Commit Graph

1091 Commits

Author SHA1 Message Date
takase1121 c255e53d37 feat(bootstrap): return error string from C searcher 2023-08-07 14:50:59 +01:00
Adam aa2ac0a4ce Added in double-clicking on emptyview and tab bar. (#1478)
* Added in double-clicking on emptyview and tab bar.

* Fixed issue with split tabs.

* Early exit if no overlapping node.

* Changed category of command to tabbar.

* Additional cleanup.

* Changed for whether we should show tabs.

* Fixed erroneous hover.
2023-08-07 14:50:59 +01:00
jgmdev ff4364b0ff StatusView compat fix with older Lua runtimes 2023-08-07 14:50:59 +01:00
Guldoman 532d3a6572 Merge carets after `doc:move-to-{previous,next}-char` (#1462) 2023-08-07 14:50:58 +01:00
sammyette 2978037f51 feat: add statusview item to show selections (#1445) 2023-08-07 14:50:58 +01:00
vqn 7aa1217878 #1393 followup (#1463)
* Fix incorrect check in doc:raw_remove

Restore caret position on command doc:cut

* merge cursors and fix new line in clipboard

* add new line to the last copied line
2023-08-07 14:50:58 +01:00
Jan 662fde364b Add View dragging (#1402) 2023-08-07 14:50:58 +01:00
Adam 7ca0ec18ca Added in support for foreground and background events. (#1395) 2023-08-07 14:50:58 +01:00
vqn 46ea86e28c fix cursors positions when deleting multiple selections (#1393)
* correctly handle overlapping selections merge cursors in Doc:raw_remove
2023-08-07 14:50:58 +01:00
Adam ee80b451c6 Added in explicit touchscreen keyboard support. (#1389) 2023-08-07 14:50:58 +01:00
Guldoman 1c8c569fae Allow `tokenizer` to pause and resume in the middle of a line (#1444) 2023-08-07 14:50:58 +01:00
Adam 1becf35508 Disable `trimwhitespace` and `drawwhitespace` via their configs (#1446)
Instead of completely disabling them, we now use their internal toggle.

Also moved `drawwhitespace` commands inside the plugin.

---

* Fixed bug where commands would show even when plugin was disbled. Also removed antiquated way of disabling.

* Fixed typos.

* Also moved trimwhitespace out of config, if it already has a default enabled value of false.

* Changed documentation.

* Clarified comments.
2023-08-07 14:50:58 +01:00
Guldoman b005454652 Limit `core.threads` without a timeout to run 30 times per second 2023-08-07 14:50:58 +01:00
Adam Harrison 73ff025552 Made things clearer, as per jgm's suggestion. 2023-08-07 14:50:58 +01:00
Adam 7f0651155d Made coroutines make more sense, and fixed a bug. (#1381)
* Made coroutines make more sense, and fixed a bug.

* Fixed typo.

* Additional checking for off-cycles.

* Fixed issue with calling step too much.

* If we have no redraw, set next step time for next frame.

* Added in `now` variables to reduce calls.
2023-08-07 14:50:58 +01:00
Guldoman 146dca9188 Don't calculate widths per-uft8-char when not needed (#1409) 2023-08-07 14:50:58 +01:00
Guldoman e1f92683bc Use correct view for scrolling to `find-replace:repeat-find` results (#1400) 2023-08-07 14:50:58 +01:00
Adam 83c27cf9f4 Added in ability to specify prefix via env variable. (#1388) 2023-08-07 14:50:58 +01:00
vqn 9b4a86f763 fix incorrect x_offset if opened docs have different tab sizes (#1383) 2023-08-07 14:50:58 +01:00
Guldoman 7e0ddf2817 Make tab scrolling more flexible (#1384)
* Add `Object:{is_class_of,is_extended_by}` to check inverse relationships

* Make tab scrolling more flexible

This adds tab scrolling commands and connects them to mouse scroll
events.
This way scrolling behavior can be customized more easily.

For example an alternative behavior could be:
```lua
keymap.add({
  ["wheelup"] = "root:switch-to-hovered-previous-tab",
  ["wheeldown"] = "root:switch-to-hovered-next-tab"
})
```
2023-08-07 14:50:58 +01:00
jgmdev 51ab72f715 Correct the inverted tabs scrolling 2023-08-07 14:50:58 +01:00
Eric Gaudet 911eb325cc Make mouse scrollwheel hovering tabs scroll the tab bar (#1314) 2023-08-07 14:50:58 +01:00
Guldoman d9925b7d44 Allow groups to be used in end delimiter patterns in tokenizer (#1317)
* Allow empty groups as first match in tokenizer
* Avoid pushing tokens with empty strings
* Allow groups to be used in end delimiter in tokenizer
* Use the first entry of the type table for the middle part of a subsyntax
This applies to delimited matches with a table for `type` and without a 
`syntax` field.
* Match only once if using `at_start` in tokenizer `find_text`
* Check if match is escaped in the "close" case too
Also allow continuing matching if the match was escaped.
2023-08-07 14:50:58 +01:00
Guldoman be5d23557d Improve `DocView:get_visible_line_range` precision (#1382) 2023-08-07 14:50:58 +01:00
Jefferson González 84039331a5 NagView: properly rescale on scale change (#1379)
* drop font option since style.font is always used
2023-08-07 14:50:58 +01:00
Jefferson González 1c2571bad7 Restore in-selection replace as discussed in #1331 (#1368) 2023-08-07 14:50:58 +01:00
Jefferson González d68583b688 Improved plugins config table handling (#1356)
* Warns user if trying to disable a plugin that is already
  enabled when doing `config.plugins.plugin_name = false` and also
  prevents replacing the current plugin config table with the false
  value to mitigate runtime issues.
* Uses a merge strategy by default when assigning a table to a plugin
  config to prevent a user from removing a plugin default config values
  as experienced and explained on this issue lite-xl-plugins#158
* This change is basically backwards compatible, but will require a
  change on the settings ui plugin on how it checks for already
  enabled plugins, since rawget will no longer be a working hack
  or workaround for this.
* As suggested by Adam dropped loaded key and switched to package.loaded
2023-08-07 14:50:58 +01:00
Guldoman 57cd4e2949 Make mod-version follow semver (#1036)
* Make mod-version follow semver
  Now plugins can optionally specify the minor and patch version they 
support.
  If no minor or patch version is specified, it's considered 0.
  Plugins are only loaded if they have the same major version and a 
  smaller or equal minor+patch version.
* Add modversion to logging and plugin mismatch nagview

---------

Co-authored-by: Jefferson González <jgmdev@gmail.com>
2023-08-07 14:50:58 +01:00
Himura Kazuto aef400bc90 Replace globally when replacing from selection (#1331) 2023-08-07 14:50:58 +01:00
Adam f74716b436 Getting rid of annoying forward slash on windows. (#1345) 2023-08-07 14:50:58 +01:00
Adam 4682092b8d Added in Config Postload (#1336)
* Added in an `onload` variable to configs which is called by the plugin loader.

* Used appropriate parameter.

* Fixed tabbing.
2023-08-07 14:50:43 +01:00
Guldoman 12bae1ec95 Avoid drawing hidden text in `DocView:draw_line_text` (#1298)
* Stop drawing text past the `DocView` edge in `DocView:draw_line_text`

* Don't add draw commands if they fall outside the latest clip

The check was previously done with the window rect, so this will reduce 
a bit more the number of commands sent.
2023-08-07 14:50:43 +01:00
xwii e4c5fceaf9 Use `table.move` to implement `common.splice` (#1324)
* Use `table.move` to implement `common.splice`

* Disallow negative `remove` in `common.splice`
2023-08-07 14:50:43 +01:00
sammyette 1504ad7f4c
fix: center title and version in emptyview (#1311)
* fix: divide by amount of lines
2023-01-06 15:27:05 -04:00
Guldoman 72c0ad768e
Make `dirwatch` sorting compatible with what `file_bisect` expects (#1300)
The result of `a.filename < b.filename` is sometimes different from 
`system.path_compare(a.filename, a.type, b.filename, b.type)` which 
causes issues to `file_bisect`, as it expects the sorting to be done 
with `system.path_compare`.
2023-01-05 15:59:15 -05:00
Dave 4e272c33de Minor typos in init text 2022-12-30 13:32:20 +01:00
Guldoman 74349f8e56
Fix horizontal scroll with touchpad on MacOS 2022-12-28 17:26:57 +01:00
Jefferson González 870d685b59
contextmenu: adjust y positioning if less than zero (#1268)
* use clamp for both x and y coords
2022-12-28 02:51:24 -04:00
xwii 271a804986
Fix popping subsyntaxes that end consecutively (#1246) 2022-12-27 20:24:52 -04:00
Simon Krauter 8603644726
Fix two typos in data/init.lua (#1272) 2022-12-27 19:56:30 -04:00
Martin Ashby d4989d98bd
Add example settings to _overwrite_ an existing key binding (#1270) 2022-12-27 18:40:22 -05:00
sammyette 1810db0705
fix: move tab scroll buttons to remove spacing before 1st tab (#1231)
* fix: move tab scroll buttons to remove spacing before 1st tab
* fix: always show tab scroll buttons
* fix: cleanup code, get scroll button rect for correct button
* fix: expand to full size for tabs if scroll buttons arent visible
* fix: define n as visible tabs number
2022-12-20 22:06:53 -04:00
Guldoman c42f01ed1f
Improve IME location updates (#1170)
* Avoid updating IME input rect if it hasn't changed
* Update the IME input rect even when the composition didn't change
* Apply IME input blocking workaround to non-Linux only
2022-12-20 20:11:13 -04:00
Jefferson González 3c64c32379
core: ported regex.gsub to faster native version (#1233)
* added regex.gmatch iterator and other fixes
* fixed issues reported by Guldoman
* push strings with fixed len just in case for binary safety
* added limit to regex.gsub and use pushinteger
* added description to regex.gsub limits param
* replaced substitutions regex description for correctness
* ignore negative limits on regex.gsub
2022-12-20 17:46:37 -04:00
Cyriaque Skrapits 5b5b5fd3e3
contextmenu: make divider less aggressive (#1228)
Following changes are applied:
- use divider color instead of caret;
- add a vertical padding on the divider.
2022-12-20 17:29:53 -04:00
Guldoman 9d48441685
Add `regex.find_offsets`, `regex.find`, improve `regex.match` (#1232)
`regex.match` now behaves like `string.match`.
This required changes in the `tokenizer` and in the `detectindent` 
plugin.
2022-12-11 22:25:42 -04:00
sammyette e13f265fac
feat: alert user via nagview if file cannot be saved (#1230)
* feat: alert user via nagview if file cannot be saved
it will prompt the user to choose whether they
want to save to another location and perform
the save as command
* refactor: change defer draw call to thread
* feat: log error when attempting to save doc
2022-12-11 21:38:58 -04:00
sammy dfa2f93d9c
feat: encode home in statusview file path (#1224) 2022-12-06 06:19:52 -04:00
Guldoman f7ad8753eb
Improve `regex.gsub` performance (#1220) 2022-12-02 19:21:05 -05:00
jgmdev 0373d29f99 statusview: respect right padding of item tooltip
When the tooltip was rendered on the last item of right items the right
padding was not properly getting accounted as part of the tooltip width.

This commit also fixes:

* Passing StatusView to item.get_item() instead of StatusView.item
* Some adjustments to annotations.
2022-11-24 12:34:49 -04:00
Guldoman 51f2a291d3
Make `Scrollbar` follow `force_status` when animations are disabled 2022-11-15 21:08:33 +01:00
Guldoman 519b91c2dd
Pass the currently selected item to `CommandView` validation (#1203) 2022-11-15 12:03:13 -04:00
Guldoman c6c485feb0
Use subsyntax info in `doc:toggle-{line,block}-comments` 2022-11-15 16:11:37 +01:00
Guldoman 0a1b8b6bb1
Set initial tokenizer state to a `NULL` byte 2022-11-15 16:01:04 +01:00
Guldoman e147a6cb9b
Add `tokenizer.extract_subsyntaxes` 2022-11-15 16:00:48 +01:00
jgmdev fb43e6f9e6 traceback: some lua versions do not support message as nil 2022-11-07 12:48:09 -04:00
Jefferson González 9c7304f555
highlighter: autostop co-routine when not needed (#881)
* highlighter: autostop co-routine when not needed

* applied @Guldoman suggestions
2022-11-06 03:38:10 +01:00
Jefferson González b8a4f729df
tokenizer: remove the limit of 3 subsyntaxes depth (#1186)
* tokenizer: remove the limit of 3 subsyntaxes depth

Make the state a string of bytes instead of a 32bits integer to be able
to have deeper subsyntax support. Fixes issues with syntax files like
the one for PHP that was already hitting more than 3 subsyntaxes depth.

* remove unnecesary call to set_subsyntax_pattern_idx

* fixed wrong word on comments
2022-11-03 18:56:20 -04:00
Guldoman 03cc5ffcd1
Add `config.keep_newline_whitespace` option (#1184)
This option will avoid removing line content when pressing enter in 
lines with only whitespace.
2022-11-03 12:40:27 -04:00
Guldoman b029f5993e
Don't sort in `Doc:get_selection_idx` with an invalid index 2022-11-02 21:11:41 +01:00
Jefferson González 69bccf6fcf
docview: support gutter click selection, fixes #1116 (#1169)
* docview: support gutter click selection, fixes #1116

* Added missing call to parent on_mouse_pressed

Also fixed call to selections when `shift` is pressed.

* change to arrow instead of hand

Co-authored-by: Adam <adamdharrison@gmail.com>
2022-11-01 19:34:23 -04:00
Guldoman ed226c476e
Add more options to `Scrollbar` (#1174)
* Make `Scrollbar` accept a table for its options

* Add `force_status`, `{expanded,shrinked}_size` options to `Scrollbar`

* Add `Scrollbar:set_forced_status`

* Add `config.force_scrollbar_status` to force `DocView` scrollbars status
2022-11-01 18:38:50 -04:00
Guldoman 0f160e614e
Improvements to multicursor copy/paste (#1123)
* Add `Doc:get_selection_idx`

* Make multicursor paste add a cursor at the end of each paste

* Better manage paste of multicursor whole line copy

* Document `Doc:get_selection_idx`

* Keep track of last added selection in `Doc`

* Make use of `doc.last_selection` in `Doc` commands

* Make `Doc:get_selection` return the `Doc.last_selection` if possible
2022-11-01 18:16:39 -04:00
Guldoman b52fe1605e
Make MacOS `core:restart` shortcut more in line with other platforms 2022-11-01 21:21:50 +01:00
Guldoman c512d01a68
Fix horizontal scroll with shift+scroll on MacOS
It seems like pressing shift+scroll on MacOS automatically makes it 
shift+horizontal scroll.
2022-11-01 21:20:37 +01:00
Guldoman 715411061b
Apply `doc` commands to anything that extends `DocView`
This fixes a regression caused by 
cf29a6a45f.
2022-10-24 04:47:26 +02:00
Jefferson González af6c4bc152
core syntax: strip the path from filename on syntax.get (#1168) 2022-10-22 20:04:54 -04:00
Jefferson González f02b3c46e6
Merge pull request #1167 from jgmdev/PR/new-lines
* plugin drawwhitespace: allow newline substitution
* docview: do not render newline fixes #1164
2022-10-22 19:56:43 -04:00
jgmdev 3da6833249 docview: do not render newline fixes #1164 2022-10-21 13:56:23 -04:00
Adam dd6eee1542
Fixed the common idiom of setting a plugin to true. (#1152) 2022-10-20 18:04:28 -04:00
Takase 437b954595
make the default core.ignore_files more specific (#1160)
* make the default core.ignore_files more specific

instead of blanket ignoring all dotfiles, we define a list of folders
and files to ignore. this makes the overall experience better.

* fix wrong path pattern

* add ignore_files to user init
2022-10-19 22:23:01 -04:00
Adam 1c5936e697 Fixup minor drawing issue. 2022-10-18 16:01:32 -04:00
Guldoman decbac4ac6
Check if scrollbar is no longer hovered on mouse release 2022-10-16 04:43:15 +02:00
Guldoman 6ca56fee1a
Only consider left clicks on the scrollbar 2022-10-16 04:40:03 +02:00
Guldoman 6b754eb628
Refactor scrollbar into its own file (#1124)
* Move scrollbar to its own file
* Don't call `Scrollbar` functions if `View` is not scrollable
* Allow horizontal scrolling in `Scrollbar`
* Add horizontal scrollbar to `View`
* Add `root:horizontal-scroll` command with `shift+wheel` keymap
* Prioritize vertical scrollbar hover
* Don't send mouse movement to vertical scrollbar when dragging horizontal one
* Fix clicking on horizontal scrollbar track
* Implement `start` scrollbar alignment
* Add documentation to `Scrollbar`
* Make `DocView` infinitely scrollable horizontally
* Handle horizontal scroll SDL event
2022-10-15 20:12:15 -04:00
Guldoman 5c2c95765e
Add IME support (#991) 2022-10-15 19:58:51 -04:00
Jefferson González f89088d0ec
dirmonitor: add watch to subdirs on file limit mode (#1155) 2022-10-13 00:37:52 -04:00
Guldoman 334a7da5c9
Use the syntax with the longest match (#919)
This way, for example, a syntax that applies to `docker-compose.yml` 
files will take precedence over one that applies to `*.yml` files.
2022-10-12 18:10:11 -04:00
Jefferson González 0fc793d1ae
Add on_scale_change event to View (#1146)
* core view: emit on_scale_change event
* core titleview: reconfigure hit_test on rescale fixes #1144
2022-10-11 14:44:32 -04:00
Jefferson González 214c9d6287
dirwatch: exit coroutine if project not open anymore to properly gargage collect it (#1142) 2022-10-11 13:22:44 -04:00
Jefferson González a7888e96ea
Add fsevents backend to dirmonitor (#1141)
* dirmonitor: added backend reporting of watch mode

* dirmonitor: added fsevents backend for macos
2022-10-10 20:40:41 -04:00
Takase 3409929a0c
draw lite-xl icon in TitleView (#1143)
the original hamburger menu icon is confusing. It is not a menu
and clicking it doesn't do anything. There is no reason why
we can't draw lite-xl's icon in place of that.
2022-10-10 11:05:30 -04:00
Adam 9e816154ad
Added in an additional ENVVAR for setting USERDIR, and also changed / to PATHSEP. (#1139)
* Added in an additional ENVVAR for setting USERDIR, and also changed / to PATHSEP.

* Forgot a /
2022-10-08 20:48:30 +02:00
jgmdev e2884895ce core start: added missing ';' to package.cpath 2022-09-25 17:13:07 -04:00
Adam 6bb08fc68f
Added in ability to have `init.so` as a require for cpath. (#1126) 2022-09-25 17:08:21 -04:00
Adam 5ada80b9df
Added in native modules suffixes. (#1111)
* Added in native modules with suffixes, giving priority to those with matching architectures and platforms.

* PowerPC isn't x86, and it's x86_64.

* Changed things over to allow compiler to set a tuple, makes more sense from a build perspective.

* Spelling mistake.

* Added in arm target tuples.
2022-09-18 18:27:50 -04:00
jgmdev 4134b30ffd core: remapped core:restart to `ctrl+alt+r`
Commonly `ctrl+shift+r` is used in most editors for find and
replace operations, also the regexreplacepreview.lua plugin makes
a more appropriate use of this binding.
2022-09-16 11:31:05 -04:00
Jefferson González 5a80d3547e
contextmenu: resize on scale changes (#1117) 2022-09-15 00:57:45 -04:00
Guldoman a19cfb4f80
Strictly limit find/replace commands to `core.docview` (#1108)
Without this, find/replace commands applied to the `CommandView` too,
with buggy results.
2022-09-13 22:29:52 -04:00
Aqil Contractor 9b1bfeacac
Added a smoothing and strikethrough option to font loading. (#1087)
* Added a smoothing option to font loading.
* Added a font strikethrough option to font loading.
* Fixed underline applying incorrectly in cases of non-underlined fallback fonts being used.

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2022-08-20 16:15:08 -04:00
Jefferson González f07b62f852
Merge pull request #1100 from Guldoman/PR_fix_path_suggest
Remove dot slash from suggested paths in `common.path_suggest`
2022-08-17 13:59:19 -04:00
Guldoman 4c186b07a3
Be more lenient with appending `PATHSEP` in `common.path_suggest` in Windows
This allows to use the Unix separator without resulting in ugly 
suggestions that added the Windows separator too.

For example:
Before: `data/` -> `data/\core\`
After: `data/` -> `data/core\`
2022-08-17 00:11:19 +02:00
Guldoman e8ca861512
Remove final `PATHSEP` in `common.normalize_volume` 2022-08-16 23:53:03 +02:00
Guldoman a4355c6536
Add `PATHSEP` before listing the directory in `common.path_suggest`
Before, in Windows, listing `.` instead of `.\` resulted in unexpected 
results.
2022-08-16 23:51:12 +02:00
Guldoman 6aa96556c0
Replace `assert` with `core.log_quiet` on command replace
This caused issues when saving the user module with commands defined
inside it, as it resulted in the user-defined commands trying to
overwrite themselves and failing.
2022-08-16 22:18:50 +02:00
Guldoman d944bd85ec
Add predicate memoization to `command.get_all_valid` 2022-08-16 22:13:25 +02:00
Guldoman cf29a6a45f
Allow command predicates to manage parameters passed to the commands
When a command is performed with parameters, those are now passed to the
predicate.
The predicate can then return, after the validity boolean, any other
value that will then be passed to the actual command.
If the predicate only returns the validity boolean, the original
parameters are passed through to the actual command.

This allows predicates to manipulate the received parameters, and allows
them to pass the result of an expensive computation to the actual
command, which won't have to recalculate it.

String and table predicates will now also return `core.active_view`.
2022-08-16 22:13:16 +02:00
Guldoman 4b4c54ba65
Remove dot slash from suggested paths in `common.path_suggest`
When no `root` is specified and the initial `path` is empty, the initial 
`path` becomes `.`.
This results in returned files/dirs that are prepended with `./`.

Now, in that case, `./` is removed.
2022-08-16 08:08:04 +02:00
Adam 6ccc5f6dde
Steps to generalize toolbar and treeview. (#1088) 2022-08-09 14:53:30 -04:00
Guldoman 4db71836af
Clear default Lua require path (#1085)
This is mainly done to avoid requiring from the current working 
directory of the editor.

This also avoids requiring from system paths, as it was already the case 
for the native modules search path.
2022-08-03 11:13:26 -04:00