Commit Graph
100 Commits
Author SHA1 Message Date
Guldomanandtakase1121 499124d8e3 Improve autocomplete suggestions box behavior (#1734)
* Improve `autocomplete` suggestions box sizing

This avoids that the box gets too big because of non-visible items, and makes it reactive to window sizing.

* Draw ellipsis when `autocomplete` entries aren't fully visible
2024-03-23 20:26:43 +08:00
Guldomanandtakase1121 34cebe8fe4 Make license time-independent (#1655) 2023-12-01 15:41:25 +08:00
Guldomanandtakase1121 8e2928aeb8 Improve font/color change detection in language_md (#1614)
* Delay setting font for custom `language_md` token types

* Improve font/color change detection in `language_md`
2023-11-30 11:45:58 +08:00
Guldomanandtakase1121 bc935906d1 Use x offset to define render command rect in rencache_draw_text (#1618)
* Return x offset for the first character in `ren_font_group_get_width`

* Use x offset to define render command rect in `rencache_draw_text`
2023-11-30 11:45:25 +08:00
Guldomanandtakase1121 9be5a46a22 Fix patterns starting with ^ in tokenizer (#1645)
Previously the "dirty" version of the pattern was used, which could 
result in trying to match with multiple `^`, which failed valid matches.
2023-11-30 11:39:55 +08:00
Guldomanandtakase1121 885e6b3c50 Fix language_js regex constant detection (#1581)
* Fix `language_js` regex constant detection

* Simplify regex constant detection in `language_js`

* Add more possessive quantifiers in `language_js` regex constant detection

This avoids more catastrophic backtracking cases.

* Allow `.` after regex constant in `language_js`
2023-11-30 11:39:48 +08:00
Guldomanandtakase1121 b1a647814f Fix editing after undo not clearing the change id (#1574) 2023-11-30 11:39:41 +08:00
Guldomanandtakase1121 8eacca7ae1 Fix selecting newlines with find-replace:select-add-{next,all} (#1608)
* Avoid adding existing selections in `select_add_next`

* Use the first available selection as delimiter in `select_add_next`

* Fix returning searches with newlines in `search.find`

* Fix repeat search when the last result spanned multiple lines
2023-11-30 11:39:27 +08:00
Guldomanandtakase1121 19cef97bcd Fix core.redraw when window is not focused (#1601)
* Execute at least one step when window has no focus

This way if `core.redraw` is set, it's respected.

* Fully run threads at least once when window has no focus

This allows threads that set `core.redraw` (like `projectsearch`) to
continue running even after the window loses focus.

"Fully" here means that `run_threads` has gone through *all* the "timed
out" coroutines at least once.
2023-11-30 11:39:16 +08:00
Guldomanandtakase1121 c31a8ae0f6 Scale mouse coordinates by window scale (#1630)
* Update window scale on resize

* Scale mouse coordinates by window scale

* Avoid scaling mouse coordinates while using `LITE_USE_SDL_RENDERER`
2023-11-30 11:27:08 +08:00
Guldomanandtakase1121 5c5c77219b Fix dirmonitor sorting issues (#1599)
* Use `PATHSEP` in path-related functions

* Don't stop on digits when getting the common part in `system.path_compare`

* Avoid sorting multiple times in `dirwatch.get_directory_files`

This also fixes the timeout detection in `recurse_pred`.
2023-11-30 09:20:34 +08:00
Guldomanandtakase1121 6cd1f96234 Fix running core.step when receiving an event while not waiting
When `time_to_wake` was <= 0, so when a coroutine needed to be executed 
as soon as possible, we didn't check for events, so we only performed a 
`core.step` with the blink timer.
This resulted in jerky reactions to input.
2023-11-29 09:41:55 +08:00
Guldomanandtakase1121 4adfd44d9f Limit system.{sleep,wait_event} to timeouts >= 0 (#1666)
Otherwise we might wait forever by mistake.
2023-11-29 09:13:12 +08:00
Guldomanandtakase1121 01cab0611c Fix deleting indentation with multiple cursors (#1670) 2023-11-29 07:41:27 +08:00
Guldomanandtakase1121 fb7ed49a44 Avoid considering single spaces in detectindent (#1595) 2023-11-29 07:41:13 +08:00
Guldomanandtakase1121 4005a46144 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 13:14:28 +08:00
Guldomanandtakase1121 8c451928bf Ignore keypresses during IME composition (#1573)
Some IMEs continue sending keypresses even during composition, so we 
just ignore them.
2023-10-18 13:14:23 +08:00
Guldomanandtakase1121 a066190ee2 Improve common.serialize (#1640)
* Make `common.serialize` more locale-independent

* Handle inf/nan numbers in `common.serialize`
2023-10-18 13:14:14 +08:00
Guldomanandtakase1121 1ad3b70e9e Mark unsaved named files as dirty (#1598) 2023-10-18 13:14:02 +08:00
Guldomanandtakase1121 316fbbe743 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-10-16 12:04:37 +08:00
Guldomanandkelvinvoon03 784b911d41 Make linewrapping consider the expanded Scrollbar size
This avoids reflowing the text when hovering the scrollbar.
2023-09-13 08:05:35 +08:00
Guldomanandtakase1121 397b61e7c6 Fix returned percent when clicking the Scrollbar track 2023-08-26 08:56:35 +08:00
Guldomanandtakase1121 3d93e16597 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-26 08:52:10 +08:00
Guldomanandtakase1121 86cfbe5f3b 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-19 13:31:37 +08:00
Guldomanandtakase1121 f7400c924e Allow setting custom glyphset size (#1542)
* Properly set glyphset size

* Rename `MAX_GLYPHSET` to `GLYPHSET_SIZE`

* Use more appropriate types for font metrics
2023-08-19 13:29:48 +08:00
Guldomanandtakase1121 e9678cc140 Skip checking files if no filename was provided to syntax.get 2023-08-19 13:29:48 +08:00
Guldomanandtakase1121 964b8fe29d Increase number of loadable glyphsets (#1524)
This should be enough to load every unicode codepoint.
2023-08-19 13:28:37 +08:00
Guldomanandtakase1121 f1f81c8851 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-08-19 13:28:14 +08:00
Guldomanandtakase1121 68e9c4670e 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-08-19 13:28:14 +08:00
Guldomanandtakase1121 ff884d7d4a When logging don't use core.status_view if not yet initialized 2023-08-19 13:27:31 +08:00
Guldomanandtakase1121 3febcf454c 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-08-19 13:27:28 +08:00
Guldomanandtakase1121 bd36b3f615 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-08-19 12:45:16 +08:00
Guldomanandtakase1121 97f3159415 Merge carets after doc:move-to-{previous,next}-char (#1462) 2023-08-19 12:43:56 +08:00
Guldomanandtakase1121 d497402c30 Make system.path_compare more case-aware (#1457)
* Use Lua-provided string lengths for `system.path_compare`
* Make `system.path_compare` more case-aware
   Before, strings like `README.md` would be sorted before `changelog.md`, 
   because we only looked at the raw ascii values.
   Now the character case is considered as a secondary sorting key.
2023-08-19 12:41:56 +08:00
Guldomanandtakase1121 6d217204f6 Allow tokenizer to pause and resume in the middle of a line (#1444) 2023-08-19 12:39:22 +08:00
Guldomanandtakase1121 bf35417f82 Don't calculate widths per-uft8-char when not needed (#1409) 2023-08-19 12:38:49 +08:00
Guldomanandtakase1121 89864ee88c Aggregate SDL_Surfaces and their scale in RenSurface (#1429) 2023-08-19 12:38:49 +08:00
Guldomanandtakase1121 a61531dbf0 Use clipping functions provided by SDL (#1426) 2023-08-19 12:38:35 +08:00
Guldomanandtakase1121 1d0725f904 Improve text width calculation precision (#1408)
In some extreme cases (~30000 chars) text width precision takes a hit.
Using double instead of float fixes that.
2023-08-19 12:38:35 +08:00
Guldomanandtakase1121 8c47fad637 Split Command struct into different structs for each command type (#1407)
This reduces the space needed for each command.
2023-08-19 12:38:34 +08:00
Guldomanandtakase1121 95611366bb Use correct view for scrolling to find-replace:repeat-find results (#1400) 2023-08-19 12:38:34 +08:00
Guldomanandtakase1121 b0e524dd15 Improve DocView:get_visible_line_range precision (#1382) 2023-08-19 12:37:50 +08:00
Guldomanandtakase1121 bddb5e274d 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-19 12:28:48 +08:00
Guldomanandtakase1121 a9d8f12cb7 Make empty groups in regex.gmatch return their offset (#1325)
This makes `regex.gmatch` behave like `string.gmatch`.
2023-08-19 12:28:47 +08:00
Guldomanandtakase1121 f00f41b468 linewrapping: Disable horizontal scrolling when enabled (#1309) 2023-08-19 12:28:20 +08:00
Guldomanandtakase1121 138cea45d5 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-08-19 12:28:19 +08:00
Guldomanandtakase1121 bd4e64cc7e Allow command buffer to be expanded (#1297) 2023-08-19 12:28:18 +08:00
Guldoman 74349f8e56 Fix horizontal scroll with touchpad on MacOS 2022-12-28 17:26:57 +01:00
GuldomanandGitHub c29b1c2cb9 Use Lua string length instead of relying on strlen (#1262)
This allows us to render `NULL` byte sequences and not truncate strings 
that contain them.
2022-12-26 13:49:07 -04:00
GuldomanandGitHub 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
GuldomanandGitHub 97bfe503a0 detectindent: Limit subsyntax depth (#1253) 2022-12-20 22:28:29 -04:00
GuldomanandGitHub 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
GuldomanandGitHub 24179bbb23 Merge pull request #1245 from Jan200101/PR/touch-event
add touch events
2022-12-21 00:13:52 +01:00
GuldomanandGitHub 213dc7142e toolbarview: Remove tooltip when hidden (#1251) 2022-12-20 18:07:29 -04:00
GuldomanandGitHub 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
GuldomanandGitHub f7ad8753eb Improve regex.gsub performance (#1220) 2022-12-02 19:21:05 -05:00
Guldoman 9f917052ad Add initialization to variable in ren_draw_text 2022-11-27 00:45:57 +01:00
Guldoman 51f2a291d3 Make Scrollbar follow force_status when animations are disabled 2022-11-15 21:08:33 +01:00
GuldomanandGitHub 519b91c2dd Pass the currently selected item to CommandView validation (#1203) 2022-11-15 12:03:13 -04:00
Guldoman 38a8549e71 Replace deprecated meson feature gui_app with win_subsystem 2022-11-15 16:57:50 +01: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
Guldoman 66198eb327 Use a better fallback in case get_exe_filename fails 2022-11-13 19:47:32 +01:00
GuldomanandGitHub 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
GuldomanandGitHub 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
GuldomanandGitHub 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 8a9bac7de3 Fix drawwhitespace drawing lines with different substitution kinds
When multiple substitution kinds are present in the same line, they're 
placed in the cache in an order that's spatially consistent only between 
items of the same kind.
Because we stopped drawing after we reached the first invisible 
substitution, the subsequent kinds weren't drawn even if they should 
have been.
2022-10-30 02:54:30 +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
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
GuldomanandGitHub 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
GuldomanandGitHub 5c2c95765e Add IME support (#991) 2022-10-15 19:58:51 -04:00
GuldomanandGitHub 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
GuldomanandGitHub e7a575b4c4 Use relative mouse position directly for drop event (#1140)
Previously the relative position was calculated using the window 
position and the global mouse coordinates. In some systems like wayland, 
this operation returns incorrect values.
2022-10-09 20:13:51 -04:00
GuldomanandGitHub 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
Guldoman c25f83da90 Make predicate for some TreeView commands stricter
This avoids performing the `treeview:new-folder` command on ctrl + 
double click.
This happens because `ctrl+lclick` (which is the keybinding for 
`treeview:new-folder`) is triggered also by ctrl + double click, which 
isn't captured by anything else.
2022-08-21 20:03:32 +02:00
Guldoman cbe0fd63bf Reduce double click radius
SDL uses 32 pixels by default, which is a bit too much and causes 
problems with, for example, adding multiple close selections too 
quickly.
2022-08-21 19:08:32 +02: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 06b9953777 Use Object:is instead of direct metatable comparison in autocomplete 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
Guldoman 63c818ac45 Enable SDL timers 2022-08-03 17:28:43 +02:00
GuldomanandGitHub 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
GuldomanandGitHub 06b2fada07 Merge pull request #1079 from cisoun/master
Add font style options in user module
2022-07-16 04:27:39 +02:00
Guldoman d7f9b30d05 drawwhitespace: Invalidate cache on indent size change 2022-07-15 06:54:03 +02:00
GuldomanandGitHub 2dac3667cb Merge pull request #1073 from ncarrezdev/ncarrezdev/synxtax-corrections
[chore]: Update syntax
2022-07-13 15:05:26 +02:00
Guldoman 9cfa3ecd56 Make StatusView:add_item accept a table 2022-07-13 07:22:42 +02:00
Guldoman 693bd11b22 Don't wrap around if there are no suggestions in CommandView 2022-07-11 23:28:08 +02:00
GuldomanandGitHub 86024586fd Start dirmonitor check thread only after a watch is added (#1072) 2022-07-11 17:14:50 -04:00
Guldoman e7c4bdfe8e Make Doc:get_selection[s] return if the selection was actually sorted 2022-07-11 05:39:55 +02:00
GuldomanandGitHub f5fbdd80f6 Merge pull request #1066 from benwalksaway/match_case_syntax_support
language_python: add syntax support for the match-case statement
2022-07-03 15:28:54 +02:00
Guldoman 7888bf08e9 LogView: Show scrollbar 2022-07-01 05:29:55 +02:00