summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2011-09-04 04:08:29 +0200
committerSebastian Rasmussen <sebras@gmail.com>2011-09-04 12:35:13 +0200
commitf6b4b3586cef63c68cc3a436ffdf32edb8f144cf (patch)
tree333dd6320d4e538af8388eaf178df1d608c75bad
parent1e96e8e23581dc44e04d5133891f477bc9a6c5d6 (diff)
downloadmupdf-f6b4b3586cef63c68cc3a436ffdf32edb8f144cf.tar.xz
Repaint only viewer search area when editing search string.
-rw-r--r--apps/pdfapp.c19
-rw-r--r--apps/pdfapp.h1
-rw-r--r--apps/win_main.c26
-rw-r--r--apps/x11_main.c53
4 files changed, 66 insertions, 33 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index e139e06e..a30e7a4c 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -587,6 +587,7 @@ static void pdfapp_searchforward(pdfapp_t *app, enum panning *panto)
app->hit = test;
app->hitlen = matchlen;
wincursor(app, HAND);
+ winrepaint(app);
return;
}
test++;
@@ -602,7 +603,10 @@ static void pdfapp_searchforward(pdfapp_t *app, enum panning *panto)
} while (app->pageno != startpage);
if (app->pageno == startpage)
+ {
pdfapp_warn(app, "String '%s' not found.", app->search);
+ winrepaintsearch(app);
+ }
else
winrepaint(app);
@@ -637,6 +641,7 @@ static void pdfapp_searchbackward(pdfapp_t *app, enum panning *panto)
app->hit = test;
app->hitlen = matchlen;
wincursor(app, HAND);
+ winrepaint(app);
return;
}
test--;
@@ -652,7 +657,10 @@ static void pdfapp_searchbackward(pdfapp_t *app, enum panning *panto)
} while (app->pageno != startpage);
if (app->pageno == startpage)
+ {
pdfapp_warn(app, "String '%s' not found.", app->search);
+ winrepaintsearch(app);
+ }
else
winrepaint(app);
@@ -682,13 +690,20 @@ void pdfapp_onkey(pdfapp_t *app, int c)
if (c < ' ')
{
if (c == '\b' && n > 0)
+ {
app->search[n - 1] = 0;
+ winrepaintsearch(app);
+ }
if (c == '\n' || c == '\r')
{
app->isediting = 0;
- winrepaint(app);
if (n > 0)
+ {
+ winrepaintsearch(app);
pdfapp_onkey(app, 'n');
+ }
+ else
+ winrepaint(app);
}
if (c == '\033')
{
@@ -702,6 +717,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
{
app->search[n] = c;
app->search[n + 1] = 0;
+ winrepaintsearch(app);
}
}
return;
@@ -914,6 +930,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
app->search[0] = 0;
app->hit = -1;
app->hitlen = 0;
+ winrepaintsearch(app);
break;
case 'n':
diff --git a/apps/pdfapp.h b/apps/pdfapp.h
index 23f66658..732d637c 100644
--- a/apps/pdfapp.h
+++ b/apps/pdfapp.h
@@ -16,6 +16,7 @@ extern void winerror(pdfapp_t*, fz_error error);
extern void wintitle(pdfapp_t*, char *title);
extern void winresize(pdfapp_t*, int w, int h);
extern void winrepaint(pdfapp_t*);
+extern void winrepaintsearch(pdfapp_t*);
extern char *winpassword(pdfapp_t*, char *filename);
extern void winopenuri(pdfapp_t*, char *s);
extern void wincursor(pdfapp_t*, int curs);
diff --git a/apps/win_main.c b/apps/win_main.c
index fc772aa7..da97b011 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -463,6 +463,17 @@ void windrawstring(pdfapp_t *app, int x, int y, char *s)
TextOutA(hdc, x, y - 12, s, strlen(s));
}
+void winblitsearch()
+{
+ if (gapp.isediting)
+ {
+ char buf[sizeof(gapp.search) + 50];
+ sprintf(buf, "Search: %s", gapp.search);
+ windrawrect(&gapp, 0, 0, gapp.winw, 30);
+ windrawstring(&gapp, 10, 20, buf);
+ }
+}
+
void winblit()
{
int x0 = gapp.panx;
@@ -544,13 +555,7 @@ void winblit()
r.bottom = y1;
FillRect(hdc, &r, shbrush);
- if (gapp.isediting)
- {
- char buf[sizeof(gapp.search) + 50];
- sprintf(buf, "Search: %s", gapp.search);
- windrawrect(&gapp, 0, 0, gapp.winw, 30);
- windrawstring(&gapp, 10, 20, buf);
- }
+ winblitsearch();
}
void winresize(pdfapp_t *app, int w, int h)
@@ -567,6 +572,13 @@ void winrepaint(pdfapp_t *app)
InvalidateRect(hwndview, NULL, 0);
}
+void winrepaintsearch(pdfapp_t *app)
+{
+ // TODO: invalidate only search area and
+ // call only search redraw routine.
+ InvalidateRect(hwndview, NULL, 0);
+}
+
/*
* Event handling
*/
diff --git a/apps/x11_main.c b/apps/x11_main.c
index 1d18d0d5..d62c63d6 100644
--- a/apps/x11_main.c
+++ b/apps/x11_main.c
@@ -75,6 +75,7 @@ static int mapped = 0;
static Cursor xcarrow, xchand, xcwait;
static int justcopied = 0;
static int dirty = 0;
+static int dirtysearch = 0;
static char *password = "";
static XColor xbgcolor;
static XColor xshcolor;
@@ -276,6 +277,18 @@ static void fillrect(int x, int y, int w, int h)
XFillRectangle(xdpy, xwin, xgc, x, y, w, h);
}
+static void winblitsearch(pdfapp_t *app)
+{
+ if (gapp.isediting)
+ {
+ char buf[sizeof(gapp.search) + 50];
+ sprintf(buf, "Search: %s", gapp.search);
+ XSetForeground(xdpy, xgc, WhitePixel(xdpy, xscr));
+ fillrect(0, 0, gapp.winw, 30);
+ windrawstring(&gapp, 10, 20, buf);
+ }
+}
+
static void winblit(pdfapp_t *app)
{
int x0 = gapp.panx;
@@ -342,14 +355,7 @@ static void winblit(pdfapp_t *app)
justcopied = 1;
}
- if (gapp.isediting)
- {
- char buf[sizeof(gapp.search) + 50];
- sprintf(buf, "Search: %s", gapp.search);
- XSetForeground(xdpy, xgc, WhitePixel(xdpy, xscr));
- fillrect(0, 0, gapp.winw, 30);
- windrawstring(&gapp, 10, 20, buf);
- }
+ winblitsearch(app);
}
void winrepaint(pdfapp_t *app)
@@ -357,6 +363,11 @@ void winrepaint(pdfapp_t *app)
dirty = 1;
}
+void winrepaintsearch(pdfapp_t *app)
+{
+ dirtysearch = 1;
+}
+
void windrawstringxor(pdfapp_t *app, int x, int y, char *s)
{
int prevfunction;
@@ -636,21 +647,6 @@ int main(int argc, char **argv)
onmouse(oldx, oldy, 0, 0, 0);
- if (dirty)
- {
- winblit(&gapp);
- dirty = 0;
- }
-
- if (gapp.isediting)
- {
- char str[sizeof(gapp.search) + 50];
- sprintf(str, "Search: %s", gapp.search);
- XSetForeground(xdpy, xgc, WhitePixel(xdpy, xscr));
- fillrect(0, 0, gapp.winw, 30);
- windrawstring(&gapp, 10, 20, str);
- }
-
break;
case MotionNotify:
@@ -684,10 +680,17 @@ int main(int argc, char **argv)
}
while (!closing && XPending(xdpy));
- if (!closing && dirty)
+ if (closing)
+ continue;
+
+ if (dirty || dirtysearch)
{
- winblit(&gapp);
+ if (dirty)
+ winblit(&gapp);
+ else if (dirtysearch)
+ winblitsearch(&gapp);
dirty = 0;
+ dirtysearch = 0;
}
}