aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
AgeCommit message (Collapse)AuthorFilesLines
2023-11-23luadoc: fix broken link and add links between vis/win.optionsRandy Palamar1-1/+3
2023-10-05vis-lua: fail when mapping a key to an invalid handler typeKarthin Srinavakili1-0/+2
When passing an invalid handler type (i.e., any type that isn't a string, function, or KeyAction) to Vis:map/Window:map, the editor would map the key to an empty (zeroed) KeyBinding struct. vis_keys_process() doesn't take this into account, so the key is never consumed from the input queue, causing the editor to get stuck in an infinite loop.
2023-08-27Make expandtab option window-localAlexey Yerin1-10/+10
2023-08-27Make tabwidth option window-localAlexey Yerin1-6/+6
2023-08-27vis-lua.c: silence warning about implicit conversionRandy Palamar1-1/+5
`SIZE_MAX` cannot be represented accurately in `lua_Number`. A correct solution probably doesn't exist but we can silence the warning by explicitly casting to `lua_Number` and changing the comparison to `<` instead of `<=`. checkpos() deals with large numbers for file ranges. For most users we can assume no one is editing files that are `SIZE_MAX` bytes long (many petabytes). For obscure systems where `SIZE_MAX` is a small number this will result in a maximum range (in lua) of 1 byte less than before. fixes #1120: vis-lua.c:504:21: warning: implicit conversion changes value
2023-08-24lua api: fix a couple typos in process_response() documentationRandy Palamar1-2/+2
I thought I fixed these in the applied patch but I guess they slipped by
2023-08-24Implementation of the non-blocking process running Lua APIxomachine1-0/+91
Rationale A modern text editor usually includes tools for helping user to avoid mistakes in texts. Those tools include spell checkers and programming language integrations. Though vis explicitly states that the full featured IDE is not a goal, implementing some of the tools might be achieved using its Lua API. Unfortunatelly the API misses the ability to start a process and to perform a communication with it without completely blocking the editor UI, which is crucial for any tool that performs background tracking of the inserted text (e. g. language servers). Implementation details New feature introduces new API method: communicate. The method start a new process and returns a handle to communicate with the process instantly. The patch inserts stderr and stdout file descriptors of the process to the pselect call of the main loop used for reading user input to track the process state without blocking the main loop until the process is finished. Any changes in the process state cause the iteration of the main loop and are being exposed to the Lua API as new event: PROCESS_RESPONSE.
2023-08-24Lua API: access and set all available optionsRandy Palamar1-16/+400
The first point of this commit is to allow all options to be read from lua. This has a number of uses for plugin writers. They are grouped into a couple of tables depending on what they control: `vis.options`: table with global configuration `win.options`: table with window specific configuration The second point is to allow you to set all these options as if they were simply lua variables. Technically this is already possible by using `vis:command("set ...")` but personally I think this interface is cleaner. Note that this already possible for some things like the current mode (eg. vis.mode = vis.modes.VISUAL). Examples: `vis.options.ai = true` `win.options.brk = " !?."` `win.options = { showeof = true, showtabs = true } There are a number of related issues and pull requests: closes #803: Lua API: let plugins read the values of options closes #812: Window layout property supersedes/closes #717: Add ability to access tabwidth from Lua supersedes/closes #1066: expose UI layout and allow it to be set from lua API
2023-08-10vis-lua.c: stop obj_ref_get() from leaving the lua stack modifiedRandy Palamar1-17/+8
The only place where this behaviour was encountered was in file_lines_iterator() and it was just being worked around.
2023-07-18vis:pipe(): don't segfault if vis->win isn't presentRandy Palamar1-1/+5
When `file` was made optional the variable was changed to be initialized by `vis->win->file` instead of a known safe file pointer. If `vis:pipe()` is called based on the event `FILE_OPEN` the `file` parameter can be valid even when `vis->win` is not yet present. Assuming `file` was provided this would be handled later on if vis didn't segfault. By initializing to NULL when `vis->win` isn't present `file` is given a chance be handled later. In the case where `file` wasn't given and `vis->win` is missing an error is thrown and `vis:pipe()` exits. fixes #1107 - Lua API: vis:pipe() causes a segfault when called before a window is open
2023-07-18Add fullscreen param to vis_pipe_collect() and Lua API vis:pipe()Jörg Bakker1-1/+4
This enables restoring the terminal from a fullscreen command like curses based program. Use cases are e.g. a file picker based on some external program like nnn (https://github.com/jarun/nnn).
2023-06-22Lua API: allow nil in vis:pipe() File and Range parametersJörg Bakker1-5/+13
2023-03-19implement Selection:remove()Jeremy Bobbin1-0/+13
2022-11-29fix miscellaneous spelling mistakesNick Hanley1-9/+9
2022-08-19Revert "vis-lua: support themes in vis:message"Evan Gates1-5/+1
This reverts commit 22d4709e8a30c8feb9b4da7d78e0ea6a57af83e8. erf mentioned[0] that this change broke a plugin. Revert for now until have time to implement it without that bug. [0] https://github.com/martanne/vis/issues/1034
2022-06-15vis-lua: support themes in vis:messageEvan Gates1-1/+5
The commit that added vis:message[0] used the existing vis_message_show function which is used internaly to display lua stack traces. That function uses the internal error_file. vis_event_emit does not trigger events for internal files in order to avoid extra lua errors when already printing a lua stack trace[1]. Due to this setup any usage of vis:message showed the text in a window with default theme/syntax/status bar colors. Instead of using the internal vis_message_show function, create a new window and file that are not marked internal in the same manner as cmd_help so themes are applied. [0]: d815268 (vis-lua: implement vis:message(msg)) [1]: d555c90 (vis: properly redraw status bar of windows displaying internal files)
2020-12-29vis-lua: provide file.permission propertyMarc André Tanner1-0/+10
These are the permission bits of struct stat's st_mode field at the time of the most recent load/save. Close #861
2020-12-10fix typos in commentsMoesasji1-4/+4
2020-09-20Merge branch 'csi_event' of https://github.com/ezdiy/vis into masterMarc André Tanner1-0/+21
2020-09-17vis-lua: provide vis.mark propertyMarc André Tanner1-0/+17
2020-09-17vis-lua: use utility function to translate mark namesMarc André Tanner1-9/+7
2020-09-17vis-lua: provide vis.register propertyMarc André Tanner1-0/+17
2020-09-17vis-lua: use utility function to translate register namesMarc André Tanner1-9/+7
2020-09-17vis-lua: fix mark_names Lua doc indentationMarc André Tanner1-3/+3
2020-09-17Pass up terminal CSI as events to Lua.Ez Diy1-0/+21
2020-08-14vis-lua: fix redraw method name in API documentationMarc André Tanner1-1/+1
2020-08-14vis-lua: make file.modified assignableMarc André Tanner1-1/+22
We fake a modification by doing an insertion followed by a deletion which does not actually change the buffer content. Close #855
2020-02-24vis-lua: implement vis:redraw()Marc André Tanner1-0/+13
2020-02-24lua: fix documentation typos and errorsGeorgi Kirilov1-2/+2
2020-02-10vis-lua: avoid string memory leaks in error caseMarc André Tanner1-6/+3
The function lua_pushstring can throw an error, meaning it will setjmp(3) out thereby leaking the allocated memory. By using lua_newuserdata we let Lua free the memory during a GC run.
2020-02-07lua: add <plugin>/init.lua to package.pathGeorgi Kirilov1-2/+4
2020-02-04vis: make core code more robustMarc André Tanner1-1/+1
The core vis code was originally written under the assumption that there always exists at least one window. However, when being called from the Lua configuration file during start up this is not yet the case. In general, Lua code should always be placed within appropriate event handlers e.g. vis.events.INIT for global configuration. Invoking API functions depending on an active window from top level statements is not supported. Where before the editor simply crashed, these changes turn such code sections into NOPs. Fix #561
2018-05-17vis: simplify C status bar drawing codeMarc André Tanner1-11/+7
2018-05-17vis: display count/input queue content in status barMarc André Tanner1-0/+7
Fix #695
2018-05-17vis-lua: expose current input_queue contentMarc André Tanner1-0/+9
2018-05-16vis: remove v and V in operator pending modeMarc André Tanner1-1/+1
2018-01-01vis-open: fix for absolute and non-existent pathsKelsey Judson1-0/+9
When the shell cannot find any matching files, the glob is not expanded, and vis-open will return the absolute path of the current working directory (because dirname outputs '.'), followed by the filename, followed by a literal '*'. This commit checks that the final path actually exists, and if not, exits with status 1. It also uses text_object_longword for the range to match, so that absolute paths are accepted, and replaced properly (else it only works back to the first '/').
2017-11-21vis-lua: implement window:closeMarc André Tanner1-0/+28
2017-11-21vis-lua: do not enumerate internal windowsMarc André Tanner1-5/+8
This for example skips the command prompt window.
2017-07-23vis-lua: move marks array to window objectMarc André Tanner1-27/+29
Some marks (only '^ right now) are window specific while others have file file scope. This distinction is currently hidden in the API. Before this commit file.marks[...] would always operate on the currently active window.
2017-07-17vis: specify window in mark related APIMarc André Tanner1-2/+2
This should also fix coverity issue 157024.
2017-07-14vis-lua: make selection first class primitives in Lua APIMarc André Tanner1-83/+111
2017-07-11vis: cleanup register related APIMarc André Tanner1-15/+30
Also expose all register slots through the Lua API.
2017-07-11vis-lua: represent marks as array of rangesMarc André Tanner1-21/+34
2017-07-08vis: cleanup marks implementationMarc André Tanner1-2/+2
We now use ' to refer to marks. Mark a is set using 'am and restored using 'aM while this is slightly harder to type than ma and 'a it is consistent with register usage for yank/put and allows a default mark to be used which is handy for quick selection manipulation primitives.
2017-07-07vis: use marks instead of registers to store selectionsMarc André Tanner1-6/+14
The key binding remain the same, but the selections are now stored on a per-buffer basis.
2017-06-27Merge branch 'theme-tweaks-2' of https://github.com/p-e-w/visMarc André Tanner1-13/+14
Conflicts: view.c
2017-06-15view: do not automatically anchor selections when setting rangeMarc André Tanner1-2/+4
2017-06-15vis: rename uses of Cursor to SelectionMarc André Tanner1-36/+36
2017-06-15view: rename view_cursorsMarc André Tanner1-2/+2