| Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
These values are useful for calculating terminal positions.
|
|
This allows better control over styling, as well as potential for
entirely new UI elements implemented entirely using the Lua API.
|
|
|
|
This will break all plugins which currently use Win.viewport.
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
|
|
`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
|
|
I thought I fixed these in the applied patch but I guess they slipped by
|
|
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.
|
|
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
|
|
The only place where this behaviour was encountered was in
file_lines_iterator() and it was just being worked around.
|
|
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
|
|
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).
|
|
|
|
|
|
|
|
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
|
|
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)
|
|
These are the permission bits of struct stat's st_mode field at the
time of the most recent load/save.
Close #861
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We fake a modification by doing an insertion followed by a deletion
which does not actually change the buffer content.
Close #855
|
|
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
Fix #695
|
|
|
|
|
|
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 '/').
|