Commit Graph

509 Commits

Author SHA1 Message Date
Francesco Abbate a1bba5e628 Use PLATFORM to detect macOS for key bindings 2021-09-29 12:09:38 +02:00
Francesco Abbate fcc196684c Use new dmon version win watch_add/rm
Include changes in dmon not yet merged into master.
2021-09-29 12:09:38 +02:00
Francesco Abbate 41fcb799bc Fix files limited project with dir monintoring
Changed approach to files limited project. Now we keep into the
top-level dir a list of subdirectories to be shown. When in file
limited mode we will not scan subdirectories unless they are in
the list of shown subdirectories.

With the new mechanism the function get_subdirectory_files always
recurse into subdirectories by default but is able to figure out
to stop recursing into subdirectories for files limited project.

The new mechanism is more robust of the previous one. Now the
rescan of subdirectories is compatible with files limited project.
2021-07-25 21:03:27 +02:00
Francesco Abbate d4943680af Fix a new things about project rescan
Add a flag core.redraw to force redraw when rescan is done.

Inhibit recursion when files_limit is reached.

Still doesn't work correctly for files limited directories.
2021-07-25 21:02:18 +02:00
Francesco Abbate b49422ab02 Smarter algorithm to patch files list
New algorithm use the fact that files list are always
sorted to optimize the table's insertions and removals.
2021-07-25 21:01:38 +02:00
Francesco Abbate 1ecb016453 Fix error in rescan list replace 2021-07-24 21:55:39 +02:00
Francesco Abbate 17e1ddeb58 Ensure all project files are correctly filtered 2021-07-24 21:54:24 +02:00
Francesco Abbate 7098043e6e Fix a few things about dmon
Ensure that we call coroutine.yield when scanning recursively.

Do not use a weak-key based on project dir when adding the job for rescan.
Since "dir" was not unique many threads were missing.

Ensure we do not block waiting for events if there are pending rescan.
2021-07-23 23:04:57 +02:00
Francesco Abbate fe5e1dc57c Ensure directory is rescanned after the first read 2021-07-23 21:23:37 +02:00
Francesco Abbate 1277399bbb Implement project files rescan on dir changes
In theory the dmon based directory monitoring is enough to ensure that
the list of project files is always correct. In reality some events
may be missing and the project files list may get disaligned with the
real list of files.

To avoid the problem we add an additional rescan to be done later in a
thread on any project subdirectory affected by an event of directory of
file change.

In the rescan found the same files already present the thread terminates.
If a difference is found the files list is modified and a new rescan is
scheduled.
2021-07-23 19:36:31 +02:00
Francesco Abbate 31479a4ad7 Show max files warning message for initial project
If the max number of files limit is achieved when the application
is starting the StatusView is not yet configured so we cannot
show the warning.

We show the warning in the function scanning the directory only if
the StatusView is up. On the other side, when the application starts
it will check if the initial project dir hit the max files limit and
show the warning if needed.
2021-07-19 10:47:31 +02:00
Francesco Abbate 8e7d3c0f66 Fix several problem with directory update
When scanning a subdirectory on-demand ensure files aready present
are not added twice. Files or directory can be already present due
to dir monitoring create message.

Fix check for ignore files when adding a file to respond to a dir monitor
event to use each part of the file's path.

Fix C function to compare files for treeview placement.
2021-07-15 18:49:18 +02:00
Francesco Abbate d3c7a43a60 Fix bug with expanding directory when file limited
Introduce a new field in items generated by TreeView:each_item()
to point "dir" to the toplevel directory entry.

In this was we can simplify the code and know if the toplevel
directory is files limited.
2021-07-15 12:17:18 +02:00
Francesco Abbate 3994c3ac42 Treat watch dir errors and fix various things
Verity if dmon_watch returns an error.

Add a check if an added file for which we received a create event is
ignored based on the user's config.

Add some explanatory comments in the code.
2021-07-15 09:56:49 +02:00
Francesco Abbate 3e6b9fedfe Remove the treeview check for modified files
In the treeview the implementation was checking the files list
to detect if it changed because of a project scan. Since we removed
the project scan we no longer need the check.

Removed the TreeView's self.last table that stores previous files
object by top-level directories.
2021-07-14 23:15:05 +02:00
Francesco Abbate fb1f4af7d5 Remove the project scan thread
Since the directory monitoring is now basically working we remove the
project scan thread periodically scanning the project directory.

Each project's directory is scanned only once at the beginning when
calling the function `core.add_project_directory` and is updated
incrementally when directory change events are treated.

The config variable `project_scan_rate` is removed as well as the
function `core.reschedule_project_scan`.
2021-07-14 23:03:52 +02:00
Francesco Abbate 2bc068d0b7 WIP: implement adding of files in project's tree
When a dir monitor create event is received the file is added in the
project's files tree.
2021-07-13 23:08:12 +02:00
Francesco Abbate 79b65014a5 WIP: add correct binary search for removed file
Use a C function to compare nested files in project tree to enable
binary search of a file across the project files tree.
2021-07-13 22:23:52 +02:00
Francesco Abbate b2affddf32 WIP: advance implementation bot not yet complete
Now we request a watch on the directory and we manage sending
and receiving directory change events.

The mechanism to update on the fly the directory scan is not complete.
The code to remove a file is there but we need to implement the code
to add a new file.
2021-07-13 17:40:26 +02:00
Adam e1ae94a01b
Merge pull request #318 from lite-xl/MacOSClose
Created an extra command, to implement appropriate cmd+w behaviour on Mac.
2021-07-09 14:30:48 -04:00
lqdev e5b2a7cbe8 reset blink timer when a new cursor is created 2021-07-01 14:50:28 +02:00
Adam 9126b5e64d
Merge pull request #313 from jgmdev/add-system-rmdir
Added `system.rmdir(path)`, and `common.rm(path, recursive)`
2021-06-29 17:44:58 -04:00
jgmdev 4188269cef Added system.rmdir(path)
It is reported that the built-in lua function os.remove(path) does
not removes empty directories on windows. To fix this a system.rmdir
function is introduced that calls a native win32 function.

Also common.rm(path, recursively) was added which wraps system.rmdir()
to easily delete an entire folder with all its contents.
2021-06-28 11:07:27 -04:00
Adam Harrison c2c59e9c99 Fixed XDG issue. 2021-06-28 10:44:40 -04:00
Adam Harrison f899848631 Added in checks so that the entire thing isn't consumed. 2021-06-27 13:27:20 -04:00
Adam Harrison fd3f25608f Created an extra command, to implement appropriat cmd+w behaviour on mac. 2021-06-27 13:18:54 -04:00
Adam Harrison cc568e65fc Changed over ctrl+w keybinding over to cmd+w, as per #311. 2021-06-24 18:00:50 -04:00
Adam 83a604dfb7
Merge pull request #296 from lite-xl/font-copy-api
Add a C API copy method for font_desc objects
2021-06-24 12:47:16 -04:00
Adam Harrison f9edca712d Added in lineguide to core. 2021-06-21 23:21:07 +02:00
Francesco Abbate 1cf0f2009c Add a C API copy method for font_desc objects
Add a renderer.font's method "copy" to clone the font object
by specifying an optional new size. In the size is not given
the size of the original object is used.

Should fulfill the request from issue #288.
2021-06-21 11:18:52 +02:00
Adam Harrison 8b2fb67b9b Fixed regex replace. 2021-06-20 22:24:20 -04:00
Adam Harrison 46e939a3e6 Fixed a minor bug. 2021-06-20 21:34:42 -04:00
Adam Harrison 305921299f Added in tooltips, the ability to swap between different find modes with a keybind. 2021-06-20 21:22:37 -04:00
Adam 2486f253eb
Abstracted out draw caret, so that the line guide can draw under it. (#287)
* Abstracted out draw caret, so that the line guide can draw under it.

* Moved caret drawing out to draw_overlay.
2021-06-20 22:16:35 +02:00
jgmdev 1a51dad23c Added Doc:on_close() for plugins 2021-06-20 00:13:07 -04:00
Adam Harrison bd02095a13 Fixed minor bugs; swap no longer returns from get. 2021-06-18 23:58:55 -04:00
Adam Harrison 704e04396f Rebased, and added the ability for ctrl to just create new cursors. 2021-06-18 17:33:55 -04:00
Adam Harrison 292c98935c Fixed recursion error. 2021-06-18 17:33:55 -04:00
Adam Harrison 3541ab4aa1 Removed unecessary check. 2021-06-18 17:33:55 -04:00
Adam Harrison 0210264552 Made get_selections a bit more flexible. 2021-06-18 17:33:55 -04:00
Adam Harrison b5cbe3a2fb Added in the ability to iterate through cursors backwards. 2021-06-18 17:33:55 -04:00
Adam Harrison dfc57bd884 Used routine to add cursors in order correctly. 2021-06-18 17:33:55 -04:00
Adam Harrison 6915d86d59 Introduced the constraint that all cursors must be in order. 2021-06-18 17:33:55 -04:00
Adam Harrison b065b52067 Ensured that textual inputs sort cursors so that we don't get *real* weird behaviour. 2021-06-18 17:33:55 -04:00
Adam Harrison 0f229b039d Fixed merging. Fixed selection undo stack. 2021-06-18 17:33:55 -04:00
Adam Harrison c494d52caf Used an inappropriate function in a selection loop. 2021-06-18 17:33:55 -04:00
Adam Harrison d3b3f26316 Added in cursor merging behaviour. 2021-06-18 17:33:55 -04:00
Adam Harrison c6f7e473f0 That's what I get for not testing after a 'simple' refactor. 2021-06-18 17:33:55 -04:00
Adam Harrison 858f7a2a50 Added in missing boolean. 2021-06-18 17:33:55 -04:00
Adam Harrison 75658b4f3f Removed unecessary elses. 2021-06-18 17:33:55 -04:00