aboutsummaryrefslogtreecommitdiff
path: root/vis.c
AgeCommit message (Collapse)AuthorFilesLines
2025-12-22silence new gcc warningsRandy Palamar1-2/+2
2025-12-22move all standard library includes into util.hRandy Palamar1-23/+2
2025-12-16make vis a single file buildRandy Palamar1-0/+19
2025-12-16delete functions which were exposed as unusedRandy Palamar1-16/+0
2025-12-16mark all functions in headers with VIS_EXPORT or VIS_INTERNALRandy Palamar1-1/+2
if vis actually wants to be a library exported symbols may need mark up depending on the platform (eg. __declspec(dllexport)). This needs to be hidden behind a macro because the way you export is not the same on every platform. I did this based on the assumption that vis.h was supposed to be the only interface to the "vis" library. Since nobody actually uses vis as a library I have no idea if this is actually correct. Anyway marking up all prototypes like this allows for one to convert all functions to static if a single translation unit is used by inserting at the start: #define VIS_INTERNAL static #define VIS_EXPORT static
2025-12-16main: make vis instance into a globalRandy Palamar1-13/+9
This might be controversial to some but for the purposes of the editor there will never be more than one instance of vis. This allows the compiler to use more efficient rip relative addressing in the places where it knows the code is referring to the global instance. Once the code is compiling in a single translation unit with all functions declared static this will allow for much better optimization. From the perspective that vis is meant to be a library, which is what Marc clearly intended, changing vis_new() to vis_init() and vis_free() to vis_cleanup() is still better design. The library user should be allowed to place the vis instance wherever they want in memory.
2025-02-22style_set: add option to keep non-default style valuesinfastin1-6/+6
2025-01-12buffer: drop buffer_move functionRandy Palamar1-6/+2
2025-01-12array: delete onelinersRandy Palamar1-2/+2
same as buffer commit Array is completely visible
2025-01-11buffer: clear out one line functionsRandy Palamar1-2/+2
Buffer is fully exposed to the program, no need to rely on the linker to optimize useless code.
2025-01-11buffer: delete pointless buffer_init functionRandy Palamar1-6/+3
lets not make the code harder to read for no reason
2025-01-08ui: pass window id when setting styleRandy Palamar1-6/+6
There are a couple times when we want to set a style without an active window. In those cases we just want to use base UI_STYLE_*s and (Win *) is not needed. This fixes a crash when trying to do a vis:info() from lua during an initial file open event. Note that this code is due for a serious refactor, ui styles should be stored in Ui and window specific styles should be stored in Win. Then we won't need any of this difficult to follow indexing into the styles array based on window id and we will never have to realloc when a new window opens. Just another thing to add to my list.
2025-01-04remove duplicated read_buffer functionsRandy Palamar1-7/+2
When you take a pointer to a function in C that function is going to appear in full in the final binary. This means that there were 3 sections of the final binary with the exact same code. You could argue that in very high performance programs having that function closer to the current instruction when it is needed will give a performance boost but there are so many other places to gain more significant speed ups in vis before that would be remotely relevant. In fact, removing these allows the buffer_append call to inlined so that buffer_insert can be hopped to directly instead of including a useless hop in the middle.
2025-01-02check the life time of subprocesses before freeing visFlorian Fischer1-0/+1
Currently there is now way for long running subprocesses like language servers to gracefully shutdown. When reacting to the QUIT event and invalidating the process handle the subprocess will never be killed and destroyed because the subprocesses are only checked during vis_run. Collecting and killing subprocesses with invalid handles after the QUIT event allows graceful shutdown.
2024-09-13support piping a buffer to an external processFlorian Fischer1-18/+56
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-0/+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-18/+17
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-24remove SyntaxSymbol redirection typeRandy Palamar1-1/+1
There is no reason why this isn't just a char *.
2024-05-21remove some view pointer chasingRandy Palamar1-38/+36
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-27/+26
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-41/+25
2024-05-21replace UiTermWin with UiWin & remove function pointersRandy Palamar1-13/+9
2024-05-21make Selection unopaqueRandy Palamar1-7/+6
2024-05-21make View unopaqueRandy Palamar1-14/+14
2024-05-21cleanup some single line get/set functionsRandy Palamar1-32/+2
2024-05-21cleanup vis event interfaceRandy Palamar1-99/+13
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-19fix primary cursor color displaynobody1-1/+2
2024-05-12lua: allow changing the displayed file of a windowFlorian Fischer1-0/+12
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-29Emit an event (ui_draw) immediately before drawing the screenRudy Dellomas III1-0/+4
This allows better control over styling, as well as potential for entirely new UI elements implemented entirely using the Lua API.
2024-03-25ui: refactor style handlingRandy Palamar1-49/+19
The old style handling had a lot edge cases where one of the colours or the attribute wouldn't get applied correctly. This commit adds a new style_set() method to the Ui which should be called instead of manually touching a cell's style. This also means that the Cell struct can be made opaque since all the handling is now done inside the ui-terminal files. With this it is now viable to combine the light and dark 16 colour themes into a single base-16 theme. This theme works very well with the Linux virtual console and will now be the default theme regardless of if the terminal supports 256 colours or not. This should address the common complaints about vis not respecting the users default terminal colours. fixes #1151: Theming is sometimes partially applied or ignored see #1103: terminal no longer has transparency/opacity see #1040: Transparent background and setting options by default
2024-03-25Add parentheses around '&&' within '||'.Matěj Cepl1-2/+2
Silencing compiler's -Wparentheses warning.
2023-10-17apply configured foreground to matching pairRandy Palamar1-0/+1
fixes #1151 (part 2): Set foreground color for matching pair
2023-10-17apply configured foreground to selectionsRandy Palamar1-0/+1
fixes #1151: Set foreground color for visual selection
2023-10-10vis_pipe: correctly return non-zero exit statusRandy Palamar1-1/+4
according to POSIX wait(3p) the return status needs to be checked and the macro WEXITSTATUS(stat_val) should be used to get the actual return value on a normal exit. POSIX doesn't specify the value of stat_val on abnormal exit and thus vis_pipe() should just return -1 as it does for other errors closes #1130: vis:pipe returns wrong exit status (when non-zero) Thanks @pippi1otta for the report and suggestion.
2023-08-27Make expandtab option window-localAlexey Yerin1-2/+2
2023-08-27Make tabwidth option window-localAlexey Yerin1-3/+1
2023-08-24Implementation of the non-blocking process running Lua APIxomachine1-1/+4
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-01Prevent flickering in cursesIan Hixson1-0/+8
Reading from curs_refresh(3X) from curses, calling doupdate() repeatedly will cause 'several bursts of output to the screen'. wnoutrefresh() has the smarts to only copy the changed lines to the copied virtual screen, but doupdate() does not. There have been several bug reports related to flickering but all seems to be inconsistenly reproducible due to different terminal buffering behavior. See #1032, #327 Unfortunately, when I am using a slow display, I still notice flickering, so this commit changes the routines for opening new windows and splitting windows to wait until the last change is finished before calling doupdate().
2023-07-18Add fullscreen param to vis_pipe_collect() and Lua API vis:pipe()Jörg Bakker1-4/+6
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-06Limit to lines within range for inner text objectsMiles Canfield1-0/+3
2022-11-29fix miscellaneous spelling mistakesNick Hanley1-1/+1
2022-07-27vis: Some duplicate files were overlooked due to a condition in the wrong placeTom Schwindl1-5/+7
2022-07-23vis: Compare non-existing files by name and existing files by inodeTom Schwindl1-5/+12
2022-07-12vis: Compare inodes instead of filenamesTom Schwindl1-3/+8
2021-02-15vis: correctly close pipe connected to stdin of external processMarc André Tanner1-2/+2
Once we have written all data we should properly close the (correct) pipe. Before we wrongly closed the pipe connected to the standard output stream. More generally, we currently do not listen for child process termination, but instead wait until all the connected pipes are closed. This might be problematic in case the external process keeps hold of the standard I/O file descriptors. One particular example of this is wl-copy(1). See #929
2020-12-10fix typos in commentsMoesasji1-2/+2
2020-11-14vis: fix <C-c> processing after SIGINTMarc André Tanner1-1/+2
There are two main ways how the input queue is managed in vis: - vis_keys_feed(..) appends new input to the queue and immediately starts processing it. Starting from the position before the call i.e. ignoring any previously queued input. This is typically used in key binding handlers where the input queue still contains the mapping leading to the invocation of the handler. In that case new input should be interpreted immediately, before the handler eventually returns and its mapping is consumed. - vis_keys_push(..) with pos=0, appends new input to the end of the queue and starts processing it from the start of the queue, taking the full content into consideration. This is used by the main loop when new input becomes available. This patch switches the handling of <C-c> after a SIGINT from the former to the latter mechanism and fixes mappings using <C-c> in a non-leading position.
2020-09-20Merge branch 'emg-add-ignorecase' of https://github.com/deepcube/vis into masterMarc André Tanner1-1/+2
2020-09-19Add ignorecase optionEvan Gates1-1/+2
Add a global ignorecase boolean option. When set add REG_ICASE to cflags when calling text_regex_compile().
2020-09-17Pass up terminal CSI as events to Lua.Ez Diy1-0/+15