Commit Graph

205 Commits

Author SHA1 Message Date
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
Adam Harrison 152fd6c66c Fixed doc, and fixed plugin load. 2021-07-20 15:09:14 -04:00
Adam Harrison 0777a6f0b8 Merged dev to master. 2021-07-20 14:39:50 -04: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 e1530c0951 Remove duplicate normalize_path function
Use the function defined in the "common" module.

Move the check for not-nil filename from common.normalize_path
to core.open_doc. In this latter the filename can be nil if a
new unnamed document is created.
2021-07-15 18:01:17 -04:00
Adam Harrison e539310e6d Namespace plugin-specific configuration settings. 2021-07-15 17:58:14 -04: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 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
jgmdev 1a51dad23c Added Doc:on_close() for plugins 2021-06-20 00:13:07 -04:00
Francesco Abbate 1ad4289e76 Do not try to update topdir folder in treeview
If the directory expanded is a project's top directory
do not attempt to update its content.

Fix again issue #275
2021-06-17 19:07:32 +02:00
Francesco 98164f6d4f
Integrate mkdirp function in common module (#265)
Move the function mkdirp into common to be generally available.

Use the new common.mkdirp from create_user_directory() from
core/init.lua replacing previous parent directory creation code
within the function.

The previous mkdirp function did not work on Windows where
absolute paths starts with a drive letter. The code from
create_user_directory() did not have this problem but was wrong
in the way it was creating the nested directories.

The new implementation in common.mkdirp fix both problems.
2021-06-13 19:50:42 +02:00
Francesco Abbate 752ecd5ece Group mouse move events from C API function
Groups together consecutive mouse move events like done in core.step()
lua function but on the C side.

It does not introduce any meaningful speedup but it theory is more efficient and
simplifies the Lua code.

The simplification of the Lua code alone is enough to justify this change?
2021-06-11 15:00:18 +02:00
Francesco b046afccf9
Scale fonts context menu (#246)
* Retrieve scale plugin from lite-plugins

* New implementation of scale plugin and font C API

Introduce two new C API functions, renderer.font.get_size and set_size
respectively to get the font size and to set the size to a new value.

Using these functions we don't need to know the name of the font but
we can just change their size.

Adapt the scale plugin to use the new C API function with minor adaptations
in the logic.

Use smaller step to scale fonts.

Rename font_desc_free function, previous name was misleading as only the cached
resources are freed.

* Add contextmenu plugin from takase

From https://github.com/takase1121/lite-contextmenu

Adapted to show font scaling commands and find/replace commands.

i#	testing.lua

* Fix the cursor flickering with contextmenu

To avoid flickering of the cursor when using the context menu
we add a new function `core.request_cursor` that just take note
of the cursor requested.

The cursor will be actually changed only in root_view:draw() method
only when all the drawing operations are done. This means the cursor
will be changed only once per frame and only the most recent cursor
change request will take effect.

* Remove unneeded scale plugin return functions
2021-06-03 22:49:37 +02:00
Adam 248d70a8ca
Add PCRE to support regular expressions
Use regular expressions instead of Lua patterns for find and replace editor commands.

Syntax files can now use regex or Lua patterns as before keeping backward compatibility for plugins.
2021-06-02 21:27:00 +02:00
lqdev ea5e9b0ce5 fixed broken Doc:save monkeypatch 2021-06-02 19:11:59 +02:00
Francesco Abbate 4e93eabbac Deprecate core.add_save_hook to override Doc:save
In order to stay simple and closer to the lite's design principles we
deprecate the core.add_save_hook function and the related mechanism.
Instead we now directly override the Doc:save() method.

The method is already overrided from core.init to add the automatic
reloading of style when user's module is saved.

The cleanup is related to the discussion in issue #229.
2021-05-31 09:41:37 +02:00
Francesco Abbate 6d044224c1 Starts maximized only if it was in previous session 2021-05-28 16:35:25 +02:00
redtide 818a7abb0a Avoid to restore window size when maximized (#226) 2021-05-28 08:51:39 +02:00
Francesco Abbate ad7d17caca Use FiraSans regular for UI 2021-05-27 13:49:33 +02:00
Janis-Leuenberger 1394c53dbc
Improve user feedback for big directories (#223) 2021-05-27 08:28:58 +02:00
Francesco Abbate 10fde6e264 Implement lazy loading of directories
When the number of files in a project directory is above the max
limit switch back to a mechanism to read directory content only
when the corresponding folder is expanded in the treeview.

When the command core:find-file is invoked the command core:open-file
is executed instead because the complete list of the project's
files is not available.

When a project search is done we search through all the files within
the project dir without indexing them.

Address issues #217 #203 #183.
2021-05-26 14:22:10 +02:00
Francesco Abbate 739763675e Check the real absolute path of user module
Close issue #212
2021-05-22 23:32:45 +02:00
Francesco Abbate 217360ed31 Switch to FiraSans and JetBrainsMono fonts 2021-05-22 15:09:54 +02:00
Francesco Abbate 5cef643e02 Introduce new plugin versioning tag mod-version
New plugins should use the version tag:

-- mod-version: 1

The old version tag "-- lite-xl 1.16" will be considerer equivalent
to mod-version 1.
2021-05-05 22:38:29 +02:00
Adam 135dfa6f03
Add a more explicit message in log and config.max_project_files
* Added a line to avoid people going down the rabbit hole that I did.

* Further explanatory text.
2021-05-05 16:00:17 +02:00
Francesco Abbate 1a05e00fdd Fix detection of user file module
Close #54
2021-05-01 19:27:29 +02:00
Francesco Abbate e6d88909a8 Fix log message about project dir 2021-05-01 19:27:29 +02:00
Francesco Abbate 5766329313 Fix filename problem
Close #163
2021-05-01 19:27:29 +02:00
lqdev c859498d68 check version in init.lua within directory plugins 2021-04-25 19:14:36 +02:00
lqdev 34e94bb8aa fixed versioning, again 2021-04-25 12:35:00 +02:00
lqdev 5e8e2f54b5 directories should not be loaded 2021-04-25 11:45:08 +02:00
Francesco Abbate 8bcace1d59 Merge remote-tracking branch 'origin/border-less-window' 2021-04-21 08:42:57 +02:00
Francesco Abbate 032018ec48 More aggressive wait_event timeout when window has focus
Adopt a time based logic for cursor blinking and wait for event

when idle with a timeout equal to blink remaining time.
2021-04-17 14:57:28 -07:00
Francesco Abbate f7375924ab Make non-borderless mode work 2021-04-12 19:05:30 +02:00
Francesco Abbate 4de97d51fb Avoid always calling system.get_window_mode 2021-04-12 13:31:32 +02:00
Francesco Abbate 8ad87d77da Add correct hit-test information and menu icon 2021-04-11 15:08:25 +02:00
Francesco Abbate 7531a0ddc8 Preliminary implementation of border-less mode
Not yet functional but most ingredients are there
2021-04-10 19:35:57 +02:00
Francesco Abbate f250adcda1 Implement multi-lines for NagView
Related to issue #147
2021-04-07 23:46:45 +02:00
Francesco Abbate 119f406d3c Add NagView message for refused plugins 2021-04-07 09:42:19 +02:00
Francesco Abbate d7cc1f9f9d Add plugin verification by version tag 2021-04-06 17:50:46 +02:00
Takase 63b9cf223e
NagView improvements (#136)
Implement keyboard commands for the NagView.
2021-04-04 16:11:47 +02:00
Francesco Abbate 3b040aabc7 Implement unicode character replacements
Useful to draw whitespaces with alternate characters and colors
without slowing down the text rendering.

A new API is implemented. A renderer.replacements object can be created
to list the replacements.

In turns the function renderer.draw_text and draw_text_subpixel now accept
two optional arguments for replacements.
2021-04-01 18:05:59 +02:00
Francesco Abbate 7f50df6a2f Ensure plugin within a directory are loaded
Close #118
2021-03-20 16:34:00 +01:00
Takase c0ad86de8c
integrate NagView 2021-03-13 12:57:52 +01:00
Francesco Abbate 23a053e1ee Ensure error and stack trace are written to stdout
To address https://github.com/franko/lite-xl/issues/87
2021-03-07 09:48:44 +01:00
Francesco Abbate 09332fe242 Fix problem with fatal error message
Previous implementation was broken.

Ensure the error file is always written and write its location in the error message
2021-03-05 23:46:41 +01:00
Francesco Abbate a4bc8986ff Implement fatal error message box
Used when lite-xl fails at startup
2021-03-05 10:33:50 +01:00
Francesco Abbate 3506ff47fc Fix problem with plugin loading
Introduced with PR https://github.com/franko/lite-xl/pull/73
2021-03-05 07:22:56 +01:00
liquidev 2e1a6ad5d1
Fix #30 – user plugins take priority over built-in plugins (#73)
user plugins should take priority over stock plugins
2021-03-03 12:20:22 +01:00
Francesco Abbate 8883685eea Fix font size in initial user's config 2021-03-01 09:48:12 +01:00
Francesco Abbate a35ef764a0 Show Lite XL instead of lite in window's title 2021-02-28 18:55:05 +01:00
Francesco Abbate 0dc18de6bc Add information about icon_big_font in initial user's configuration 2021-02-27 12:13:51 +01:00
Francesco Abbate 4f2e38d41f Make code and ui font smaller at 12 2021-02-19 16:23:19 +01:00
Francesco Abbate 688dc1a7b8 Do not log every plugin load
Since we now load the user's module before the plugins\nwe avoid to log a line for each loaded plugin to not hide\nan eventual error in the user module
2021-02-19 16:12:56 +01:00
Francesco Abbate 68d9794926 Adjust default code font size
The previous value looks too big in hidpi screens
2021-02-19 16:10:57 +01:00
Francesco Abbate 76b463bd11 Create empty fonts directory in USERDIR 2021-02-19 16:10:02 +01:00
Francesco Abbate 6353fde609 Move user module loading before plugins
Otherwise the configuration to disable a plugin does not take effect.
2021-02-19 10:08:03 +01:00
Francesco Abbate 114f6b2481 Do not print error on standard output
Delayed error when passing invalid directory argument.
2021-02-19 09:29:46 +01:00
Francesco Abbate ba68d6db24 Improve error handling for directory arguments 2021-02-19 00:15:55 +01:00
Francesco Abbate a2c4fdf649 Normalize global PATH from core.init 2021-02-18 09:02:57 +01:00
Francesco Abbate de1afb3391 Add full filename path in window's title
Optimal implementation to limite computations in core.step.
2021-02-18 00:26:19 +01:00
Francesco Abbate 59fbf9cfc0 Merge branch 'master' into dev 2021-02-17 23:57:02 +01:00
Francesco Abbate 9b27180267 Use doc on_save hooks to reload user module 2021-02-17 20:10:39 +01:00
bud 3693556958 FIX: get DocView in init instead of step, remove option for window title format' 2021-02-16 19:12:56 +01:00
bud dd30725d84 FIX: before setting full path to window title, make sure activeView is DocView 2021-02-15 22:38:29 +01:00
bud 436446dd9a ADD: in core.step() show full path if view is a document and config.full_path_in_window_title is true 2021-02-15 21:05:06 +01:00
Francesco Abbate b836c2e1e6 Implement proper layout of toolbar 2021-02-15 00:36:39 +01:00
Francesco Abbate 2765cbd92b Show a dummy toolbar
Does not do anything for the moment
2021-02-12 15:54:11 +01:00
Francesco Abbate f482ea318a Makes resizable attribute explicit in Node:split() 2021-02-11 16:12:21 +01:00
Francesco Abbate a8c810d801 Merge remote-tracking branch 'origin/master' into dev 2021-02-09 18:39:39 +01:00
Francesco Abbate 3d8cf22933 Fix error with previous commit 2021-02-05 15:36:48 +01:00
Francesco Abbate 03818d13fd Fix error when using relative dir argument 2021-02-03 07:39:35 +01:00
B14CK313 65c7f666aa
Fixed path returned by temp_filename not writeable
The path returned by temp_filename was not writeable on UNIX (and possibly other OS). This lead to the gitstatus plugin not working.
The proposed change fixes this by using the USERDIR variable instead of EXEDIR
2021-01-22 02:10:24 +01:00
Francesco Abbate ef5e431a8b New feature to disable plugins from config
Disable trimwhitespace by default
2021-01-13 14:50:24 +01:00
Francesco Abbate fcf763fe9c Fix problem when project directory has a trailing slash 2021-01-10 12:56:15 +01:00
Francesco Abbate 7f9e4e4984 Do not error out when project directory is invalid 2021-01-10 11:50:15 +01:00
Francesco Abbate e548a6adb9 Fix directories management to always keep the project's directory 2021-01-03 12:02:07 +01:00
Francesco Abbate 850fcbf710 Add required normalize_path call 2020-12-31 12:32:41 +01:00
Francesco Abbate 2cdf674b97 Keep memory of window's size and position and restore them on start
Fix also a problem with directory path on windows.
2020-12-31 11:25:12 +01:00
Francesco Abbate c3f5d2c144 Fix problems with project files and project directories
Now treat coherently the case when the project directory is removed from
the project directories.
2020-12-30 14:53:50 +01:00
Francesco Abbate b91a84eb56 Fix project change and quit versus workspace plugin 2020-12-30 14:31:36 +01:00
Francesco Abbate 0e263af3c6 Create common.serialize function 2020-12-30 13:32:25 +01:00
Francesco Abbate ddd56ec615 Add command to remove a directory from the project
In addition directories can be removed with a mouse middle-click in the
tree view pane.
2020-12-28 15:51:16 +01:00
Francesco Abbate c042bfc907 Change project files output to not include a prefix '/' in filename
It make sense to not put the initial '/' in the filename as the name
is relative to the top directory it belongs to.

By removing the the initial '/' in the filename we can re-introduce the
variable

core.project_files

to stay compatible with standard Lite. The project_files variable will
always point to the files table of the first entry of
core.project_directories.
2020-12-28 10:26:27 +01:00
Francesco Abbate df74781da8 Fix project search and status view for new add directory feature 2020-12-27 18:28:21 +01:00
Francesco Abbate e4fa196b33 Finalize add project directory feature 2020-12-27 11:32:52 +01:00
Francesco Abbate 39181a56fd Use relative path for filenames in project directories 2020-12-27 09:47:58 +01:00
Francesco Abbate 5449781353 Minor cleanup to project directory stuff 2020-12-26 23:39:27 +01:00
Francesco Abbate 54518c438d Cosmetic changes to names from previous commit 2020-12-26 23:29:18 +01:00
Francesco Abbate ec730e9520 Test configuration with project_files stored separately for each directory 2020-12-26 21:22:57 +01:00
Francesco Abbate 2f50f21f57 Preliminary version of projects with multiple directories 2020-12-26 16:48:08 +01:00
Francesco Abbate 9e8e8f7543 Remove priority run mechanism 2020-12-26 11:30:20 +01:00
Francesco Abbate 499f085045 Use get_primary_node instead of Rootview:get_primary_view 2020-12-15 12:51:36 +01:00
Francesco Abbate eadbe41064 Add core.on_quit function for plugins
To be used for plugins like workspace from exi/lite-plugins
2020-12-14 13:57:24 +01:00