aboutsummaryrefslogtreecommitdiff
path: root/main.c
AgeCommit message (Collapse)AuthorFilesLines
2026-01-06replace oversized libutf with smaller versionRandy Palamar1-9/+9
this is taken from one of my other projects. there was no reason for there to be 2x the code tests checking for surrogate characters and non characters were removed. I see no reason why the user shouldn't be allowed to insert those characters in text (they exist in the standard). Also, in the case of non-characters only the first two were being checked and not the other 64.
2026-01-06vis-marks: make mark set cache actually usefulRandy Palamar1-6/+1
Without also saving and restoring the editor mode when the selections were added to the cache almost no useful actions can be performed. While we are at it the 3 jumplist functions can just be combined into one.
2026-01-04main: initialize signal handling before other parts of the editorFlorian Fischer1-19/+23
There is a period during vis' initialization where our signal handler is not yet registered and we potentially lose not handled signals. This time window is dependent on the lua code executed during the EVENT_INIT event and can be arbitrary long dependent of the user's config. Decrease the window for lost signals by registering our signal handler and blocking the signals for the rest of the editor's startup immediately after parsing the command options.
2025-12-16make vis a single file buildRandy Palamar1-23/+1
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-6/+10
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-12-16main: replace key action enum, prototype, and table with single X-macro listRandy Palamar1-1275/+345
The lists were very long and if you need to change anything in them you need to do so in at least 3 different places to ensure they remain in sync. The idiomatic way of solving this problem in C (without using features outside the language) is to use a sequence of X-macros. This was motivated by the fact that many of the functions in this file have names that collide with other names in the program. When the program is compiled into separate object files this is not a problem but I want to compile vis in a single translation unit. It also adds more mental overhead when debugging if you have to keep track of which file you are in as well as which function you are in. The macro definition for the function args is less common but is a good way of ensuring that if you need to modify the type of the function pointer (i.e. change its arguments) you will not have to locate hundreds of locations throughout the code. This also makes it much easier to potentially refactor the KeyAction array of structs into separate arrays.
2025-01-12array: delete onelinersRandy Palamar1-2/+2
same as buffer commit Array is completely visible
2025-01-11buffer: delete pointless buffer_init functionRandy Palamar1-3/+2
lets not make the code harder to read for no reason
2024-05-30remove the vis->initialized memberRandy Palamar1-22/+24
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-21remove some ui pointer chasingRandy Palamar1-2/+2
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-3/+3
2024-05-21make Selection unopaqueRandy Palamar1-11/+12
2024-05-21make View unopaqueRandy Palamar1-9/+9
2024-05-21cleanup some single line get/set functionsRandy Palamar1-33/+33
2024-05-21cleanup vis event interfaceRandy Palamar1-20/+1
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-04-29Emit an event (ui_draw) immediately before drawing the screenRudy Dellomas III1-0/+1
This allows better control over styling, as well as potential for entirely new UI elements implemented entirely using the Lua API.
2024-02-05use correct apostrophe in error messageErlend Lind Madsen1-1/+1
2020-12-28vis: implement multiline to/till motionsMarc André Tanner1-1/+25
These are currently not mapped by default but can be enabled by mappings using their virtual key names.
2020-12-28vis: rename to/till motion internalsMarc André Tanner1-24/+24
This renames the functions and constants implementing the to/till motions. The new names should indicate that matches are only returned within the current line (not globally). Apart from the changed virtual key/command name this contains no functional changes.
2020-12-10vis: make O implementation independent of <Up> mappingMarc André Tanner1-1/+1
2020-10-10vis: add vis-selection-new-match-allEvan Gates1-10/+28
Add new vis-selection-new-match-all command, default keybinding <C-a> in visual mode. Refactor selections_next_match to find all matches if arg.b is true. This does not affect existing configs as arg.b defaults to false.
2020-10-10vis: refactor selections_match_nextEvan Gates1-35/+8
A lot of code from selections_match_next was duplicated in selections_match_next_literal. Use the new text_object_find_next/prev functions to combine the two match_next functions into one.
2020-09-17Pass up terminal CSI as events to Lua.Ez Diy1-0/+1
2020-08-29vis: improve C-n behavior in visual modeMarc André Tanner1-3/+9
Determine the matching behavior based on the first (not primary) selection. Fix #864
2020-08-29vis: implement C-n in normal mode with a mapping to viwMarc André Tanner1-20/+0
2020-08-01vis: remove ae outer entire text objectMarc André Tanner1-6/+0
Use :, which is a short hand for :0,$ instead.
2020-08-01vis: remove ie inner entire text objectMarc André Tanner1-6/+0
2020-08-01vis: remove z> rightmost pairwise selection combinatorMarc André Tanner1-44/+0
2020-08-01vis: remove z< leftmost pairwise selection combinatorMarc André Tanner1-15/+0
2020-08-01vis: remove z- shorter pairwise selection combinatorMarc André Tanner1-17/+0
2020-08-01vis: remove z+ longer pairwise selection combinatorMarc André Tanner1-17/+0
2020-08-01vis: remove z& pairwise selection intersectionMarc André Tanner1-13/+0
2020-08-01vis: remove z| pairwise unionMarc André Tanner1-15/+0
2020-04-28vis: make <Escape> reset count in visual modesMarc André Tanner1-0/+16
2020-04-28vis: make <Escape> reset count in normal modeMarc André Tanner1-0/+16
Fix #825
2020-02-03vis: improve <C-n> in visual modeMarc André Tanner1-1/+37
If the existing primary selection is not a word, switch to a literal search. This should still avoid unwanted prefix matches (e.g. when renaming related variables) but allow searching for arbitrary regions. Fix #746
2020-02-03vis: simplify selections_match_nextMarc André Tanner1-15/+15
Introduce utility function to create new anchored, primary selection.
2020-01-30main: fix a few mistakes in commentsTwoFinger1-6/+6
2020-01-30vis: Fix a few :help stringsTwoFinger1-10/+10
2020-01-27vis: make r<Enter> insert a new lineMarc André Tanner1-0/+2
Special case <C-v><Enter> to still insert a carriage return as discussed in #656 and changed in 2cfc9c867bdfd4cc3ae3246f31cf636633fe1a5f. Due to limitations of the current implementation <C-v> is not generic, i.e. combining it as r<C-v><Enter> will not work. Fixes #765
2018-05-16vis: remove v and V in operator pending modeMarc André Tanner1-19/+0
2018-05-16vis: remove gPMarc André Tanner1-6/+0
This only removes the user visible mapping, the underlying implementation is kept for now. It is used in insert mode for the implementation of <C-r> (register insertion).
2018-05-16vis: remove gpMarc André Tanner1-6/+0
This only removes the user visible mapping, the underlying implementation is kept for now. This might change in the future.
2018-05-16vis: implement g~ using tr(1)Marc André Tanner1-6/+0
2018-05-16vis: implement gU using tr(1)Marc André Tanner1-6/+0
2018-05-16vis: implement gu using tr(1)Marc André Tanner1-6/+0
2018-04-08Fix "parenthese" in identifiersTwoFinger1-12/+12
2018-03-27main: fix a few typos in commentsDelapouite1-2/+2
2018-03-05Fix a typo in identifiersTwoFinger1-6/+6