Added zoom buffer command

Now you can adjust the zoom level by typing commands like
"25Z" etc.
This commit is contained in:
Moritz Lipp 2010-01-28 13:57:54 +01:00
parent a7ebea0a10
commit e0f8bdc3b4
3 changed files with 22 additions and 3 deletions

View File

@ -11,7 +11,7 @@ DOBJECTS = ${SOURCE:.c=.do}
all: options ${PROJECT}
options:
@echo ${PROJECT} buld options:
@echo ${PROJECT} build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "DFLAGS = ${DFLAGS}"

View File

@ -107,6 +107,7 @@ BufferCommand buffer_commands[] = {
{"^zI$", bcmd_zoom, { ZOOM_IN } },
{"^zO$", bcmd_zoom, { ZOOM_OUT } },
{"^z0$", bcmd_zoom, { ZOOM_ORIGINAL } },
{"^[0-9]+Z$", bcmd_zoom, { ZOOM_SPECIFIC } },
};
/* special commands */

View File

@ -24,8 +24,8 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN,
BOTTOM, TOP, HIDE, NORMAL, HIGHLIGHT,
INSERT, VISUAL, DELETE_LAST_WORD, DEFAULT,
ERROR, WARNING, NEXT_GROUP, PREVIOUS_GROUP,
ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, FORWARD,
BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH,
ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC,
FORWARD, BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH,
CONTINUOUS };
/* typedefs */
@ -1984,11 +1984,29 @@ bcmd_zoom(char* buffer, Argument* argument)
{
if((Zathura.PDF.scale + ZOOM_STEP) <= ZOOM_MAX)
Zathura.PDF.scale += ZOOM_STEP;
else
Zathura.PDF.scale = ZOOM_MAX;
}
else if(argument->n == ZOOM_OUT)
{
if((Zathura.PDF.scale - ZOOM_STEP) >= ZOOM_MIN)
Zathura.PDF.scale -= ZOOM_STEP;
else
Zathura.PDF.scale = ZOOM_MIN;
}
else if(argument->n == ZOOM_SPECIFIC)
{
int b_length = strlen(buffer);
if(b_length < 1)
return;
int value = atoi(g_strndup(buffer, b_length - 1));
if(value <= ZOOM_MIN)
Zathura.PDF.scale = ZOOM_MIN;
else if(value >= ZOOM_MAX)
Zathura.PDF.scale = ZOOM_MAX;
else
Zathura.PDF.scale = value;
}
else
Zathura.PDF.scale = 100;