more precise control over menu order
I can't believe I didn't notice this until now.
This commit is contained in:
parent
c537e7bc2d
commit
343316dcfa
|
@ -37,7 +37,9 @@
|
|||
__teliva_note: foo
|
||||
- __teliva_timestamp: original
|
||||
menu:
|
||||
>menu = {Enter="increment"}
|
||||
>menu = {
|
||||
> {"Enter", "increment"}
|
||||
>}
|
||||
- __teliva_timestamp: original
|
||||
update:
|
||||
>function update(window)
|
||||
|
|
11
gemini.tlv
11
gemini.tlv
|
@ -234,11 +234,12 @@
|
|||
>end
|
||||
- __teliva_timestamp: original
|
||||
menu:
|
||||
>menu = {}
|
||||
>menu['enter'] = 'go to highlight'
|
||||
>menu['←'] = 'back'
|
||||
>menu['^g'] = 'enter url'
|
||||
>menu['^u'] = 'view source'
|
||||
>menu = {
|
||||
> {'Enter', 'go to highlight'},
|
||||
> {'<-', 'back'},
|
||||
> {'^g', 'enter url'},
|
||||
> {'^u', 'view source'},
|
||||
>}
|
||||
- __teliva_timestamp: original
|
||||
edit_line:
|
||||
>function edit_line(window)
|
||||
|
|
2
life.tlv
2
life.tlv
|
@ -194,7 +194,7 @@
|
|||
>end
|
||||
- __teliva_timestamp: original
|
||||
update:
|
||||
>menu = {arrow="pan"}
|
||||
>menu = {{"arrow", "pan"}}
|
||||
>
|
||||
>function update(window, c)
|
||||
> if c == curses.KEY_LEFT then
|
||||
|
|
12
src/menu.c
12
src/menu.c
|
@ -2,6 +2,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "teliva.h"
|
||||
|
||||
|
||||
|
@ -32,9 +33,16 @@ void draw_menu (lua_State *L) {
|
|||
/* render any app-specific items */
|
||||
lua_getglobal(L, "menu");
|
||||
int table = lua_gettop(L);
|
||||
if (lua_istable(L, -1))
|
||||
for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1))
|
||||
if (lua_istable(L, -1)) {
|
||||
for (int i = 1; i <= luaL_getn(L, table); ++i) {
|
||||
lua_rawgeti(L, table, i);
|
||||
int menu_item = lua_gettop(L);
|
||||
lua_rawgeti(L, menu_item, 1); /* key */
|
||||
lua_rawgeti(L, menu_item, 2); /* value */
|
||||
draw_menu_item(lua_tostring(L, -2), lua_tostring(L, -1));
|
||||
lua_pop(L, 3);
|
||||
}
|
||||
}
|
||||
|
||||
lua_pop(L, 1);
|
||||
attrset(A_NORMAL);
|
||||
|
|
|
@ -165,6 +165,8 @@
|
|||
>end
|
||||
- __teliva_timestamp: original
|
||||
menu:
|
||||
>-- To show app-specific hotkeys in the menu bar, add hotkey/command
|
||||
>-- arrays of strings to the menu array.
|
||||
>menu = {}
|
||||
- __teliva_timestamp: original
|
||||
update:
|
||||
|
|
|
@ -165,9 +165,10 @@
|
|||
>end
|
||||
- __teliva_timestamp: original
|
||||
menu:
|
||||
>menu = {}
|
||||
>menu['^u'] = 'clear'
|
||||
>menu['^w'] = "write prose to file 'toot' (edit does NOT save)"
|
||||
>menu = {
|
||||
> {'^u', 'clear'},
|
||||
> {'^w', 'write prose to file "toot" (edit hotkey does NOT save)'},
|
||||
>}
|
||||
- __teliva_timestamp: original
|
||||
update:
|
||||
>function update(window)
|
||||
|
|
Loading…
Reference in New Issue
Block a user