summary refs log tree commit diff stats
path: root/examples/rifle_sxiv.sh
Commit message (Expand)AuthorAgeFilesLines
* Should I dual ranger/cleric or wait for the THAC0 bonus? v1.7.0hut2015-04-141-1/+1
* moved "doc/examples" to "examples" for more visibilityhut2015-04-131-0/+48
* move examples to doc/exampleshut2013-03-091-48/+0
* examples/rifle_sxiv: fix rifle_sxiv with chars like []hut2013-03-091-1/+1
* Fixed the sxiv workaround to handle spaces and be more POSIX compliant.Pierre Neidhardt2013-03-051-7/+21
* Added version info to exampleshut2013-03-011-0/+1
* examples/rifle_sxiv.sh: removed realpath dependencyhut2013-02-181-1/+8
* examples/rifle_sxiv.sh: remove bash dependencyhut2013-02-181-1/+1
* examples/rifle_sxiv.sh: fix symlink handlinghut2012-08-071-1/+1
* added the examples from the man page to the examples directoryhut2012-08-061-0/+26
er Kartik K. Agaram <vc@akkartik.com> 2021-11-06 12:41:14 -0700 refactor menu drawing' href='/akkartik/teliva/commit/src/lcurseslib.c?id=2964a5e74aaf09c0299d38fe756cbc91c018fd99'>2964a5e ^
ef9c420 ^

2b7ffea ^
2964a5e ^

ee85ad3 ^
ef9c420 ^
cab996b ^

2964a5e ^


ee85ad3 ^



40fdaf2 ^


ee85ad3 ^
40fdaf2 ^
ef9c420 ^
cab996b ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
                    
                   

                
 
 
                    
                                          






                                      
                                                         
                     

                           
                            

 
                               
                           

                                


                               



                                     


                                                                
 
                
                            
 
#include <ncurses.h>
#include <string.h>

#include "lua.h"


int menu_column = 0;
void draw_string_on_menu (const char* s) {
  mvaddstr(LINES-1, menu_column, " ");
  ++menu_column;
  mvaddstr(LINES-1, menu_column, s);
  menu_column += strlen(s);
  mvaddstr(LINES-1, menu_column, " ");
  ++menu_column;
}
void draw_menu_item (const char* key, const char* name) {
  attroff(A_REVERSE);
  draw_string_on_menu(key);
  attron(A_REVERSE);
  draw_string_on_menu(name);
}

void draw_menu (lua_State *L) {
  attron(A_BOLD|A_REVERSE);
  for (int x = 0; x < COLS; ++x)
    mvaddch(LINES-1, x, ' ');
  menu_column = 2;
  draw_menu_item("^x", "exit");
  draw_menu_item("^e", "edit");

  /* 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))
      draw_menu_item(lua_tostring(L, -2), lua_tostring(L, -1));

  lua_pop(L, 1);
  attroff(A_BOLD|A_REVERSE);
}