aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
AgeCommit message (Collapse)AuthorFilesLines
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
2017-06-15view: rename view_cursors_numberMarc André Tanner1-2/+2
2017-06-15view: rename view_cursors_countMarc André Tanner1-3/+3
2017-06-15view: rename view_cursors_nextMarc André Tanner1-2/+2
2017-06-15view: rename view_cursors_selection_clearMarc André Tanner1-1/+1
2017-06-15view: rename view_cursors_selection_getMarc André Tanner1-2/+2
2017-06-15view: rename view_cursors_primary_{get,set}Marc André Tanner1-4/+4
2017-06-10More theme improvementsPhilipp Emanuel Weidmann1-13/+14
2017-05-27vis-lua: avoid nil values in table returned by vis:mappingMarc André Tanner1-1/+2
Also fix compilation with ./configure --disable-help.
2017-05-27vis-lua: expose functions to unmap key bindingsMarc André Tanner1-0/+40
2017-05-27vis-lua: expose currently active key bindings through APIMarc André Tanner1-0/+38
Close #563
2017-05-03text: remove text_insert_newline functionMarc André Tanner1-2/+2
This is no longer needed because we always insert \n never \r\n.
2017-04-20vis: start cleaning up register related codeMarc André Tanner1-3/+1
Now that register.h is no longer used by view.h we can move the struct and function declarations to vis-core.h.
2017-04-09vis: remove handling of \r\n line endingsMarc André Tanner1-22/+0
Use something like dos2unix(1) and unix2dos(1), if you need to edit such files.
2017-03-25Merge branch 'master' of https://github.com/joshaw/visMarc André Tanner1-1/+10
2017-03-24vis: properly redraw status bar of windows displaying internal filesMarc André Tanner1-3/+3
Currently the only "internal window" with a status bar is the information window used to display Lua stack traces. We do not want to trigger events for it, because that could result in further Lua errors. Nonetheless its status bar should be properly redrawn to avoid display artifacts. That is why we fall back to the built-in default status bar as used by non-Lua builds.
2017-03-24vis-lua: register a panic handlerMarc André Tanner1-1/+31
The intention here is to catch any errors in unprotected mode, close the lua state and jump back to the mainloop to give the user the opportunity to take care of unsaved changes. We abuse the infrastructure Lua provides for custom memory allocators to associate our vis instance pointer with the lua state. In the panic handler we can then use lua_getallocf to get our context back. The actual memory allocater is equivalent to the one used by default and just forwards everything to the libc.
2017-03-24vis-lua: use better name for error handling functionMarc André Tanner1-2/+2
2017-03-24vis-lua: adjust return value validation of called lua functionsMarc André Tanner1-3/+7
While the invoked Lua functions are executed in protected mode, the validation of the return values currently happens in unprotected mode. Thus an invaid return value triggers a lua error and because we currently do not have a global panic handler registered this will terminate the editor process. This commit changes the return value validation to silently fall back to default values instead of raising errors. If we want to provide user friendly stack traces showing the origin of the offending value we would have to move the validation into the Lua code.
2017-03-24vis-lua: validate lua state on vis API entry pointsMarc André Tanner1-9/+27
2017-03-22vis-lua: add usage documentation to command_registerJosh Wainwright1-1/+10
2017-03-19vis-lua: allow operators to be defined as lua functionsMarc André Tanner1-0/+62
2017-03-19Move :set horizon option implementaiton to luaMarc André Tanner1-5/+3
2017-03-19Move :set theme option implementation to luaMarc André Tanner1-19/+0
2017-03-19Move :set syntax option implementation to luaMarc André Tanner1-55/+1
It is no longer possible to change the used syntax by assigning to the `win.syntax = name` field, instead the function win:set_syntax(name)` should be called. The distinction between filetype and syntax lexer to use should probably be clarified/cleaned up at some point.
2017-03-19vis-lua: make vis.win return nil if no window exists yetMarc André Tanner1-2/+4
This is only the case during editor startup before the first window is created.
2017-03-19vis-lua: expose option_unregister functionMarc André Tanner1-0/+16
2017-03-19vis-lua: expose option_register functionMarc André Tanner1-0/+54
2017-03-14Restructure display codeMarc André Tanner1-0/+5
Use pull instead of push based model for display code. Previously view.c was calling into the ui frontend code, with the new scheme this switches around: the necessary data is fetched by the ui as necessary. The UI independent display code is moved out of view.c/ui-curses.c into vis.c. The cell styles are now directly embedded into the Cell struct. New UI styles are introduced for: - status bar (focused / non-focused) - info message - window separator - EOF symbol You will have to update your color themes. The terminal output code is further abstracted into a generic ui-terminal.c part which keeps track of the whole in-memory cell matrix and #includes ui-terminal-curses.c for the actual terminal output. This architecture currently assumes that there are no overlapping windows. It will also allow non-curses based terminal user interfaces.
2017-03-07vis-lua: remove vis:open methodMarc André Tanner1-20/+0
The same functionality is available using vis:command and :open. If we decide a distinct API is useful, we should probably also provide a corresponding close method.
2017-03-05vis-lua: expose vis:pipe functionMarc André Tanner1-0/+35
2017-03-03vis-lua: add vis:exit functionMarc André Tanner1-0/+21
2017-03-02vis-lua: fix bogus URL in LDoc commentMarc André Tanner1-1/+1
2017-03-01vis-lua: fix invalid LDoc tagMarc André Tanner1-1/+1
2017-03-01vis-lua: make cursor.pos return nil if cursor position is invalidMarc André Tanner1-7/+12
It remains to be seen whether that is a good idea, but at least it will reveal possible bugs.
2017-03-01vis-lua: document cursor behaviorMarc André Tanner1-0/+50
2017-02-28vis-lua: correctly treat return value of input event handlerMarc André Tanner1-1/+1
Returning true from the event handler, indicating that the keys were consumed, should now prevent insertion as mentioned in the documentation. vis.events.subscribe(vis.events.INPUT, function(key) if key == ' ' then -- do something fancy here return true end end)