diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-21 22:43:38 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-21 22:43:38 +0200 |
| commit | 398f44415c89f478298861c3ff655bdbda716af1 (patch) | |
| tree | 5c143eaec6ac7c088b4b87aae01860232b72987c | |
| parent | d815268ee4c64a5c6134ee43968d0685eaac4d73 (diff) | |
| download | vis-398f44415c89f478298861c3ff655bdbda716af1.tar.gz vis-398f44415c89f478298861c3ff655bdbda716af1.tar.xz | |
vis-lua: allow selection modification by assigning to cursor.selection
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | vis-lua.c | 9 |
2 files changed, 10 insertions, 1 deletions
@@ -617,7 +617,7 @@ At this time there exists no API stability guarantees. - `to(line, col)` - `pos` bytes from start of file (0 based) - `number` one based index of cursor - - `selection` a `range` + - `selection` read/write access to selection represented as a `range` - `range` denoted by absolute postions in bytes from the start of the file, an invalid range is represented as `nil` - `start` @@ -752,6 +752,15 @@ static int window_cursor_newindex(lua_State *L) { view_cursors_to(cur, pos); return 0; } + + if (strcmp(key, "selection") == 0) { + Filerange sel = getrange(L, 3); + if (text_range_valid(&sel)) + view_cursors_selection_set(cur, &sel); + else + view_cursors_selection_clear(cur); + return 0; + } } return newindex_common(L); } |
