… | |
… | |
66 | |
66 | |
67 | /* global variables */ |
67 | /* global variables */ |
68 | struct linematrix *lines; |
68 | struct linematrix *lines; |
69 | int width = STD_WIDTH, height = STD_HEIGHT, listlen; |
69 | int width = STD_WIDTH, height = STD_HEIGHT, listlen; |
70 | int win_x = LOC_X, win_y = LOC_Y; |
70 | int win_x = LOC_X, win_y = LOC_Y; |
71 | int font_descent, font_height; |
71 | int font_ascent, font_height; |
72 | int do_reopen; |
72 | int do_reopen; |
73 | struct timeval interval = { 2, 400000 }; |
73 | struct timeval interval = { 2, 400000 }; |
74 | XFontSet fontset; |
74 | XFontSet fontset; |
75 | |
75 | |
76 | /* command line options */ |
76 | /* command line options */ |
77 | int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
77 | int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
78 | opt_outline, opt_whole, opt_update, geom_mask, reload = 0; |
78 | opt_outline, opt_noflicker, opt_whole, opt_update, geom_mask, reload = 0; |
79 | const char *command = NULL, |
79 | const char *command = NULL, |
80 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
80 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
81 | *continuation = "[+]"; |
81 | *continuation = "[+]"; |
82 | |
82 | |
83 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
83 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
… | |
… | |
104 | void blank_window (int); |
104 | void blank_window (int); |
105 | |
105 | |
106 | void InitWindow (void); |
106 | void InitWindow (void); |
107 | unsigned long GetColor (const char *); |
107 | unsigned long GetColor (const char *); |
108 | void redraw (void); |
108 | void redraw (void); |
109 | void refresh (int, int); |
109 | void refresh (int, int, int); |
110 | |
110 | |
111 | void transform_line (char *s); |
111 | void transform_line (char *s); |
112 | int lineinput (struct logfile_entry *); |
112 | int lineinput (struct logfile_entry *); |
113 | void reopen (void); |
113 | void reopen (void); |
114 | void check_open_files (void); |
114 | void check_open_files (void); |
… | |
… | |
285 | |
285 | |
286 | { |
286 | { |
287 | XFontSetExtents *xfe = XExtentsOfFontSet (fontset); |
287 | XFontSetExtents *xfe = XExtentsOfFontSet (fontset); |
288 | |
288 | |
289 | font_height = xfe->max_logical_extent.height; |
289 | font_height = xfe->max_logical_extent.height; |
290 | font_descent = xfe->max_logical_extent.y; |
290 | font_ascent = -xfe->max_logical_extent.y; |
291 | } |
291 | } |
292 | |
292 | |
293 | if (geom_mask & XNegative) |
293 | if (geom_mask & XNegative) |
294 | win_x = win_x + ScreenWidth - width; |
294 | win_x = win_x + ScreenWidth - width; |
295 | if (geom_mask & YNegative) |
295 | if (geom_mask & YNegative) |
… | |
… | |
316 | */ |
316 | */ |
317 | void |
317 | void |
318 | redraw (void) |
318 | redraw (void) |
319 | { |
319 | { |
320 | XSetClipMask (disp, WinGC, None); |
320 | XSetClipMask (disp, WinGC, None); |
321 | XClearArea (disp, root, win_x - 2, win_y - 2, width + 5, height + 5, False); |
|
|
322 | refresh (0, 32768); |
321 | refresh (0, 32768, 1); |
323 | } |
322 | } |
324 | |
323 | |
325 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
324 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
326 | void |
325 | void |
327 | refresh (int miny, int maxy) |
326 | refresh (int miny, int maxy, int clear) |
328 | { |
327 | { |
329 | int lin; |
328 | int lin; |
330 | int offset = (listlen + 1) * font_height; |
329 | int offset = (listlen + 1) * font_height; |
331 | unsigned long black_color = GetColor ("black"); |
330 | unsigned long black_color = GetColor ("black"); |
332 | |
331 | |
333 | miny -= win_y + font_height; |
332 | miny -= win_y + font_height; |
334 | maxy -= win_y - font_height; |
333 | maxy -= win_y - font_height; |
335 | |
334 | |
|
|
335 | if (clear && !opt_noflicker) |
|
|
336 | XClearArea (disp, root, win_x, win_y, width, height, False); |
|
|
337 | |
336 | for (lin = listlen; lin--;) |
338 | for (lin = listlen; lin--;) |
337 | { |
339 | { |
338 | struct linematrix *line = lines + (opt_reverse ? listlen - lin - 1 : lin); |
340 | struct linematrix *line = lines + (opt_reverse ? listlen - lin - 1 : lin); |
339 | |
341 | |
340 | offset -= font_height; |
342 | offset -= font_height; |
341 | |
343 | |
342 | if (offset < miny || offset > maxy) |
344 | if (offset < miny || offset > maxy) |
343 | continue; |
345 | continue; |
|
|
346 | |
|
|
347 | if (clear && opt_noflicker) |
|
|
348 | XClearArea (disp, root, win_x, win_y + offset - font_ascent, width, font_height, False); |
344 | |
349 | |
345 | if (opt_outline) |
350 | if (opt_outline) |
346 | { |
351 | { |
347 | XSetForeground (disp, WinGC, black_color); |
352 | XSetForeground (disp, WinGC, black_color); |
348 | XmbDrawString (disp, root, fontset, WinGC, win_x - 1, |
353 | XmbDrawString (disp, root, fontset, WinGC, win_x - 1, |
… | |
… | |
807 | XRectangle r; |
812 | XRectangle r; |
808 | |
813 | |
809 | XSetRegion (disp, WinGC, region); |
814 | XSetRegion (disp, WinGC, region); |
810 | XClipBox (region, &r); |
815 | XClipBox (region, &r); |
811 | |
816 | |
812 | refresh (r.y, r.y + r.height); |
817 | refresh (r.y, r.y + r.height, 0); |
813 | |
818 | |
814 | XDestroyRegion (region); |
819 | XDestroyRegion (region); |
815 | region = XCreateRegion (); |
820 | region = XCreateRegion (); |
816 | } |
821 | } |
817 | } |
822 | } |
… | |
… | |
871 | } |
876 | } |
872 | else if (!strcmp (arg, "-shade")) |
877 | else if (!strcmp (arg, "-shade")) |
873 | opt_shade = 1; |
878 | opt_shade = 1; |
874 | else if (!strcmp (arg, "-outline")) |
879 | else if (!strcmp (arg, "-outline")) |
875 | opt_outline = 1; |
880 | opt_outline = 1; |
|
|
881 | else if (!strcmp (arg, "-noflicker")) |
|
|
882 | opt_noflicker = 1; |
876 | else if (!strcmp (arg, "-frame")) |
883 | else if (!strcmp (arg, "-frame")) |
877 | opt_frame = 1; |
884 | opt_frame = 1; |
878 | else if (!strcmp (arg, "-no-filename")) |
885 | else if (!strcmp (arg, "-no-filename")) |
879 | opt_nofilename = 1; |
886 | opt_nofilename = 1; |
880 | else if (!strcmp (arg, "-reverse")) |
887 | else if (!strcmp (arg, "-reverse")) |