Commit Graph

76 Commits

Author SHA1 Message Date
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
80e26b1faa Don’t dereference end-of-range iterator 2013-08-27 15:30:09 +02:00
Allan Odgaard
15a15e8c15 Remove prototype for unimplemented member function 2013-08-24 01:19:29 +02:00
Allan Odgaard
a52165694c Move crash reporter info support to own framework
This is to avoid cyclic dependencies since it was previously in a somewhat high-level framework, so everything that framework depended on, could not augment crash reports.
2013-08-12 19:32:23 +02:00
Allan Odgaard
2c0010a141 Restore “first visible character” instead of visible rectangle
This is when switching tabs ore re-opening a file.

Restoring the visible rectangle doesn’t always work because we do an initial heuristic layout where we don’t do proper soft wrap and may also lack scoped settings to increase font size for headings, meaning that the restored visible rectangle does not point to the same section of the text, as it would with a fully updated layout.

This fixes #243.
2013-08-04 14:36:45 +02:00
Allan Odgaard
9072ba8d26 Collect info related to potential crash 2013-07-31 18:42:31 +02:00
Allan Odgaard
1d4d3bd3d3 Fix path/inode lookup when opening documents
The strategy is to prefer an existing document with same path and if there is none, check if there is a document with the same inode. The latter is so that links or files that have been moved, do not create duplicate documents.

The old code used a single map for the lookup, using path::identifier_t as key (wrapping path and/or inode), though since the map is ordered, the code would occasionally fail, as the keys cannot be correctly ordered (so effectively this reworked code is a fix for an incorrect path::identifier_t::operator<).

Fixes #1052.
2013-07-30 15:34:17 +02:00
Allan Odgaard
a4a2af726a Use std::mutex instead of OSSpinLock 2013-07-30 15:34:17 +02:00
Allan Odgaard
e0e7059500 Limit use of path::identifier_t 2013-07-30 15:34:17 +02:00
Allan Odgaard
b09d1974ea Improve speed of stopping the document scanner
Closes #1069.
2013-07-29 16:24:29 +02:00
Allan Odgaard
0a64d372a9 Improve lstat error message 2013-07-29 16:07:33 +02:00
Allan Odgaard
24bd109ccc Store tab size with backups 2013-07-29 16:06:15 +02:00
Allan Odgaard
05efb628b4 Setup indent settings at a higher level
We now setup the indent settings when creating untitled documents where we know the folder, so that we can use potential settings scoped to that folder.

Since the document itself no longer sets this as part of regular buffer setup, we also set it when opening a document with a path, and when changing a document’s file type, although the latter is probably temporary.

Closes #305.
2013-07-29 15:50:31 +02:00
Allan Odgaard
a05088f9be Document from content now sets file type and tab settings
Presently we also set file type (and thus indirectly indent settings) when “opening” a document, but I wish to remove that code, so that one can create a document, set all desired settings, and not worry about later code overwriting these settings.
2013-07-29 13:56:15 +02:00
Allan Odgaard
ad44540209 Use document’s indent accessor instead of going via buffer() 2013-07-29 12:43:37 +02:00
Allan Odgaard
2ad22d7662 Add indent accessor to document_t 2013-07-29 10:11:51 +02:00
Allan Odgaard
98585e166e Use byte range for replacement API 2013-07-27 16:30:02 +02:00
Allan Odgaard
db070efed8 Replace after a folder search now use the decoded content
This wasn’t a problem before, as we didn’t decode the content prior to doing a folder search.
2013-07-27 16:28:44 +02:00
Allan Odgaard
8094d61ec4 Only open documents that are already open (during save)
The “find in folder” will create documents, set their content, and potentially save them.

If a document is not open, it should save it without going through the content examination for file type and similar, which is part of opening a non-open document.
2013-07-27 12:26:49 +02:00
Allan Odgaard
7ed6199df1 Print error if scandir/lstat fails 2013-07-26 16:26:20 +02:00
Jasmin Lapalme
b9a06b3e0a Support UTF-16/32 and user fallback encoding for folder search
The fallback encoding is taken from .tm_properties (attr.unknown-encoding).
2013-07-26 13:53:57 +02:00
Allan Odgaard
491fc8a3e3 Add missing semi-colons after assertion 2013-07-21 13:25:28 +02:00
Allan Odgaard
2c307cabce Allow setting a tab as “sticky”
Presently this can only be done by right-clicking the tab and selecting the “Sticky” option — if a tab is sticky then it will not be closed when executing any of the batch close actions (Close All Tabs, Close Other Tabs, Close Tabs to the Right, and holding option down while opening a file via file browser or file chooser).

Closes #1038.
2013-07-21 13:25:28 +02:00
Allan Odgaard
1b61c9c688 Fix “unused variable” compiler warning 2013-07-21 13:25:27 +02:00
Allan Odgaard
d22f7163c5 Ensure tab size read from .tm_properties is larger than zero
Closes #1028.
2013-06-21 01:43:42 +07:00
Allan Odgaard
6ee93431bc Avoid passing -1 (as fd) to kevent() and close()
Observing paths will normally fail when opening files that only privileged users can read.
2013-06-15 16:05:48 +07:00
Allan Odgaard
e0523bb926 Improve encapsulation 2013-05-16 21:36:49 +07:00
Allan Odgaard
b6fce5fe30 Check if command result is valid UTF-8
This was previously implicit by using oak::command_t
2013-05-16 21:36:43 +07:00
Allan Odgaard
7dbb02652f Use io::spawn instead of oak::command_t for /usr/bin/diff3 2013-05-16 21:29:35 +07:00
Allan Odgaard
a366a5f9fe Move grammar changed callback from document → buffer 2013-05-15 15:45:36 +07:00
Allan Odgaard
58dc0b0491 Remove path::walker_t
The intent of this class was to allow ad-hoc recursive/lazy walking of a directory structure and having links only visited once.

It was however only used once, and for that task, path::entries() is sufficient.
2013-05-15 15:45:36 +07:00
Allan Odgaard
6e4926177e Provide symmetric content/set_content for document_t 2013-05-15 15:45:36 +07:00
Allan Odgaard
f5c63828ee Remove path attributes from document_t 2013-05-12 23:04:57 +07:00
Allan Odgaard
e5cca3de18 Remove ‘document_settings’ API 2013-05-12 11:09:18 +07:00
Allan Odgaard
4a32881c11 Remove legacy variable functions 2013-05-12 11:09:17 +07:00
Allan Odgaard
a6cf964e9f Remove callback support from document::run 2013-05-12 11:09:16 +07:00
Allan Odgaard
ccf2414768 Add pwd argument to command runner
Previously this was only possible to change by setting PWD in the passed-in environment.
2013-05-12 11:09:15 +07:00
Allan Odgaard
7f4649ba32 Factor out deprecated variable collecting 2013-05-12 11:09:15 +07:00
Allan Odgaard
88ae04572c Handle “did-save” bundle item callback in OakTextView
While it’s easier to execute bundle items from a text view, it doesn’t work when saving documents that are not in the current text view.

This is an intermediate refactoring step — handling should (likely) end up in the DocumentSaveHelper class, but we need to improve dealing with command execution first, and by having the callback piggyback on the normal performBundleItem: method, we (temporarily) limit the code which use the command execution API, making refactoring easier.
2013-05-09 15:16:33 +07:00
Allan Odgaard
5fd188531a Change naming of functions for obtaining variables
These are now all prefixed with what they are obtaining variables for (scope, document, bundle, …) which makes it easier to analyze/refactor the code.

Also change document_t’s settings function to document_settings.
2013-05-09 15:16:32 +07:00
Allan Odgaard
ba2130f0c8 Don’t change signal mask in library code
This belongs in main(), where it is already being set.

It might however be necessary to set it when running tests, although none of the tests seems to fail w/o this.
2013-03-21 14:39:35 +01:00
Allan Odgaard
13edc6d131 Use O_CLOEXEC when opening files
This avoids leaking file descriptors into child processes, which would otherwise happen if another thread forks while the file descriptor is open.
2013-03-10 16:07:10 +01:00
Allan Odgaard
c26a61a749 Remove “grammar changed” callback
This would cause a crash if grammar changed on disk for a document which was closed but not disposed.
2013-02-18 15:38:26 +01:00
Allan Odgaard
f980573d8b Ensure document is open during save
Saving is done asynchronously so the document might be closed while being saved. This in itself is not an issue, but the “post save” function will assume it has an open document for “marking as pristine” and executing potential “document did-save” callbacks on.
2013-02-11 14:21:20 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
540bf5daf1 Remove SCM variables from document_t 2013-02-02 11:14:35 +01:00
Allan Odgaard
57f4589dbb Broadcast “is on disk” after first save 2013-02-02 10:32:53 +01:00
Allan Odgaard
61b01c89f8 Use scm variables API 2013-01-20 12:49:33 +01:00
Allan Odgaard
e6a4254e61 Allow excluding untitled documents from document::scanner_t
The problem with this feature is that it includes all untitled documents including e.g. the current bundle item being edited. For things like ⌘T we only want to show untitled documents from the current window.
2013-01-18 05:46:27 +01:00