Commit Graph

306 Commits

Author SHA1 Message Date
Allan Odgaard
69c83e56df The ‘const’ keyword should be to the right of its type
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.

E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
2014-03-31 08:27:19 +07:00
Allan Odgaard
4f4fe38aec Use path::escape instead of local code 2014-03-29 18:58:53 +07:00
Allan Odgaard
6d6210e490 Use ‘assign’ instead of ‘weak’ when building for 10.7 2014-03-28 10:19:06 +07:00
Allan Odgaard
33178679c7 Scroll to caret failed if mouse button was pressed
We want to disable “make selection visible” when the user is drag-selecting, though the previous check was too broad and would disable it if user opened a document via double click (e.g. a find in folder result).
2014-03-27 07:53:55 +07:00
Allan Odgaard
247e866760 Going to symbol or bookmark will now center selection
Previously it would just make sure the selection was visible, so if the symbol was already visible, no scrolling/centering would take place.

For most actions we want to minimize scrolling since it makes it easier to keep track of the location in the document, but for the “Go to …” actions, we’re doing an absolute positioning rather than a relative jump, so it makes sense to always center.

For bookmarks, it’s only when choosing a specific bookmark from the Navigation menu that we center selection, not when using the next/previous bookmark actions.
2014-03-25 20:32:46 +07:00
Allan Odgaard
a052c81cfa Improve crash reporting for C++ exceptions from keyDown: 2014-03-25 20:32:46 +07:00
Allan Odgaard
90d1fd432d Non-local drags from TextMate now include NSDragOperationGeneric 2014-03-25 12:19:57 +07:00
Allan Odgaard
af0e6cc643 Change decltype(mapVariable)::value_type → auto (C++14) 2014-03-16 18:06:03 +07:00
Allan Odgaard
de99c053db Do not call unimplemented method on super
This was broken by commit 5edd3479ba.
2014-03-12 15:50:39 +07:00
Allan Odgaard
1183367694 fixup! Do “refresh” for actions which are no-op due to current state 2014-03-10 16:44:28 +07:00
Allan Odgaard
3786e0e823 Do “refresh” for actions which are no-op due to current state
For example when caret is at the beginning of the document, using “move left” would be a no-op and would cause “refresh” to be skipped, which meant if the caret was outside the visible area, no scroll would happen (to make it visible).
2014-03-09 17:13:57 +07:00
Allan Odgaard
337dc1a221 Update sizing code for snippet pop-up menu
We now rely on the table view to obtain the entries and setup the data cell, which should make the code easier to use for other table views with a different data source implementation.
2014-03-06 10:15:09 +07:00
Allan Odgaard
5e1f86a7c2 Setting disableIndentCorrections to ‘1’ was not treated as :true 2014-03-06 10:15:09 +07:00
Allan Odgaard
1e11a30a53 Remove redundant storage keywords for @property
These were required prior to the new 64 bit run-time.
2014-03-05 16:39:54 +07:00
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
be92d71c46 Allow disabling indent corrections when typing on empty lines
This is generally desired when the indent of a new line does not (necessarily) depend on lines above it, but where we otherwise do want indent corrections, e.g. HTML.
2014-03-02 20:06:31 +07:00
Allan Odgaard
a180c24539 Run will/did save and activate/deactivate callbacks in sequence
Previously only the most specialized callback(s) would run. For example creating a command scoped to “source” with “callback.document.will-save” for semantic class would never run for Ruby, Python, etc. because the Source bundle has a “Make Script Executable” callback scoped specifically to “source.ruby”, “source.python”, etc.
2014-03-02 13:15:34 +07:00
Allan Odgaard
e71be609e0 Use new pasteboard history browser
Closes #481
2014-03-02 12:13:06 +07:00
Allan Odgaard
1a4314fce2 Wrap initialize code in dispatch_once
This is only done for code where running it twice would actually cause a problem.

Dispatch_once is favored over a static boolean only because it seems to carry slightly more semantic information.
2014-02-26 19:36:54 +07:00
Allan Odgaard
362c18c3e0 Record current replace string as part of macro find action
Previously we would only record it if the user invoked a replace action from the find dialog, but the user may invoke “find” from the dialog and then subsequently “replace” via keyboard/menu (where we would not record the string).
2014-02-20 22:09:35 +07:00
Allan Odgaard
95b834ac0a Grammars with no root scope are no longer shown in the UI
Only injection grammars should have an empty root scope, and if so, it does not make sense to allow the user to pick it as document grammar.
2014-02-20 13:14:36 +07:00
Allan Odgaard
8c9ebc46ea Ignore caret’s “desired X” in positionForWindowUnderCaret:
For example if at column 60 on a line and moving up/down to a shorter line, we remember that column 60 is our desired column position. This would previously be used when returning a position for the caret, e.g. used with clipboard history pop-ups and bundle item disambiguation menus.
2014-02-19 15:41:48 +07:00
Allan Odgaard
fe1f50f279 Do not store captures (from regexp matches) on replace clipboard
Instead these are stored as an OakTextView property. This makes more sense since we only want to use the captures in the text view that created them.
2014-02-18 13:16:27 +07:00
Allan Odgaard
57e8e37313 Rename NSReplacePboard → OakReplacePboard
We shouldn’t use Apple’s prefix for our own constants. The actual value of the constant hasn’t been renamed yet as this requires “migration” (renaming the key in user defaults).
2014-02-18 12:41:47 +07:00
Allan Odgaard
8ebbb338c2 Disallow creating OakPasteboardEntry outside OakPasteboard.mm
This is in preparation of adopting CoreData which will require a managed object context to create pasteboard entry objects.
2014-02-18 11:53:41 +07:00
Allan Odgaard
b3d12b4364 Set explicit target for status bar menu items
These items were relying on “first responder” which only works when focus is in the document view (since that’s the object that implements the actions).

This would manifest itself by showing the items disabled when focus was in the file browser, and for the grammar pop-up, the selected item (after opening the menu) would not be reverted back to the actual selected grammar in the document view.

Closes #1213
2014-02-13 13:38:35 +07:00
Allan Odgaard
5edd3479ba Implement accessibilityIsAttributeSettable: for all attributes
Previously if using the Accessibility Inspector exceptions could be thrown.
2013-12-26 15:19:28 +07:00
Ronald Wampler
1f61b628b3 Use new safeObjectAtIndex method
Also removed the static SafeObjectAtIndex mehtod in OakTabBarView
2013-12-22 23:30:29 -05:00
Allan Odgaard
5faba29bb5 Fix value for AXSelectedText
We were grabbing a const reference to a reference into a temporary object (result of editor_t::ranges), so the range used was effectively a pointer to a destroyed object.
2013-12-21 11:13:15 +07:00
Allan Odgaard
32ce648224 Clicking a folded range will now unfold it 2013-12-20 09:56:53 +07:00
Allan Odgaard
c94f6d8555 Improve “you are recording a macro” dialog
Rather than tell the user how to stop recording, we now offer it as an option.
2013-12-19 18:58:55 +07:00
Allan Odgaard
7d91fd8322 Allow fractional font sizes.
Closes #1125
2013-12-14 12:10:05 +07:00
Allan Odgaard
c2bb5253ef Ensure text view find operations use values from the UI
We already commit the values when focus is lost, but it’s possible to initiate a find operation while focus is still in the find dialog text fields (via the menu).

Fixes #1183
2013-12-12 14:45:05 +07:00
Allan Odgaard
9f07942e09 Use dynamic menu titles for most toggle items
Closes #935
2013-12-12 13:36:16 +07:00
Allan Odgaard
b568f2e788 Handle dropping CR delimited text
Also filter malformed UTF-8 sequences from dropped text.
2013-11-28 17:07:55 +07:00
Allan Odgaard
888ccbed16 Remove use of NSPointToCGPoint
This is not required when building in 64 bit mode or when defining NS_BUILD_32_LIKE_64.
2013-11-18 22:43:50 +07:00
Boris Dušek
22a5dc1413 Support getting AXVisibleCharacterRange accessibility attribute 2013-11-15 18:14:03 +07:00
Boris Dušek
c7fbcf06ed Fix accessibility visual bounds ending at line boundary
Accessibility visual bounds for a range of a single softline should always
be also visually restricted to the softline. This is in order to be consistent
with implementation in Apple's apps (e.g. TextEdit).
2013-11-15 17:58:28 +07:00
Boris Dušek
9f68cb416c Use softlines instead of hardlines for accessibility
Fixes #1149.

VoiceOver expects AXLineForIndex and AXRangeForLine to be consistent with
the movement by line using arrow up/down. That means it expects "line"
to mean softline.

VoiceOver also distinguishes commands to move by:
* paragraph (hardline): VO-Shift-PgUp/PgDown
* line (softline): VO-up/down

These are available when interacting with the text area (VO-Shift-down).

This commit therefore fixes the AXLineForIndex and AXRangeForLine
to make "line" mean "softline" instead of "hardline" as was the case
until now.
2013-11-15 17:58:18 +07:00
Boris Dušek
5dcca0996c Support text links with VoiceOver
Now links in text (e.g. links to RFCs after installing the Hyperlink Helper bundle)
are announced as such with VoiceOver and it is possible to search for them with
VO-Cmd-L.

TODO:

* launching links with VO-Space is not supported yet, but Enter (Fn-Return)
  does the same thing and is even more reliable.
* link URL is not supported, so it is not possible to learn the URL
  with VO-Shift-U.
2013-11-15 16:09:02 +07:00
Allan Odgaard
8f90f8f602 Defensive programming
Seeing a common crash on quit which might be due to drawRect: being called when the OakTextView is in a partially destroyed state.
2013-11-04 14:09:27 +01:00
Allan Odgaard
2df3118e34 Do not set window as opaque when gutter background is transparent
Previously only the text view’s background would affect the window’s opaque property, which made it impossible to have a solid text view background with a transparent gutter.
2013-11-03 20:37:48 +01:00
Allan Odgaard
7402a7835b Opt out of responsive scrolling
With responsive scrolling we need to return NO from isOpaque in order to get transparency and we cannot overload the scrollWheel: method (which we use to forward mouse events from the gutter to the text area).

I have also received a few crash reports that might be caused by responsive scrolling and one user has reported “sticky” scroll behavior.

So for now better just disable it, and see if it fixes all these issues.

Fixes #1135
2013-11-03 20:37:48 +01:00
Allan Odgaard
e16bacb6f9 Loosen rules about tab trigger boundaries
Previously the character before the potential tab trigger had to be of a different character class. This is now only required when the first character of the tab trigger is a word character.
2013-10-30 21:35:08 +01:00
Allan Odgaard
734f24552d Update symbol chooser to use OakChooser
Fixes #1160
2013-10-27 20:07:48 +01:00
Allan Odgaard
3064fb82b4 Change text::range_t → ng::range_t 2013-10-20 19:10:02 +02:00
Steven Clukey
bbe1ca357b Add “invisiblesMap” option to the .tm_properties file
This setting allows changing which invisibles are shown and what glyph
is used for them.

Invisibles are '\t', '\n', and ' ', to turn one off, add ~[\t \n] to
the settings string. To set the glyph used for the invisible, add [\t
\n][glyph_to_use].
2013-10-08 23:06:29 +02:00
Allan Odgaard
186af2fb21 Always place bookmarks on top of “search marks”
Logically I think the less temporary marks should be eclipsed, but this currently lead to inconsistencies with respect to hover images, e.g. hovering a search mark that also has a bookmark should show “remove bookmark” which it presently doesn’t, and will require a bit of refactoring to allow.

Issue #1132
2013-10-05 14:32:37 +02:00
Allan Odgaard
fe9b6b0721 Workaround for Xcode 5
My interpretation: The old inline array is interpreted as an initializer list which cannot (yet) be used with Objective-C objects when ARC is enabled.

Fixes #1037
2013-09-22 12:55:42 +02:00
Boris Dušek
21088105a8 Support text attributes with VoiceOver
VoiceOver can announce text formatting, such as bold font, italics,
underline, font, etc., as well as whether text is misspelled. For this,
it needs the AXAttributedStringForRange attribute supported. This commit
does exactly that.

Testing can be done in this way (VO stands for Ctrl-Option):

* first interact with the text (VO-Shift-down arrow when standing
  on the text element)
* to announce text attributes for character after cursor, press VO-T
* to seek for next:
  * misspelled text: VO-Cmd-E
  * color change:    VO-Cmd-K
  * underlined text: VO-Cmd-U
  * many more (see VO-H-H, "Find", close help with Esc)
* to seek for previous *: just add Shift to the shortcut

Some attributes remain to be supported (full list of attributes is available at: https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/Protocols/NSAccessibility_Protocol/Reference/Reference.html#//apple_ref/doc/uid/20000945-SW53).

The misspelled text VoiceOver support can be used nicely with TextMate's
spelling support:

1. the user finds next mistake with VO-Cmd-E, hears the misspelled word,
   perhaps reads it on a braille display
2. the user then presses Cmd-; to show the spelling menu for that word
   and chooses the desired resolution (apply suggested correction etc.)
3. go back to step 1. :-)
2013-09-12 23:13:57 +02:00