pane

Termbox2 based terminal UI library
git clone git://git.dimitrijedobrota.com/pane.git
Log | Files | Refs

main.c (1626B)


      1 #define TB_IMPL
      2 #define TB_OPT_TRUECOLOR
      3 
      4 #include <stdio.h>
      5 
      6 #include "pane.h"
      7 #include "utils.h"
      8 #include "menu.h"
      9 
     10 void quit(char *pass, int index)
     11 {
     12 	pane_stop();
     13 	UNIMPLEMENTED;
     14 }
     15 
     16 struct menu_T mainMenu = {
     17 	.items = {
     18 	{ quit, "Start" },
     19 	{ quit, "Help" },
     20 	{ quit, "Exit" },
     21 	{ quit, "Start" },
     22 	{ quit, "Help" },
     23 	{ quit, "Exit" },
     24 	{ quit, "Start" },
     25 	{ quit, "Help" },
     26 	{ quit, "Exit" },
     27 	},
     28 	.items_size = 9,
     29 	.current = 0,
     30 };
     31 
     32 struct menuStyle_T mainMenuStyle = {
     33 	.separator = "<------------->",
     34 	.padding = 1,
     35 	.spacing = 1,
     36 };
     37 
     38 struct menuStyle_T mainMenuStyle2 = {
     39 	.separator = "***************",
     40 	.padding = 0,
     41 	.spacing = 0,
     42 };
     43 
     44 struct menuInfo_T mainMenuInfo;
     45 
     46 struct widget_T mainMenu_widget = {
     47 	.pane = NULL,
     48 	.callback = pane_menu,
     49 	.title = "Main Menu",
     50 	.style = &mainMenuStyle,
     51 	.info = &mainMenuInfo,
     52 };
     53 
     54 struct menuInfo_T mainMenuInfo2;
     55 
     56 struct widget_T mainMenu_widget2 = {
     57 	.pane = NULL,
     58 	.inited = 0,
     59 	.resized = 0,
     60 	.callback = pane_menu,
     61 	.title = "Main Menu 2",
     62 	.style = &mainMenuStyle2,
     63 	.info = &mainMenuInfo2,
     64 };
     65 
     66 int main(int argc, char **argv)
     67 {
     68 	pane_start(0);
     69 	{
     70 		Pane_T *sections, *mids, *bots;
     71 
     72 		sections = pane_vsplit(MAIN, 3, 1, 1, 1);
     73 		mids = pane_split(sections[1], 2, 1, 2);
     74 		bots = pane_split(sections[2], 2, 1, 1);
     75 
     76 		pane_vsplit(mids[0], 2, 1, 1);
     77 
     78 		data_T mainMenu_payload = data_new(&mainMenu, menu_hadleInput);
     79 		widget_setData(&mainMenu_widget, mainMenu_payload);
     80 		widget_setData(&mainMenu_widget2, mainMenu_payload);
     81 		widget_activate(&mainMenu_widget, mids[1]);
     82 		widget_activate(&mainMenu_widget2, bots[1]);
     83 		pane_event_loop();
     84 	}
     85 	pane_stop();
     86 	return 0;
     87 }