diff --git a/config.def.h b/config.def.h index 33969c6..f0a2731 100644 --- a/config.def.h +++ b/config.def.h @@ -63,6 +63,23 @@ int adjust_open = ADJUST_BESTFIT; #define SELECTION_STYLE POPPLER_SELECTION_GLYPH #define GOTO_MODE GOTO_LABELS /* GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET */ +/* define additional modes */ +#define INSERT (1 << 4) +#define VISUAL (1 << 5) +#define EMACS_CX (1 << 6) + +/* mode names */ +ModeName mode_names[] = { + /* default mode names */ + {"all", ALL, ""}, + {"fullscreen", FULLSCREEN, ""}, + {"index", INDEX, ""}, + {"normal", NORMAL, ""}, + /* additional mode names */ + {"insert", INSERT, "-- INSERT --"}, + {"visual", VISUAL, "-- VISUAL --"} +}; + /* shortcuts */ Shortcut shortcuts[] = { /* mask, key, function, mode, argument */ @@ -289,16 +306,6 @@ ArgumentName argument_names[] = { {"width", ADJUST_WIDTH}, }; -/* mode names */ -ModeName mode_names[] = { - {"all", ALL}, - {"fullscreen", FULLSCREEN}, - {"index", INDEX}, - {"insert", INSERT}, - {"normal", NORMAL}, - {"visual", VISUAL}, -}; - /* special keys */ GDKKey gdk_keys[] = { {"", GDK_BackSpace}, diff --git a/zathura.c b/zathura.c index 0bfb241..ba86f6f 100644 --- a/zathura.c +++ b/zathura.c @@ -33,9 +33,7 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, #define ALL (1 << 0) #define FULLSCREEN (1 << 1) #define INDEX (1 << 2) -#define INSERT (1 << 3) -#define NORMAL (1 << 4) -#define VISUAL (1 << 5) +#define NORMAL (1 << 3) /* typedefs */ struct CElement @@ -94,7 +92,8 @@ typedef struct typedef struct { char* name; - int mode; + int mode; + char* display; } ModeName; typedef struct @@ -895,26 +894,29 @@ draw(int page_id) void change_mode(int mode) { - char* mode_text; + char* mode_text = 0; + for(unsigned int i = 0; i != LENGTH(mode_names); ++i) + if(mode_names[i].mode == mode) + { + mode_text = mode_names[i].display; + break; + } - switch(mode) + if(!mode_text) { - case INSERT: - mode_text = "-- INSERT --"; - break; - case VISUAL: - mode_text = "-- VISUAL --"; - break; - case ADD_MARKER: - mode_text = ""; - break; - case EVAL_MARKER: - mode_text = ""; - break; - default: - mode_text = ""; - mode = NORMAL; - break; + switch(mode) + { + case ADD_MARKER: + mode_text = ""; + break; + case EVAL_MARKER: + mode_text = ""; + break; + default: + mode_text = ""; + mode = NORMAL; + break; + } } Zathura.Global.mode = mode;