361 Commits

Author SHA1 Message Date
Allan Odgaard
621e275b52 Begin-of-line zero-width search results would not show any content
This would happen if searching for an anchor that would match at the beginning of a line, e.g. ‘\A’ or ‘^’, with zero actual characters matched.
2020-06-09 16:48:37 +07:00
Allan Odgaard
e80ef1d0b7 Remove use of OBJC_WATCH_LEAKS 2020-06-05 21:22:50 +07:00
Allan Odgaard
44fbea7dc6 Avoid using BSTR macro in OakDocument.mm
This is a debug macro that shouldn’t be used by non-debug code.
2020-06-05 21:22:50 +07:00
Allan Odgaard
4ec10c0923 Don’t annotate types and classes with PUBLIC
This was required when we linked each framework as its own thing, which we do not do anymore, and if we do go back to this system, we can simply have symbols public by default.
2020-06-05 21:22:50 +07:00
Allan Odgaard
906aea3cca Use new find_t::each_match in folder search 2020-06-03 21:21:46 +07:00
Allan Odgaard
733ab302e2 Change variable name: observerId → token
Several places already used ‘token’ as the name for the result from NSNotificationCenter’s addObserver:… so this change is to be consistent.

While ‘token’ is less meaningful than ‘observerId’, the variable is only used with NSNotificationCenter API where the context makes it clear.
2020-05-22 21:48:09 +07:00
Allan Odgaard
e310724951 Pass theme to OakDocumentView instead of querying settings in the object
This is because OakDocumentView is not in the view hierarchy and it obtains the theme via settings_t, so there is no way to notify about theme changes.
2020-05-14 15:43:24 +07:00
Allan Odgaard
c2019e15a1 Use CGContext instead of graphicsPort 2020-05-13 18:50:02 +07:00
Allan Odgaard
44847a6171 Make sure we always return a document from documentWithPath:
Based on crash reports, there appears to be a race condition where the weak pointer has been nilled.
2020-05-13 18:50:02 +07:00
Allan Odgaard
cb4c12681e Use NSNotificationName as type of all our notification names 2020-05-04 19:20:04 +07:00
Allan Odgaard
b514114ec7 Access most system singletons using dot syntax
These are identified by having a prefix of shared, default, or standard in the class method.
2020-04-23 12:25:11 +07:00
Allan Odgaard
814a3c78b4 Access sharedInstance using dot syntax 2020-04-23 12:25:11 +07:00
Allan Odgaard
715d023673 Declare “sharedInstance” as a class property 2020-04-23 12:25:11 +07:00
Allan Odgaard
7c78e8316c Support copy/paste of discontinuous selections that contain newlines
Previously we stored discontinuous selections as a newline-delimited string, and therefore the individual fragments could not contain any newlines.

Now that we use NSPasteboard’s multi-string support, we no longer have this limitation.
2020-04-14 12:58:10 +07:00
Allan Odgaard
f2efe71aff Store discontinuous selections as multiple strings on clipboard 2020-04-14 12:58:10 +07:00
Allan Odgaard
34eb6967c8 Use sqlite3 for clipboard history instead of CoreData
I was using the clipboard history as a testbed for CoreData but my conclusion is that it was not a good fit, and with the API we used now being deprecated, and the clipboard history needing various improvements, it’s easier just to replace the CoreData backend with sqlite3 and offers us more flexibility going forward.

With this re-implementation there is now support for storing multiple strings on the clipboard and the check to see if other applications changed the clipboard should work better (it appears that if an application is changing the clipboard while TextMate is active, sometimes the NSPasteboard’s changeCount is not updated).

It now also stores the history item’s row ID on the pasteboard, so if we select the non-latest history item and relaunch TextMate, it will no longer treat the current item on the pasteboard as a new item.
2020-04-14 12:58:10 +07:00
Allan Odgaard
d63f12993f Use class properties for general, find, and replace pasteboard instances 2020-04-14 12:58:10 +07:00
Allan Odgaard
1e065153d6 Remove legacy API for observing changes to a single file
New code should use KEventManager instead of document::watch_server_t.
2020-04-14 12:58:10 +07:00
Allan Odgaard
386c1f53db Use KEventManager to observe the file backed by OakDocument
This should handle more edge-cases than the previous API, specifically renaming ancestors or moving files to trash (now treated as a delete).
2020-04-14 12:58:10 +07:00
Allan Odgaard
2a1553fbd7 Rename custom property to support building with the macOS 10.15 SDK 2019-12-15 13:01:20 +07:00
Allan Odgaard
8f685ff25c Use std::clamp instead of oak::cap (C++17) 2019-08-01 10:23:55 +02:00
Allan Odgaard
dae1103728 Update LINK declarations 2019-07-16 19:42:29 +02:00
Allan Odgaard
1ef78b3af7 Rename symbols to what’s expected by the 10.14 SDK 2019-06-29 20:14:15 +02:00
Allan Odgaard
c9618f8eb1 Exception was thrown when requesting icon for document with no path
This could happen when doing “Find All” for an untitled document, as the find dialog uses the document’s icon in the search results.
2018-10-31 23:21:33 +07:00
Allan Odgaard
e7d87af3f5 Remove unused include of OakFileIconImage.h
This should have been removed in commit 584cadfc17.
2018-10-31 00:50:08 +07:00
Allan Odgaard
584cadfc17 Use file browser’s image class for document icons
On 10.14 the OakFileIconImage has issues (most instances show up as blank).
2018-10-30 16:12:37 +07:00
Allan Odgaard
8e31254f70 Store captures from last search with OakDocument instead of OakTextView
This both allows updating the captures from outside the text view (e.g. Find dialog) and it uses the correct captures if performing searches in multiple tabs with delayed replacements.
2018-10-29 11:48:44 +07:00
Allan Odgaard
f6fa273912 Update coding style for where to place colon after dictionary keys
This follows the Swift style and also makes it possible to align dictionary values using TextMate’s Align Assignments command.
2018-10-07 09:54:45 +02:00
Allan Odgaard
86088f79ab Use UTF with no byte order mark when reading file with unknown encoding
We pass the selected encoding to iconv which, for encodings with a //BOM modifier, will pass over the first 2-4 bytes.

If there is a byte order mark (that should be skipped) then we will not actually show the Unknown Encoding dialog, therefor we can safely assume that files that end up presenting the Unknown Encoding dialog will not have any byte order mark.
2018-10-03 20:11:20 +02:00
Allan Odgaard
8de6bb6a46 Let clipboard_t::entry_t accept options and remove my_entry_t subclass 2018-08-21 11:42:25 +02:00
Allan Odgaard
e70791ee89 Rename a bunch of constants to fix deprecation warnings (10.12) 2018-06-16 22:55:30 +02:00
Allan Odgaard
7a61949c33 Auto-hide scrollbars
We already auto-hide them for majority of our scrollviews, but since they are hidden by default when using a trackpad, a few “new” scrollviews didn’t get this setting, and I hadn’t noticed.
2018-04-25 21:47:38 +07:00
Allan Odgaard
f7f6444885 Only load charset (encoding) frequency database once
Previously this database was loaded each time a file of unknown encoding was read, which could add a significant overhead when using “find in folder” with a large database and many files with unknown encoding.
2017-10-03 09:43:43 +02:00
Allan Odgaard
7d38095532 Let EncodingWindowController accept NSData instead of char pointers 2017-10-03 09:43:43 +02:00
Allan Odgaard
c5fd9d074d fixup! Remove OakShowSheetForWindow wrapper (10.9)
There were two issues:

1. The window’s sheetParent property is cleared when sending orderOut: to the window so the NSModalResponse was never passed on, as we were sending it to nil.

2. The endSheet:returnCode: was using NSModalResponseCancel but the completion handler was actually testing for NSModalResponseAbort
2017-09-12 16:57:00 +02:00
Ronald Wampler
903d34338d Remove remaining 10.9 LEGACY markers 2017-05-31 10:03:41 +02:00
Ronald Wampler
043a00c934 Remove OakShowSheetForWindow wrapper (10.9)
Also removed `OakSheetCallbackDelegate` since it's no longer used now.
2017-05-31 10:03:41 +02:00
Ronald Wampler
30891b1a62 Remove OakShowAlertForWindow wrapper (10.9) 2017-05-31 10:03:41 +02:00
Allan Odgaard
78a71705bc Cache document’s display name to avoid repeated file system stats
This would be slowing down editing when using a high-latency file system, as the document’s display name would be fetched each time the window was updated.
2016-12-03 21:43:04 +07:00
Ronald Wampler
a499a1559d Ensure file is on disk before adding it to the Recent menu
This reimplements 9c3923b485, which was accidentally lost in refactoring.
2016-12-03 21:43:04 +07:00
Allan Odgaard
51c067fb2d Fix race condition
We could call pop_callback before having pushed one because the latter is done after delay.

Also, when disabling observeSCMStatus we now destroy the SCM handle rather than only remove our callback (since we do not re-use the handle).
2016-11-15 21:49:35 +07:00
Allan Odgaard
dd7a7b2724 Revert "Fix race condition"
This reverts commit 9467f3f92b.
2016-11-15 21:49:34 +07:00
Allan Odgaard
9467f3f92b Fix race condition
We could call pop_callback before having pushed one because the latter is done after delay.

The way we obtained a weak reference to ourself was also scoped incorrectly so our block effectively had a strong reference to self.

Lastly when disabling observeSCMStatus we should destroy the SCM handle rather than only remove our callback (since we do not re-use the handle).
2016-11-11 15:47:19 +07:00
Allan Odgaard
944ad3ea5d Rename API: add_callback → push_callback
This makes it clear what is actually done.
2016-11-11 15:47:19 +07:00
Allan Odgaard
3e276e7e04 Update assertion
We change the semantics of “open” when we introduced the “loaded” property.
2016-11-04 19:22:39 +07:00
Allan Odgaard
aec44343ff Cancelling a save dialog could mark document as saved 2016-11-02 23:02:18 +07:00
Allan Odgaard
c92e0c42d8 Provide save dialog with document’s file type for encoding settings
Previously the save dialog would update encoding settings solely based on the path, but the user could set different line endings or character set for a file type (rather than extension).
2016-11-02 23:02:18 +07:00
Allan Odgaard
c624424539 Add kSearchIgnoreOrderingKey for when enumerating documents at path
This will return all open documents before starting to scan the disk and should make functionality like Open Quickly… (⌘T) feel faster (if enabled).
2016-10-22 23:27:16 +07:00
Allan Odgaard
948d7106d8 Add openDocumentsInDirectory: method for all open documents in folder 2016-10-22 23:27:16 +07:00
Allan Odgaard
05749c5c64 Document creation in background thread could fail
This is because we remove the document record in dealloc (unregister), but at that time, the reference in the record (for the path/inode) has already been zeroed, so if a document is created for the same path/inode after the reference has been zeroed but before the record has been unregistered, we would use the zeroed reference as the result from documentWithPath:.
2016-10-22 23:27:15 +07:00