aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
AgeCommit message (Collapse)AuthorFilesLines
2025-02-22style_set: add option to keep non-default style valuesinfastin1-8/+12
2025-01-12array: delete onelinersRandy Palamar1-2/+2
same as buffer commit Array is completely visible
2024-10-26document changing the displayed file of a window via luaFlorian Fischer1-0/+2
2024-09-13lua: improve argument parsing in vis.pipeFlorian Fischer1-6/+10
Support the old behavior of using vis:pipe(cmd, fullscreen) without input. Properly distinguish between vis:pipe(text, cmd, fullscreen) and vis:pipe(file, range, cmd).
2024-09-13support piping a buffer to an external processFlorian Fischer1-3/+27
Currently only Text objects can be piped to external commands. This is tedious if data not available in any file should be passed to an external process (e.g. building options and passing them to vis-menu). This adds the option to pass a buffer to _vis_pipe and provides wrapper functions for the original behavior and the new one.
2024-05-30remove the vis->initialized memberRandy Palamar1-6/+1
I already fixed the reason that this even existed (vis_event_emit getting called at random times when the editor wasn't ready). The option checking in main() was moved up because I noticed it was in the wrong place while thinking about where to emit the INIT event. There is no reason to do a bunch of useless work just to print the version.
2024-05-24combine Win and UiWinRandy Palamar1-24/+24
These are not seperate things and keeping them this way makes gives this convoluted mess where both Wins and UiWins must have linked lists to the other Wins and UiWins in the program despite the fact that neither of them can exist in isolation. This, like my previous cleanup commits, is part of a larger goal of properly isolating the various subsystems in vis. Doing so is required if we ever want to be able to have a vis-server and a vis-client.
2024-05-21remove some view pointer chasingRandy Palamar1-37/+37
Same as previous commit each window only has a single View. No need for it to be stored elsewhere in memory.
2024-05-21remove some ui pointer chasingRandy Palamar1-7/+5
There only exists a single Ui so there is no need to force a pointer redirection for accessing it. The Ui member was moved down in vis-core.h to punt around an issue with the way lua checks for existing objects. It may show up again as I flatten more structs.
2024-05-21replace UiTerm with Ui & delete function pointersRandy Palamar1-6/+6
2024-05-21replace UiTermWin with UiWin & remove function pointersRandy Palamar1-15/+15
2024-05-21make Selection unopaqueRandy Palamar1-3/+3
2024-05-21make View unopaqueRandy Palamar1-13/+13
2024-05-21cleanup some single line get/set functionsRandy Palamar1-5/+5
2024-05-21cleanup vis event interfaceRandy Palamar1-121/+87
This removes the function pointer interface which was adding needless complexity and making it difficult to add new events. Now if new events are only meant for lua they only need to be added to the lua interface. This will also have a minor reduction in runtime memory usage and produce a smaller binary. The only runtime difference is that QUIT happens after all windows have been closed and their files freed.
2024-05-12lua: allow changing the displayed file of a windowFlorian Fischer1-0/+6
Change the file displayed in a window by writing the new file name to the window's file member. This is useful to change the displayed file during events. Using the edit command during an event caused by a pervious edit command causes a double free.
2024-04-29lua: Serve viewport dimensions in viewport tableRudy Dellomas III1-3/+11
These values are useful for calculating terminal positions.
2024-04-29Emit an event (ui_draw) immediately before drawing the screenRudy Dellomas III1-1/+13
This allows better control over styling, as well as potential for entirely new UI elements implemented entirely using the Lua API.
2024-04-29Add Lua function to Win for directly editing cell styling by positionRudy Dellomas III1-0/+27
2024-04-25lua: Report viewport lines and bytes in one tableRudy Dellomas III1-3/+16
This will break all plugins which currently use Win.viewport.
2024-04-21Add a Lua constant for UI_STYLE_LEXER_MAXRudy Dellomas III1-0/+1
Currently, there's no mechanism for defining user styles without risk of collision with default lexer and theme settings. Very few lexers use more than 10, let alone all 64 of the allowed styles, so UI_STYLE_LEXER_MAX - (no. of user defined styles) allows for a reasonably large number of user-defined styles before collision becomes a problem.
2024-02-01allow disabling of statusbarsewn1-0/+10
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