Commit Graph

69 Commits

Author SHA1 Message Date
Allan Odgaard
bccaee4be6 Simplify document open API
Removed the ability to specify wether documents should open in current window or a new window — all documents opened via this API will go through the same algorithm to find where the documents should end up (more choice is just adding confusion and complexity).
2013-01-10 06:46:44 +01:00
Allan Odgaard
8e937a7141 Require explicit import of OakFindProtocol.h 2013-01-02 01:46:48 +01:00
Boris Dušek
5369b7cf81 Add support for “Zoom follows the keyboard focus”
Zoom is an OS X accessibility feature that lets sighted visually
impaired users magnify screen content. This commit notifies Zoom of
changes of TextMate’s caret position on screen so that Zoom can
automatically follow the caret when the user moves it.
2012-12-14 21:55:12 +01:00
Boris Dušek
224ee5fd5e VoiceOver/accessibility support for text view
This commit adds support for most common accessibility
methods/attributes to the OakTextView component. In user's language,
VoiceOver users (i.e. blind and visually impaired users) can now use
TextMate to read and write text.

A few less used accessibility attributes remain to be supported -
especially AttributedStringForRange and StyleRangeForIndex which should
allow blind users to e.g. see and seek for spelling errors in text.
2012-12-14 21:55:12 +01:00
Allan Odgaard
36902cbc6c Factor out ng::range_t ⇔ NSRange methods 2012-12-14 21:55:12 +01:00
Allan Odgaard
aef4a2206c Use caret’s right scope when expanding tab triggers 2012-09-30 15:25:45 +02:00
Allan Odgaard
9f2a4c74da Add callback.document.will-save
Commands can prepare the document for saving in this callback, e.g. strip trailing whitespace (issue #35), ensure the line always has a newline character as the last byte in the document (issue #76), or similar.

Presently having a “will-save” command fail does not abort saving (but likely should). Also, there is no check to see if the command called requires the document to be saved before running, so that likely leads to an infinite loop.
2012-09-27 17:52:41 +02:00
Allan Odgaard
e1dd99a0f5 Add window to “document will save” notification
The text view needs to do a little work before saving a document (serialize folded text) and with the window as part of the user data, we can now skip that for text views in windows for which documents are not going to be saved.

This is not an ideal solution; long-term saving will be moved up to the DocumentWindowController which has the full view of all documents and text views.
2012-09-27 17:52:41 +02:00
Allan Odgaard
a0c4af64bd Remove trailing whitespace
Only removed from non-empty lines.
2012-09-25 14:16:50 +02:00
Mads Hartmann Jensen
adec6e4184 Incremental search keybindings
You can now use CTRL+S and CTRL+SHIFT+S to jump forwards/backwards
in the incremental search results
2012-09-24 20:58:42 +02:00
Allan Odgaard
02ab2e858a Local key bindings no longer eclipse the default set 2012-09-21 20:32:31 +02:00
Allan Odgaard
bae6270d6c Add indent aware begin/end of line action methods
The methods going to “begin of indented line” will go to the first non-whitespace character on the line, unless the caret is already there or to the left of this character, in which case it will go to the actual beginning of the line.

The “end of indented line” methods work similarly.

If you want [⇪]⌘⇠/⇢ and ⌘⌫/⌦ to use this behavior, you can add the following to your key bindings file:

	"@\UF702"  = "moveToBeginningOfIndentedLine:";
	"$@\UF702" = "moveToBeginningOfIndentedLineAndModifySelection:";
	"@\UF703"  = "moveToEndOfIndentedLine:";
	"$@\UF703" = "moveToEndOfIndentedLineAndModifySelection:";
	"@\U007F"  = "deleteToBeginningOfIndentedLine:";
	"@\UF728"  = "deleteToEndOfIndentedLine:";
2012-09-21 20:29:58 +02:00
Allan Odgaard
8ea658b3cf Command-clicking single caret could lead to crash
Command-clicking an existing caret normally toggles, unless there only is a single caret, in which case it adds a caret. This would thus allow you to add a new caret sharing the position of the existing, and command-clicking again would then remove both the two existing carets, leading to an assertion failure (as there were no carets).

Fixes issue #466.
2012-09-21 16:23:35 +02:00
Allan Odgaard
6afa7601c0 Provide utf16::advance with range end
There are several crashes reported from firstRectForCharacterRange: which indicate that the system may ask for indexes “out of range”, hence why we now effectively just cap such request.
2012-09-21 01:32:41 +02:00
Allan Odgaard
d06bd877e2 Avoid using begin/endof with ng::ranges_t 2012-09-20 12:22:21 +02:00
Allan Odgaard
ebab500ba3 Use std::map/set instead of C arrays
These types come with a find() method and avoids having to use helper functions to get the begin/end of the array (for linear search).
2012-09-20 12:22:20 +02:00
Allan Odgaard
8fd7b82cbd Remove CocoaSTL.h include 2012-09-20 12:22:20 +02:00
Allan Odgaard
565242584f Ensure document stays open in refresh helper
The refresh helper uses the document’s undo manager in its destructor. Normally the document would stay open throughout the duration of the scope in which the refresh helper is used, but it might be possible to close the current document from a nested event loop, as spawned e.g. by showing a tool tip, in which case, the document will be closed when we reach the destructor.
2012-09-18 17:33:01 +02:00
Allan Odgaard
2ef3d52a3d Remove unnecessary refresh from performKeyEquivalent: 2012-09-18 17:33:01 +02:00
Allan Odgaard
c26e5c2d36 Scope attributes are now given to editor_t
While presently it works the same, it allows us to provide better scope attributes e.g. for untitled documents (which lack SCM attributes).
2012-09-18 17:33:01 +02:00
Allan Odgaard
dabcad588d Introduce OakTextViewDelegate 2012-09-18 17:33:00 +02:00
Allan Odgaard
130d0a168d Move check for indent corrections to OakTextView
This makes it easier to introduce a UI setting for the option.
2012-09-18 17:33:00 +02:00
Allan Odgaard
8f7346ee3e Reset potential column selection cursor on caret blink
Sometimes the cursor gets stuck and there is really no workaround other than periodically reset the image.
2012-09-18 17:33:00 +02:00
Allan Odgaard
5f24a91d44 Auto-layout: Update OakDocumentView
The gutter will invalidate its intrinsic size when its width changes which will cause the Cocoa layout engine to update the layout, so no more explicit code to deal with adjusting the gutter’s width.

Likewise, the height of the gutter (not the gutter scroll view) has been setup to match the height of the text view (again, not the containing scroll view). This avoids observing the text view frame and manually updating gutter height to match it.
2012-09-14 17:14:56 +02:00
Allan Odgaard
2e2b91144d Change property to read-only
Since it uses a const reference we can’t synthesize a setter for this.
2012-09-12 18:30:37 +02:00
Allan Odgaard
cb46ba11e5 Change set-only property → method 2012-09-12 18:30:37 +02:00
Allan Odgaard
5dea94da01 Disable undo/redo menu items when appropriate 2012-09-10 22:47:58 +02:00
Allan Odgaard
cf5b5965da Don’t send theme bundle items to OakTextView
Since the text view delegates theme switching to its parent document view, we just send the theme (bundle item) directly to the document view.
2012-09-10 22:47:58 +02:00
Allan Odgaard
80a0efb563 Update themed UI colors from OakDocumentView
This is an ongoing effort to refactor and simplify OakTextView. The goal is to move decisions up the hierarchy and instead have properties on the objects lower in the hierarchy (making the components more flexible and allowing for better decision making at the higher level).
2012-09-10 22:47:57 +02:00
Allan Odgaard
d442a49e1e Add ibeamCursor property to OakTextView
We now require this to be set when changing theme, rather than have the IBeamCursor getter return a cursor appropriate for the current theme.

When switching themes we need to update several UI elements (scrollview background and knob style, gutter view, and possibly more in the future) so we might as well move the logic that picks the proper cursor color to this setup code.
2012-09-10 22:47:57 +02:00
Allan Odgaard
fe5d47272e Only fill with “clear color” for transparent themes 2012-09-10 22:47:57 +02:00
Allan Odgaard
87d780d9f6 Fix image sizes on retina Macs
We were using the point size for the bitmap mask causing the images to be doubled in pixels.
2012-09-10 14:24:05 +02:00
Allan Odgaard
05cf1232a5 Redo spell checking after changing options 2012-09-09 21:10:00 +02:00
Allan Odgaard
6807f41d3b Move spell checker methods to OTV 2012-09-09 21:10:00 +02:00
Allan Odgaard
6156cf87d7 Remove overwrite and freehanded toggles
Both from code and the menus. These were not implemented and I see no real reason to implement freehanded movement as a toggle since it is easily obtainable via column selections or option-clicking beyond EOL.

Overwrite mode might be implemented, but rather low priority.
2012-09-09 20:43:53 +02:00
Allan Odgaard
b149b4215e Use image for drawing folding dots
The color of the image can be set by adding a theme style for the foreground and scoped to “deco.folding”.
2012-09-09 11:32:42 +02:00
Allan Odgaard
e33c680269 Fix potential out-of-range access
When we update the text view frame we implicitly cause the gutter to refresh, which will ask for line records from the text view based on the selection, so we should ensure the selection is up-to-date before changing frame size.
2012-09-07 16:18:03 +02:00
Allan Odgaard
8f5ddc672f Move bundles pop-up menu to BundleMenu library 2012-09-06 23:10:56 +02:00
Allan Odgaard
f57d35362e Rename method: scope → scopeContext
This is to avoid a clash as there is also another method called scope (WebKit / DOM).
2012-09-06 23:10:56 +02:00
Allan Odgaard
79254cbb6b Add find{Next,Previous}AndModifySelection: action methods
Presently no keys or menu items bound to these.
2012-09-06 23:10:55 +02:00
Allan Odgaard
bca2b4f8c8 Don’t include existing text for “search highlights”
This is e.g. when one does Find All with one instance already selected, that one instance is left out of the found instances being highlighted.
2012-09-06 23:10:55 +02:00
Allan Odgaard
41ab738d19 Change colorWithCGColor: → tmColorWithCGColor:
On Mountain Lion the OS provides a colorWithCGColor: which tmColorWithCGColor: now wraps for (when available).

This fixes a warning when building with the 10.8 SDK.
2012-09-06 23:10:55 +02:00
Allan Odgaard
2b555aef7b Move spelling dot to OakTextView
We now load the image via NSImage and creates a CGImageRef from that (based on the current graphics context). This ensures we get the @2px version when on a HiDPI display.
2012-09-04 23:53:37 +02:00
Allan Odgaard
81de007bd4 Use new API for better bundle item display names 2012-09-04 20:34:54 +02:00
Allan Odgaard
4b8f7389fb Make hasSelection a public property 2012-09-04 20:33:28 +02:00
Allan Odgaard
a026e4ad11 Improve snippet choice menu
We filter out items that doesn’t have the current prefix and deselect current item if the user deletes the selection.

Some of this logic should probably be encapsulated by a filterPrefixString property added to OakChoiceMenu. This will also avoid the visual flash which arise when filtering the menu and selection changes (since we do one redraw w/o any items selected).
2012-09-04 19:22:53 +02:00
Allan Odgaard
0fd7d2a41b Implement Wrap Column → Other…
This is done using an alert with an accessory view. Not the best user experience, but given how rarely the user interacts with this, I wasn’t really in the mood to spend a lot of time on this part now (can always be improved later).

Closes issue #200.
2012-09-03 22:35:12 +02:00
Allan Odgaard
709882fa53 Drag-selecting beyond visible document lacked refresh
This closes issue #297.
2012-09-03 17:59:41 +02:00
Allan Odgaard
6c6ba400ff Revert "Don’t refresh gutter from OakTextView"
Turns out this is required in the situation where the document occupy less space than the visible document rect.

In this case, inserting new lines will not resize the text view, since it has been artificially enlarged to fit the visible document rect, therefore the gutter view will not update properly when inserting new lines.

I think there is a better solution than have the text view refresh the gutter, reverting is just meant as a quick fix.

This reverts commit 4e2ae3c508.
2012-08-30 18:52:49 +02:00
Allan Odgaard
4e2ae3c508 Don’t refresh gutter from OakTextView
I suspect that this was added because some operations were not properly detected, though the only thing I can find, that doesn’t properly update the gutter, is when deleting folded code in a way that doesn’t change the bounds of the text view. This code however does not address that issue.
2012-08-30 10:17:12 +02:00