Commit Graph

1425 Commits

Author SHA1 Message Date
Guldoman 9c6c5475d1
Save in the `workspace` unsaved named files and `crlf` status (#1597)
* Save in the `workspace` unsaved named files

* Save in the `workspace` the `crlf` status and restore it for "new" files
2023-10-18 06:46:58 +02:00
Guldoman 8ccdcb7820
Ignore keypresses during IME composition (#1573)
Some IMEs continue sending keypresses even during composition, so we 
just ignore them.
2023-10-18 06:46:27 +02:00
Guldoman cca1c798d2
Improve `common.serialize` (#1640)
* Make `common.serialize` more locale-independent

* Handle inf/nan numbers in `common.serialize`
2023-10-18 06:45:52 +02:00
Guldoman f69f43c3f5
Mark unsaved named files as dirty (#1598) 2023-10-18 06:45:31 +02:00
Guldoman 57dffbaf2a
Remove DPI detection for default `SCALE`
This often leads to `SCALE` values that are way off, and makes Lite XL 
unusable, so we now just default it to 1.
2023-09-30 16:48:38 +02:00
Guldoman b4e95b865c
Make `linewrapping` consider the expanded `Scrollbar` size
This avoids reflowing the text when hovering the scrollbar.
2023-09-07 04:07:52 +02:00
Guldoman 7e44162101
Fix `Scrollbar.{expanded,contracted}_size` documentation 2023-09-07 04:07:52 +02:00
Robert Hildebrandt 185b9cb080
Fixed C++14 digit separators (#1593) 2023-09-07 01:54:52 +02:00
Takase ac5c65c521
docs(core.config): add documentation for config options (#1512)
* docs(core.config): add documentation for config options

* docs(core.config): remove wrong newline

* docs(core.config): remove trailing whitespace

* docs(core.config): add missing whitespace

* docs(core.config): add disclaimer for core.file_size_limit

* docs(core.config): fix wrong description of the pattern

* docs(core.config): fix wrong description

* docs(core.config): fix wrong description for transitions

* docs(core.config): guide user to drawwhitespace plugin

* docs(core.config): clarify libdecor usage

* docs(core.config): clarify various things

* docs(core.config): clarify more about libdecor support

* docs(core.config): fix missing enum separator

* docs(core.config): remove wayland-specific advice on config.borderless
2023-08-26 11:32:39 -04:00
sammyette 5f68e8b7a9
feat(statusview): make a separate item for doc position percent (#1579)
* feat(statusview): make a separate item for doc position percent

* chore: remove unused variable

* fix(statusview): remove command for percent doc item

* fix(statusview): change doc percent tooltip

* fix(statusview): change percent tooltip message
2023-08-26 11:19:12 -04:00
Jefferson González 215b8daef7
Autocomplete plugin improvements (#1519)
* Add icons support to autocomplete plugin

* Removed redundant flag check

* Added support for non syntax colors

* Assert if color name not in style.syntax

* Autocomplete plugin improvements

* Support suggestion symbols scoping
  - global: all open documents
  - local: current document
  - related: all open documents with same syntax
  - none: language syntax symbols only
* Register style.syntax[] entries as icons
* Other related fixes
2023-08-26 10:50:48 -04:00
Guldoman 3f28557aeb
Add `NaN` guard to `View:update_scrollbar` 2023-08-26 05:11:33 +02:00
Adam cb66d5b9e7
Adds super as a modkey. (#1590)
* Adds super as a modkey.

* Added in super designation for windows.
2023-08-25 14:34:51 -04:00
Guldoman 671c8976df
Normalize strokes in fixed order (#1572)
* Use normalized strokes when removing duplicates only when appropriate

* Use normalized stroke in `keymap.unbind`

* Normalize strokes by sorting the modifiers before the keys

This also sorts the modifiers in a fixed manner, decided by 
`modkeys.keys`.
We need to do this because we display the strokes in a few places like 
the command palette.
2023-08-25 14:03:23 -04:00
Takase cb667af756
docs(core.contextmenu): add documentation for contextmenu (#1567) 2023-08-24 22:32:07 -04:00
Guldoman 0dc6043dc7
Fix returned `percent` when clicking the `Scrollbar` `track` 2023-08-23 19:07:52 +02:00
Guldoman d1c3fc0f1c
Fix `scrollbar` misinterpreting `percent` (#1587) 2023-08-20 10:28:49 -04:00
Takase 6d090625f8
fix(core): defer core:open-log until everything is loaded (#1585)
* fix(core): defer core:open-log until everything is loaded

* docs(core): document why core:open-log is opened in a thread
2023-08-18 09:25:10 -04:00
Guldoman 22544b6814
Make `DocView` aware of scrollbars sizes (#1177)
* Make `DocView:scroll_to_make_visible` aware of vertical scrollbar width

* Make `DocView` aware of horizontal scrollbar size
2023-08-04 10:56:49 -04:00
Guldoman e468545bf1
Use proper timeouts for coroutines that don't need to wait (#1467) 2023-08-04 09:40:02 -04:00
Delta-official bfc4892c98
Normalize stroke before adding keybind (#1334)
* Normalize stroke before adding keybind

* improve normalization algorithm and implement normalization in several functions

Signed-off-by: delta <darkussdelta@gmail.com>

---------

Signed-off-by: delta <darkussdelta@gmail.com>
2023-08-04 09:38:33 -04:00
Adam 43c73ca298
Fixed things for when a thread requests a redraw. (#1570)
* Fixed things for when a thread requests a redraw.

* @guldoman's changes.

* Whoops.
2023-08-01 21:38:24 +02:00
Takase 7955fa1d36
Documentation for core.command (#1564)
* docs(core.command): add documentation

* fix(core.common): fix warnings

* docs(core.command): add "core." prefix to all custom types

* docs(core.command); add name as parameter to command.perform

* docs(core.command): fix typo and wording

* docs(core.command): add disclaimer to command.generate_predicate

* docs(core.command): fix wording for predicate

* docs(core.command): document command name

* docs(core.command): document the always_true predicate
2023-07-27 13:04:44 +02:00
Takase 7b330ae81b
Documentation for core.common (#1510)
* docs(core.common): add and improve documentation

* refactor(core.common): remove unused variable to get_height()

* docs(core.common): remove messy newlines

* docs(core.common): fix wording

* docs(core.common): use integer instead of number

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): update docs

the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.

* docs(core.common): fix typo

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): restyle annoatations

Extra whitespaces are removed and @overload is used whenever possible.

* docs(core.common): fix various documentation errors

* docs(core.common): simplify unicode description

* docs(core.common): fix return value

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

* docs(core.common): clarify common.bench for not being a benchmark

* docs(common): add disclaimer for numbers in common.serialize

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-07-22 21:39:32 +02:00
Adam 82fa9bc363
Updated extension for mac. (#1563) 2023-07-20 03:06:18 +02:00
Guldoman 96d6d9acac
Return state when tokenizing plaintext syntaxes 2023-07-09 18:59:25 +02:00
Guldoman 2767ac3718
Skip checking `files` if no filename was provided to `syntax.get` 2023-07-03 22:39:54 +02:00
Luke aka SwissalpS cfcd8af373
Fix #1538 log scrolls automatically (the real PR) (#1546)
* fix #1538 log scrolls automatically

adds:
- when user scrolls, position is kept no matter how many new entries
arrive
- when user scrolls up to last entry, autoscroll is enabled again

does not add buttons to jump up/down
see #1538

* move scroll-test out of on_mouse_wheel

* determine diff_index with loop

* remove check at move_towards yoffset

* use while loop instead of repeat loop

* remove meaningless setter

* remove stray var
2023-06-28 03:05:03 +02:00
Luke aka SwissalpS cf028c510a
comment typo in object.lua (#1541) 2023-06-25 04:09:27 +02:00
Jan 0075b060c8
Add top tab margins (#1479)
adapted from #810 to allow styles to decide upon the top margin of the tab list
2023-06-09 09:44:20 -04:00
Guldoman daaf247ad9
Show cursor at the start of the next line when selecting full lines (#761)
This was the previous behavior that regressed with the keymap clicks.

This also better shows that the selection extends to the next line.
2023-06-09 09:37:08 -04:00
Guldoman 595196f4fa
Make `Doc:sanitize_position` return a more appropriate `col` (#1469)
If `line` is out of range, return the `col` "closest" to the original
values.
2023-06-09 09:34:34 -04:00
Guldoman a5e3d9757e
Revert "core syntax: strip the path from filename on syntax.get (#1168)" (#1322)
* Revert "core syntax: strip the path from filename on syntax.get (#1168)"

This reverts commit af6c4bc152.

The previous behavior was correct and allowed access to the full path for path-dependant syntaxes.

* Use `Doc.abs_filename` to obtain syntax when possible

This allows matching full paths in language syntaxes, but we lose the
possibility of matching the project root.
2023-06-09 09:31:59 -04:00
Guldoman 96251bdbfa
When logging don't use `core.status_view` if not yet initialized 2023-06-09 03:50:34 +02:00
Guldoman bc2f22e9e7
Mark `linewrapping` `open_files` table as weak
We weren't correctly garbage-collecting `Doc`s, so we had `Highlighter`s 
stay alive over their due time.
2023-05-24 04:23:27 +02:00
Guldoman d8581c9b3f
Add mouse grab (#1501)
* Add mouse grab

We now also send mouse movement events only to the interested view.

* Add deprecation messages handler

* Make various `View`s respect `on_mouse_left`

* `StatusView`
* `TitleView`
* `TreeView`
* `ToolbarView`

* Fix scrollbar in `TreeView` not updating

We were in some cases sending outdated mouse positions to the scrollbar, 
which made it think that the mouse was hovering it.

This also updates the hovered item more responsively during scroll.
2023-05-20 13:54:58 -04:00
Jefferson González 57474facc6
Move lineguide below blinking cursor, fixes #1488 (#1511)
* Move lineguide below blinking cursor, fixes #1488

* Added config_spec custom color
2023-05-17 16:14:28 +02:00
Jefferson González 7a218f3181
detectindent: fix wrong detection reported by Adam (#1500)
* The comment patterns had to come before the string ones
* The smallest indentation size is now taken into consideration even if
  it only occurs once, we just make sure its size is more than 1 space.
2023-05-09 13:51:20 -04:00
Adam a818183e9f
Allowed for overrides of toolbar items, so plugins can add things if they want to with different fonts. (#1157) 2023-05-06 21:36:30 -04:00
Guldoman ac5683ba93
Restore horizontal scroll position after scale change (#494)
* Restore horizontal scroll position after scale change

* Consider `View` horizontal size when restoring horizontal scroll

This is needed because `View:get_h_scrollable_size` includes the 
horizontal size, while `View.scroll.x` doesn't.
2023-04-29 12:50:39 -04:00
takase1121 1fd20578ef
feat(bootstrap): return error string from C searcher 2023-04-26 08:31:45 +08:00
Adam Harrison 76a5d40edc Fixing linewrapping bug to do with wordwrapping. 2023-04-22 14:54:42 -04:00
Adam 116ea10fe2
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-04-22 13:24:54 -04:00
jgmdev 8cb842549c StatusView compat fix with older Lua runtimes 2023-04-17 17:26:24 -04:00
Guldoman a6d1fe720f
Merge carets after `doc:move-to-{previous,next}-char` (#1462) 2023-04-14 17:49:26 -04:00
sammyette 2c1a0baccf
feat: add statusview item to show selections (#1445) 2023-04-10 18:16:41 -04:00
vqn 1f1b7fc1ef
#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-04-10 21:57:11 +02:00
Jan 34ba4dbee6
Add View dragging (#1402) 2023-04-07 13:15:50 -04:00
Adam a0de8ea81d
Added in support for foreground and background events. (#1395) 2023-04-07 12:58:56 -04:00
vqn 45e0454a3b
add autocompletion to multicursor (#1394)
* use Doc:remove
2023-04-07 12:54:52 -04:00
vqn f3cfb90ccf
fix cursors positions when deleting multiple selections (#1393)
* correctly handle overlapping selections merge cursors in Doc:raw_remove
2023-04-07 12:54:00 -04:00
Adam 1a0d3a4a03
Added in explicit touchscreen keyboard support. (#1389) 2023-04-07 12:42:46 -04:00
Guldoman 86fa90a76b
Allow `tokenizer` to pause and resume in the middle of a line (#1444) 2023-04-01 12:12:39 -04:00
Adam dc2ae6dd9c
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-03-29 01:57:24 +02:00
Guldoman e8c317494a
Limit `core.threads` without a timeout to run 30 times per second 2023-03-29 00:33:29 +02:00
Adam Harrison 3306fc99c1 Made things clearer, as per jgm's suggestion. 2023-03-28 14:17:30 -04:00
Adam 2cae7c51a5
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-03-28 12:57:47 -04:00
Guldoman c92d7dc239
Don't calculate widths per-uft8-char when not needed (#1409) 2023-03-28 01:17:11 +02:00
Guldoman d15108309c
Make `TreeView` follow the current tab (#1411)
* Make `TreeView` follow the current tab

* Use `TreeView:toggle_expand` in `TreeView:set_selection_to_path`

We can't use `item.expanded` directly because we need to update the 
cached tree structure.
2023-03-16 17:29:33 -04:00
Guldoman 1ec3d28ff6
Use correct view for scrolling to `find-replace:repeat-find` results (#1400) 2023-03-03 11:42:31 +01:00
Adam 2035886fcd
Added in ability to specify prefix via env variable. (#1388) 2023-02-15 21:48:09 -04:00
vqn a07a4e3706
fix incorrect x_offset if opened docs have different tab sizes (#1383) 2023-02-09 13:26:32 -04:00
Guldoman 195520ea12
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-02-09 12:51:41 -04:00
jgmdev 02a99b17fe Correct the inverted tabs scrolling 2023-02-06 15:44:19 -04:00
Eric Gaudet a2acc6d770
Make mouse scrollwheel hovering tabs scroll the tab bar (#1314) 2023-02-06 15:40:04 -04:00
Guldoman 841a456106
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-02-06 15:24:40 -04:00
Guldoman c6d269d35e
Improve `DocView:get_visible_line_range` precision (#1382) 2023-02-06 14:03:29 -04:00
Jefferson González 0495ac28a6
plugins scale: also rescale style.expanded_scrollbar_size (#1380) 2023-02-06 13:40:12 -04:00
Jefferson González d784133777
NagView: properly rescale on scale change (#1379)
* drop font option since style.font is always used
2023-02-06 13:38:00 -04:00
Jefferson González e800a5de3c
Restore in-selection replace as discussed in #1331 (#1368) 2023-02-06 13:34:59 -04:00
Jefferson González 5b2538e856
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-02-06 13:32:44 -04:00
Guldoman 2e02aede7c
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-02-01 20:28:21 -04:00
vqn d207adc230
Context menu fixes and keyboard navigation (#1338)
* fix Doc contextmenu not registering commands if scale plugin is not found
* fix TreeView contextmenu commands not working if the mouse hovers DocView
* add keyboard navigation to TreeView contextmenu
* fix incorrect contextmenu predicate
2023-01-30 13:36:17 -04:00
Himura Kazuto 0a0754d1c3
Replace globally when replacing from selection (#1331) 2023-01-30 13:00:48 -04:00
sammyette 719540e73d
feat: add option to only draw whitespace if it is within selection (#1312)
* refactor: remove sort_positions usage
* refactor: move draw conditional to has_any_selection and other changes
  - snake case (sssss)
  - break after finding selection
* fix: typo of config plugins
* fix: do check for show selected only properly
* feat: only draw within selection per substitution
* `drawwhitespace`: Make `show_selected_only` work properly

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-01-30 12:43:26 -04:00
Adam ad272fce53
Abstracted open_doc out to allow for more easy overriding. (#1344) 2023-01-30 12:12:44 -04:00
Adam 813b8b278b
Getting rid of annoying forward slash on windows. (#1345) 2023-01-30 12:10:11 -04:00
Adam aa627d4023
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-01-19 10:14:45 -05:00
Guldoman 9308dfdd66
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-01-18 22:15:26 -05:00
xwii 6e04a4f970
Use `table.move` to implement `common.splice` (#1324)
* Use `table.move` to implement `common.splice`

* Disallow negative `remove` in `common.splice`
2023-01-13 19:33:13 +01:00
Merlin Volkmer 673c564e09
language_md: add nix code block highlighting (#1323) 2023-01-12 15:12:55 +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 385ee69f94
`linewrapping`: Disable horizontal scrolling when enabled (#1309) 2023-01-05 16:02:12 -05: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
Guldoman 18e3542be0
Allow `TreeView` file operation commands when focused (#1256)
Impacts `treeview:{rename,new-file,new-folder,open-in-system}`.
Previously those were only available when the mouse was over the 
`TreeView`.
They now use the same predicate as `treeview:delete`.
2022-12-26 13:41:14 -04:00
Guldoman 97bfe503a0
`detectindent`: Limit subsyntax depth (#1253) 2022-12-20 22:28:29 -04: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 902539b97a
trimwhitespace: expose functionality and extra features (#1238) 2022-12-20 18:13:56 -04:00
Guldoman 213dc7142e
`toolbarview`: Remove tooltip when hidden (#1251) 2022-12-20 18:07:29 -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
Jefferson González e152db2cce
plugins projectsearch: expose its functionality (#1235) 2022-12-14 11:53:20 -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