3071 Commits

Author SHA1 Message Date
Allan Odgaard
28533a48d6 Ignore binary identification glob when search should include binary files 2016-06-22 19:45:24 +02:00
Allan Odgaard
ff4a796c20 Don’t pass inserted data to the buffer_t metadata hooks
None of the hooks actually use this data and as they are called after the replacement has been done, they can query the buffer, should they require information about its content.

The problem with having to pass the data pointer to the hooks is that there could be future situations in where the buffer’s data is not inserted as one contiguous block of memory, for example we could allow constructing a buffer from a storage_t instance.
2016-06-22 18:31:49 +02:00
Allan Odgaard
61a3a6229a Use constructor delegation for buffer_t 2016-06-22 18:31:49 +02:00
Allan Odgaard
f5832c975f Add missing include statements 2016-06-22 18:31:49 +02:00
Allan Odgaard
371d426c5f Add ‘char const*’ insertion API to ng::buffer_t 2016-06-21 23:23:44 +02:00
Allan Odgaard
7ac10b7b29 Add to_ns helper function which creates an NSString from std::string 2016-06-21 22:11:13 +02:00
Allan Odgaard
daa90613f0 Use BOM versions of UTF-16/32 in list of default encodings
If we find that the user doesn’t have any BOM versions enabled but do have the non-BOM versions then we update their settings to instead use the BOM versions.
2016-06-21 19:47:44 +02:00
Allan Odgaard
b72091b3bb The encoding::charset_from_bom function now return “«charset»//BOM” 2016-06-21 19:32:47 +02:00
Allan Odgaard
55b2f6366e Remove ‘useBOM’ settings key 2016-06-21 19:31:22 +02:00
Allan Odgaard
7b2e296907 Remove BOM support from encoding::type 2016-06-21 19:30:22 +02:00
Allan Odgaard
4b3d959c85 Remove explicit BOM handling from the file framework 2016-06-21 19:28:29 +02:00
Allan Odgaard
735ba3a386 Remove explicit BOM support from document_t 2016-06-21 19:20:56 +02:00
Allan Odgaard
0e0eba8a54 Add BOM versions of all unicode transformation formats 2016-06-21 19:19:37 +02:00
Allan Odgaard
7e8aa8b898 Remove “byte order mark” support from the save panel
This can be specified via the encoding.
2016-06-21 19:18:17 +02:00
Allan Odgaard
f60e0dad98 Use text::transcode_t instead if iconv API 2016-06-21 18:33:20 +02:00
Allan Odgaard
0520e4fe88 Add text::transcode_t which is a wrapper for iconv
Apart from being simpler to use this wrapper supports adding ‘//BOM’ to the charset name to either consume or produce a byte order marker.

It also converts invalid byte sequences to (ASCII) escape codes, e.g. \x8F.
2016-06-21 18:31:29 +02:00
Allan Odgaard
4758061719 Do not add final newline to hex dump 2016-06-21 10:51:55 +02:00
Allan Odgaard
e8df02f4a4 Let buffer_t delegate operator== to its storage member 2016-06-21 06:19:04 +02:00
Allan Odgaard
da96be12c9 Add comparison operators to storage_t class 2016-06-21 06:18:55 +02:00
Allan Odgaard
aa310c87c5 Add const access to buffer_t’s underlying storage
This is to be used for cheap snapshots.
2016-06-20 18:19:14 +02:00
Allan Odgaard
a2dfe22339 Only expose pointer to const bytes owned by memory_t::helper_t
This guards against misuse of the API, as the compiler should now enforce our append-only design.
2016-06-20 18:19:13 +02:00
Allan Odgaard
608b375b30 Let the constructor of memory_t::helper_t accept an iterator pair
This should make the API more clear, as there is no longer the requirement to copy bytes after constructing memory_t with a non-zero size.
2016-06-20 18:19:13 +02:00
Allan Odgaard
b6861444c8 Replace memory_t::grow with memory_t::append
This makes it clear that we can only append to a memory_t type.
2016-06-20 18:19:13 +02:00
Allan Odgaard
3c3b48f9ad Rename memory_t::free → memory_t::available 2016-06-20 18:19:13 +02:00
Allan Odgaard
fb7c2cef3f Use NSUserDefaults’s specialized «type»ForKey: 2016-06-20 11:43:40 +02:00
Allan Odgaard
bc20f67d05 Revert "Search results are now added in batch to limit KVO notifications"
This was published by mistake as 8175d2d9d8 address the same problem but with less complex code.

This reverts commit f7edb51ea3.
2016-06-19 22:08:36 +02:00
Allan Odgaard
89376e6ac9 Always ask OakFileBrowser to validate deselectAll: and reload:
Also simplify code so that we only need to maintain a set of which actions the file browser should validate.
2016-06-19 09:40:09 +02:00
Allan Odgaard
6e8ab01c09 Let OakFileBrowser validate menu items sending deselectAll: 2016-06-19 09:40:08 +02:00
Allan Odgaard
0a0b9a8052 Move Select None to File Browser (main) menu
This was previously placed in the file browser’s action menu and thus probably overlooked by many, even though ⇧⌘A is a very useful key equivalent, since many commands work on the entire project when there is no selection in the file browser.
2016-06-19 09:40:08 +02:00
Allan Odgaard
dc0331b781 Change File Browser → Current Document to Select Document
Also make the title dynamic so that we show the current document’s name (when we have one) and add a separator below the menu item.
2016-06-19 09:40:08 +02:00
Allan Odgaard
5c7b04fbd3 Add missing include for test/jail.h 2016-06-19 08:45:16 +02:00
Ronald Wampler
5bb89898fb Move "Go to File" to File menu and rename to "Quick Open" 2016-06-19 08:45:16 +02:00
Ronald Wampler
e452a5ee55 Move "Go to Tab" to the Window menu and rename to "Select Tab"
Also edit the source to reflect the change in name (e.g., `updateGoToMenu:` → `updateSelectTabMenu:`).
2016-06-19 08:45:16 +02:00
Mike Meyer
91befc271b Read the gutter fontName from user defaults
defaults to textView fontName
2016-06-19 08:33:03 +02:00
Allan Odgaard
a4deade16a Show path of default keybindings as TextMate.app ▸ KeyBindings.dict
This is instead of showing the full path. The user can still get to the file by using the “Edit” button.
2016-06-18 12:15:32 +02:00
Allan Odgaard
45a23472cb Use localized number formatting for collapsed search result headers 2016-06-18 12:15:32 +02:00
Allan Odgaard
b232a70d69 Remove countOfLeafs property from OakSearchResultsHeaderCellView 2016-06-18 12:15:32 +02:00
Allan Odgaard
f7edb51ea3 Search results are now added in batch to limit KVO notifications
Majority of the time in the main thread was spent updating the countOfLeafs property since canReplaceAll and the result text are dependent on this property.
2016-06-18 12:15:32 +02:00
Allan Odgaard
5d9ad561dc Deleting last item in pasteboard history browser is now a no-op
Unfortunately disabling the “Delete” button is cumbersome because our history is stored with CoreData so knowing the number of items in the history requires a fetch request, which we would not know when to re-run (to update the disabled state when the history is changed).

When the filter string is empty we can use the array controller’s results, but I’m leaving that for the future.
2016-06-18 11:29:13 +02:00
Allan Odgaard
705fc6e0e9 Change “Clear All” → “Clear History” in pasteboard history browser
Technically we are unable to delete the pasteboard’s current item so “Clear All” was performing a “Clear All Minus One”. While the new label does not make this clear, it at least does not promise to clear everything.
2016-06-18 11:29:13 +02:00
Allan Odgaard
3346f8e237 Use operator== from document_t instead of its identifier’s
This serves to make the code slightly more abstract and allows the document to optimize the comparison operator, e.g. testing pointer equivalence before involving more complex checks.
2016-06-18 11:29:13 +02:00
Allan Odgaard
8175d2d9d8 Do not observe count of matches until search has completed
We do not display this counter during the search but triggering a KVO notification for each search result has a noticeable overhead and can result in unresponsive UI when the number of results are in the hundreds of thousands.
2016-06-18 11:29:05 +02:00
Allan Odgaard
994f3538f5 Clear old search results in setDocumentSearch:
That we have an empty results array is a prerequisite for starting a document search, so we should do it in the method itself.
2016-06-18 10:34:49 +02:00
Allan Odgaard
3fab3fe3d0 Use CoreFoundation when converting NSString → std::string
This is significantly faster on OS X 10.11.

The API is slightly different so this is probably still faster in macOS 10.12 where there should be less of a performance difference between using Foundation and CoreFoundation.
2016-06-18 10:34:49 +02:00
Allan Odgaard
8483826fae Always use '\0' as fill value when creating a string buffer 2016-06-18 10:34:08 +02:00
Allan Odgaard
5d4a14e14b Bundle Editor: Set bundle item’s name as document’s custom name
This affects the name used for backup files and TM_DISPLAYNAME which could be used by some commands invoked from the bundle editor.
2016-06-17 17:42:57 +02:00
Allan Odgaard
c0637c1037 Fix issue with “one file searched” format string
When using $n in a format string placeholder for n > 1 then we must also include $n-1.
2016-06-16 20:04:26 +02:00
Allan Odgaard
258e5449f1 Improve folder search performance
This relates to documents with many matches on the same (long) line.

Previously we would search for “end of line” per match found, which for a single-line document was effectively quadratic time complexity.

Furthermore we would make a string copy of the entire line for every match. This is now limited to 500 bytes (or longer if the match requires it) with the context before the match being up to 150 bytes (it’s using modulo so adjacent matches should generally show context starting from the same offset).

The test case for the optimization was a 3MB file with only 2 lines and 150,000 matches. After this commit the results are presented in about two seconds (Macbook Pro). Not impressive but much better than before :)
2016-06-16 20:04:21 +02:00
Allan Odgaard
41ed2817e7 Remove unused ‘searchBackups’ argument from document::find
The function will always search backups and so far there has not been a reason to disable it.
2016-06-16 10:53:11 +02:00
Allan Odgaard
d2b29d69af Delete layout and editor objects before closing document
Both of these objects may observe the buffer owned by the document, so we should be sure the observers are gone since closing a document may delete its buffer.
2016-06-16 10:50:25 +02:00