add view command
This commit is contained in:
14
main.c
14
main.c
@@ -17,13 +17,14 @@
|
|||||||
#define COMPLETED_PAIR 3
|
#define COMPLETED_PAIR 3
|
||||||
|
|
||||||
#include "3rd-party/stb-ds.h"
|
#include "3rd-party/stb-ds.h"
|
||||||
#define KEY_BINDINGS " [a]dd [m]ark [d]elete [w]rite [l]oad [q]uit"
|
#define KEY_BINDINGS " [a]dd [v]view [m]ark [d]elete [w]rite [l]oad [q]uit"
|
||||||
|
|
||||||
char SAVE_FILE[MAX_PATH_LENGTH] = "";
|
char SAVE_FILE[MAX_PATH_LENGTH] = "";
|
||||||
TodoItem *todos = NULL;
|
TodoItem *todos = NULL;
|
||||||
|
|
||||||
enum Command {
|
enum Command {
|
||||||
ADD = 'a',
|
ADD = 'a',
|
||||||
|
VIEW = 'v',
|
||||||
MARK = 'm',
|
MARK = 'm',
|
||||||
REMOVE = 'd',
|
REMOVE = 'd',
|
||||||
QUIT = 'q',
|
QUIT = 'q',
|
||||||
@@ -227,6 +228,12 @@ void add_command_handler(int width, int height) {
|
|||||||
arrput(todos, item);
|
arrput(todos, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_command_handler(int width, int index) {
|
||||||
|
TodoItem item = todos[index];
|
||||||
|
// create an alert in the middle of the screen
|
||||||
|
alert(item.title, width, 24);
|
||||||
|
}
|
||||||
|
|
||||||
void mark_command_handler(int index) {
|
void mark_command_handler(int index) {
|
||||||
TodoItem item = todos[index];
|
TodoItem item = todos[index];
|
||||||
|
|
||||||
@@ -354,6 +361,9 @@ int main(int argc, char **argv) {
|
|||||||
case ADD:
|
case ADD:
|
||||||
add_command_handler(terminal_width, terminal_height);
|
add_command_handler(terminal_width, terminal_height);
|
||||||
break;
|
break;
|
||||||
|
case VIEW:
|
||||||
|
view_command_handler(terminal_width, current_line);
|
||||||
|
break;
|
||||||
case MARK:
|
case MARK:
|
||||||
case SPACE:
|
case SPACE:
|
||||||
mark_command_handler(current_line);
|
mark_command_handler(current_line);
|
||||||
@@ -386,7 +396,5 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user