Is there an API for code editing in Cocoa? - macos

I've been exploring various text editor solutions for Mac OS X recently, and I've noticed that some editors, namely Xcode, Smultron and CodeRunner, show the same behavior with bracket matching, which makes the matching bracket exhibit a small yellow popping animation that looked exactly the same throughout the editors. This made me think about whether there is a unified Cocoa API for code views that is being used. I have looked for something like that but I haven't found anything. Can someone enlighten me?

There is no unified Cocoa API for code views, no, or at least not that I am aware of. The yellow popping animation is just due to the Cocoa method -[NSTextView showFindIndicatorForRange:], which lots of different code editors use for producing that sort of effect. However, if you search stackoverflow you'll find some examples of how to do syntax coloring, bracket matching, etc. You might also find the source code in this project useful: https://github.com/MesserLab/SLiM. (Which happens to be a project I work on.)

Related

SDL2 program doesn't show IME candidate window

I’ve been having some inquiries from CJK players of my SDL2-based game on Windows, asking about IME text entry; the candidate list window simply doesn't appear for them, making it impossible (or very difficult) to type certain glyph compositions. Right now I’m using the current latest SDL2, version 2.0.12.
As far as I can tell, I’m doing everything in approximately the right way; calling SDL_StartTextInput() when keyboard focus is moved to an (in-game-rendered) editable text field, and SDL_StopTextInput() when the keyboard focus leaves it, as well as setting SDL_SetTextInputRect() to tell the OS where the text field is. SDL_TEXTINPUT and SDL_TEXTEDITING events seem to come through the event loop as they're documented to do; everything seems to be working, except that the candidate list window doesn't open.
And it all works exactly correctly in Linux and Mac builds, with IME candidate list windows popping up at the right times and right places and functioning correctly to allow entry of composed CJK unicode glyphs, on those OSes. It's only on Windows where the candidate list window just never opens, which is a big problem for a bunch of my players. Does anybody know how one is intended to handle IME compositions under SDL2 on Windows? (I'm doing all of this testing with Windows 10's default IMEs for Japanese and Simplified Chinese)
Can anybody fill me in on how the system is intended to be used? The tutorial page on input methods is really thin on details, and I can’t find a real demo program which shows how IME is actually intended to be handled in SDL2, or I’d just copy what they were doing.
May or may not be relevant, but my game is an OpenGL 3.3 game, using SDL for window management, input, and cross-platform multithreading support; we’re not using SDL’s built-in renderer at all.
EDIT:
I’ve put a minimal example program over here on GitHub, demonstrating what I’m seeing. It’s just fifty lines of C code, so if I’m doing something catastrophically silly, it should hopefully be pretty easy to spot!

In Visual Studio Code, is it possible to Edit the MiniMap View with settings

I'm updating some legacy code, because of my unfamiliarity to it, Its very difficult to find structures, especially if I step away for a week for other projects.
To alleviate this problem I've gone back to my old-school roots and started adding ascii text-art as comments above sections of code, using this tool:
http://patorjk.com/software/taag/#p=display&h=3&v=1&f=Big%20Money-ne&t=Reveal%0ACheck
This allows me to see via my MiniMap the titles of functions or sections of code I might need to come back to
The Thought then occured.. well surely someone else has this problem, and since VSCode seems to be written by the community, maybe someone has already written a plugin that would search the code for function titles (like Javadocs?) and display the title in a readable size?
If not, would it be easily coded? i.e. is the minimap just a very shrunk down copy(not easy) or is it structured and can be parsed and tweaked?
As long as your language plugin supports it, you can use cmd + shift + o to go to function definition.
All functions should also be listed in the Side Bar under "Outline"

Domino on mac client - weird doc behavior

I support an old (late 90s) Domino DB that has a growing number of Mac users. In some docs, layout regions become grayed out once you click anywhere in the doc even though it's still editable, i.e. if the cursor was in a text field and you type something blindly and save it, it will be there when you reopen the doc. It doesn't happen in all docs and I have found no pattern.
Any Domino designers seen any behavior like this? I don't this there is anything too weird in the code; onBlur or onChange used in some cases - that sort of thing. Nothing too complicated really. Thanks!
Layout regions are a nightmare to maintain: there can be objects with differing hide-when formulas stacked on top of each other that might be causing this. I suggest making a copy you can work in without worry: inspect each object fully (keeping notes) then delete. Keep drilling down until you hopefully hit an object that matches your grey-out. If you don't find one, then it could be a bug as posted by Richard Schwartz. As Richard and D.Bugger suggest, perhaps it's time to rebuild the functionality without using a layout region: layout regions never worked with a web browser.

Fix for Xcode's indiscernible highlighting of inline errors?

I can't be the only one that finds Xcode's method of "pointing out" where your mistakes are - ridiculous. As helpful and essential as the feature is.. it does not help to make the line I need to fix virtually impossible to read or edit... let alone see...
And don't get me started on the constant struggle to find a "selection" color that is visible, yet retains one's sanity/ability to see what the selected text actually IS!
What am I missing here? I know how to futz with the colors in xCode, I know how to mess with the Appearance "Control Panel", but it all just results in different configurations - of varying aesthetic quality - that are all hard to read... I don't have this issue in TextMate... Is that my answer?
UPDATE: Thanks to the brilliant work, and answer by #amadillu, here is what the remarkably more usable Xcode looks like after installing his Xcode 4 "Fix-Ins"
I've made an Xcode Plugin by using davekeck's "fixins" that allows you to customize the colors of the inline error and warning messages. This really helps if you use a dark scheme / background . See here.

Readymade Cocoa Spotlight UI Components

I'm new to developing on the Mac and am looking to implement an interface similar to Spotlight's - the main part which seems to be an expanding table/grid view.
I was wondering if there is a component Apple provides for creating something like this or is available open source else where.
Of course if not I'll just try and work something out myself but it's always worth checking!
Thanks for your help in advance.
New Answer (December, 2015)
These days I'd go with a vertical stack view ( NSStackView ).
You can use its hiding priorities to guarantee the number of results you show will fit (it'll hide those it can't). Note, it doesn't reuse views like a table view reuses cell views, so it's only appropriate for a limited number of "results" in your case, especially since it doesn't make sense to add a bunch of subviews that'll never appear. I'd go so far as to say outright you shouldn't use it for lists of things you intend to scroll (in this case, go with a table view).
The priority setting can be used to make sure your assumption of what should be "enough" results doesn't cause ugly layout issues by letting the stack view "sacrifice" the last few.
You can even emulate Spotlight's "Spotlight Preferences" entry (or a "show all" option) by adding it last and setting its priority to required (1000) so it always stays put even if result entries above it are hidden due to lack of space.
Lately all my UI designs for 10.11 (and beyond) have been making heavy use of them. I keep finding new ways to simplify my layouts with them. Given how lightweight they are, they should be your go-to solution first unless you need something more complex (Apple engineers stated in WWDC videos they're intended to be used in this way).
Old 2011 Answer
This is private Apple API. I don't know of any open-source initiatives that mimic it off-hand.
Were I trying to do it, I might use an NSTableView with no enclosing scroll view, no headers, two columns, right-justified lighter-colored text in the left column, the easily-googled image/text cell in the right column, with vertical grid lines turned on. The container view would observe the table view for frame changes and resize/reposition accordingly.
Adding: It might be a good idea also to see if the right/left justified text (or even the position of the columns) is different in languages with different sweep paths. Example: Arabic and Hebrew are read right-to-left. Better to adapt than to say "who cares" (he says flippantly while knowing full well his own apps have problems with this sort of thing :-)). You can test this by making sure such languages are installed on your computer, then switching between them and testing out Spotlight. Changing languages shouldn't pose an issue since the language switching UI doesn't rely on reading a foreign language. :-)

Resources