mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-08 13:27:13 +01:00
Allow configurable modes
This commit is contained in:
parent
babaeacbf8
commit
8847f34afe
2 changed files with 41 additions and 32 deletions
27
config.def.h
27
config.def.h
|
@ -63,6 +63,23 @@ int adjust_open = ADJUST_BESTFIT;
|
||||||
#define SELECTION_STYLE POPPLER_SELECTION_GLYPH
|
#define SELECTION_STYLE POPPLER_SELECTION_GLYPH
|
||||||
#define GOTO_MODE GOTO_LABELS /* GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET */
|
#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 */
|
/* shortcuts */
|
||||||
Shortcut shortcuts[] = {
|
Shortcut shortcuts[] = {
|
||||||
/* mask, key, function, mode, argument */
|
/* mask, key, function, mode, argument */
|
||||||
|
@ -289,16 +306,6 @@ ArgumentName argument_names[] = {
|
||||||
{"width", ADJUST_WIDTH},
|
{"width", ADJUST_WIDTH},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* mode names */
|
|
||||||
ModeName mode_names[] = {
|
|
||||||
{"all", ALL},
|
|
||||||
{"fullscreen", FULLSCREEN},
|
|
||||||
{"index", INDEX},
|
|
||||||
{"insert", INSERT},
|
|
||||||
{"normal", NORMAL},
|
|
||||||
{"visual", VISUAL},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* special keys */
|
/* special keys */
|
||||||
GDKKey gdk_keys[] = {
|
GDKKey gdk_keys[] = {
|
||||||
{"<BackSpace>", GDK_BackSpace},
|
{"<BackSpace>", GDK_BackSpace},
|
||||||
|
|
46
zathura.c
46
zathura.c
|
@ -33,9 +33,7 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
|
||||||
#define ALL (1 << 0)
|
#define ALL (1 << 0)
|
||||||
#define FULLSCREEN (1 << 1)
|
#define FULLSCREEN (1 << 1)
|
||||||
#define INDEX (1 << 2)
|
#define INDEX (1 << 2)
|
||||||
#define INSERT (1 << 3)
|
#define NORMAL (1 << 3)
|
||||||
#define NORMAL (1 << 4)
|
|
||||||
#define VISUAL (1 << 5)
|
|
||||||
|
|
||||||
/* typedefs */
|
/* typedefs */
|
||||||
struct CElement
|
struct CElement
|
||||||
|
@ -94,7 +92,8 @@ typedef struct
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
int mode;
|
int mode;
|
||||||
|
char* display;
|
||||||
} ModeName;
|
} ModeName;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -895,26 +894,29 @@ draw(int page_id)
|
||||||
void
|
void
|
||||||
change_mode(int mode)
|
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:
|
switch(mode)
|
||||||
mode_text = "-- INSERT --";
|
{
|
||||||
break;
|
case ADD_MARKER:
|
||||||
case VISUAL:
|
mode_text = "";
|
||||||
mode_text = "-- VISUAL --";
|
break;
|
||||||
break;
|
case EVAL_MARKER:
|
||||||
case ADD_MARKER:
|
mode_text = "";
|
||||||
mode_text = "";
|
break;
|
||||||
break;
|
default:
|
||||||
case EVAL_MARKER:
|
mode_text = "";
|
||||||
mode_text = "";
|
mode = NORMAL;
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
mode_text = "";
|
|
||||||
mode = NORMAL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Zathura.Global.mode = mode;
|
Zathura.Global.mode = mode;
|
||||||
|
|
Loading…
Reference in a new issue