341 Commits

Author SHA1 Message Date
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
mathbunnyru
440414f96c Use nullptr in all C++ files instead of NULL
This brings us a bit of extra type safety, for example where an integer is expected, nullptr should be disallowed by the compiler (unlike NULL).
2016-10-22 21:40:14 +07:00
mathbunnyru
08ad760d5e static_cast instead of c-style cast 2016-10-18 23:06:48 +02:00
Allan Odgaard
3acace3121 Remove document_t and related tests
Tests should be ported to OakDocument.
2016-10-17 10:07:29 +02:00
Allan Odgaard
a278bfd5fe Postpone loading document changes when processing user edit event
When running bundle commands we run a local event loop which means that we can receive events such as “document changed” while still waiting for the bundle command to finish.
2016-10-11 13:02:36 +02:00
Allan Odgaard
7be3703404 Change user defaults to .tm_properties for disabling extended attributes 2016-10-11 10:36:49 +02:00
Allan Odgaard
8e0b22507a Use LEGACY marker for code that should eventually be retired
This is to make it easier to search for such code.
2016-10-10 22:39:16 +02:00
Allan Odgaard
4f9446ae30 Preserve a document’s visible index when updating its selection
Both the selection and visibleIndex property should be reworked, as it’s not really document properties.
2016-10-10 22:38:00 +02:00
Allan Odgaard
6a61853183 Setting a document’s selection now resets its “visible index”
When a document has a visible index then we scroll to this index, on bringing the document to front. This is not desired when we set the selection, since we basically do that to “scroll to this location”.
2016-10-07 10:02:58 +02:00
Allan Odgaard
bf747370a8 The “first line” sniffing done when changing path now work on first 2 kb
We do have a few patterns that match multiple lines, e.g. the XML plist.

The problem would happen if a document was opened using a multi-line “first line” match, but another grammar matched its extension. If this document changed location (same extension), it would switch to use the grammar that matched its extension.
2016-10-07 10:02:58 +02:00
Allan Odgaard
b598784dbe Don’t make assumptions about document having a path 2016-09-30 12:44:01 +02:00
Allan Odgaard
07a44f7540 Always wrap document saving in open/close and inline didSaveAtPath:
Since open no longer tries to load the document it is safe to call even for a document with isLoaded == NO.
2016-09-29 09:56:49 +02:00
Allan Odgaard
e59b023119 Post OakDocumentContentDidChangeNotification for all buffer changes 2016-09-28 20:56:55 +02:00
Allan Odgaard
e93f34b5ab Only remove buffer callback if added
This is incase our initializer fails, here dealloc is still called, but we didn’t get to add the callback so we should not try to remove it.

Why our initializer would fail is beyond me, but I see a few crashes from this (though all from the same user on 10.8.5).
2016-09-27 21:49:32 +02:00
Allan Odgaard
2bf803b889 Post OakDocumentWillSaveNotification before reading extended attributes
The notification makes the text view update the visualIndex (saved as an extended attribute) so previously we would save the previous value for this attribute.
2016-09-26 11:11:15 +02:00
Allan Odgaard
e6ed50c107 Introduce kMacClassicThemeUUID since we reference it in multiple places 2016-09-26 11:09:32 +02:00
Allan Odgaard
d8312b833e Rely on NSUUID overload of to_s 2016-09-26 11:09:16 +02:00
Allan Odgaard
7cb8755a66 Fix issue with updating bufferEmpty property
We should initiate it to YES and the logic for when to skip updating was wrong because of precedence.
2016-09-26 08:09:58 +02:00
Allan Odgaard
973e38a383 Fix leak: buffer_callback_t 2016-09-25 07:31:13 +02:00
Allan Odgaard
14cdd420d3 Make backupPath property public 2016-09-24 09:37:31 +02:00
Allan Odgaard
b7e4f3bc4f Make OakDocument’s saveBackup: public API
This is required when saving session state.
2016-09-24 09:37:31 +02:00