Begin re-write of basic display functions in scheme
[texed.git] / display.c
blob931430360b34d91f5ebd70a0b77ea01dd4e88892
2 #include "display.h"
4 void display_init ()
6 initscr();
7 raw();
8 noecho();
9 keypad(stdscr, TRUE);
11 refresh();
12 main_window = newwin(LINES - 1, COLS, 0, 0);
13 wrefresh(main_window);
14 minibuf = newwin(1, COLS, LINES - 1, 0);
15 wrefresh(minibuf);
16 refresh();
19 void minibuf_echo (char* string)
21 wclear(minibuf);
22 wprintw(minibuf, string);
23 /* wrefresh(minibuf); */
26 void minibuf_clear ()
28 wclear(minibuf);
29 /* wrefresh(minibuf); */
32 void display_render (buffer_t contents, int state)
34 wclear(main_window);
35 wclear(minibuf);
36 wprintw(main_window, buffer_to_string(contents));
37 wprintw(minibuf, "%d:%d ",
38 contents.cursor.y, contents.cursor.x);
39 switch (state)
41 case NORMAL_STATE:
42 wprintw(minibuf, "<N>\n");
43 break;
44 case INSERT_STATE:
45 wprintw(minibuf, "<I>\n");
46 break;
48 /* wmove(main_window, contents.cursor.y, contents.cursor.x); */
49 move(contents.cursor.y, contents.cursor.x);
50 wrefresh(main_window);
51 wrefresh(minibuf);
52 /* refresh(); */
55 void cursor_move_handler (buffer_t* current, int key)
57 switch (key)
59 case 'k': buffer_up(current);
60 break;
61 case 'j': buffer_down(current);
62 break;
63 case 'h': buffer_left(current);
64 break;
65 case 'l': buffer_right(current);
66 break;