ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/root-tail/root-tail.c
(Generate patch)

Comparing root-tail/root-tail.c (file contents):
Revision 1.21 by pcg, Sat Mar 27 20:54:33 2004 UTC vs.
Revision 1.22 by pcg, Sat Mar 27 21:12:22 2004 UTC

66 66
67/* global variables */ 67/* global variables */
68struct linematrix *lines; 68struct linematrix *lines;
69int width = STD_WIDTH, height = STD_HEIGHT, listlen; 69int width = STD_WIDTH, height = STD_HEIGHT, listlen;
70int win_x = LOC_X, win_y = LOC_Y; 70int win_x = LOC_X, win_y = LOC_Y;
71int font_descent, font_height; 71int font_ascent, font_height;
72int do_reopen; 72int do_reopen;
73struct timeval interval = { 2, 400000 }; 73struct timeval interval = { 2, 400000 };
74XFontSet fontset; 74XFontSet fontset;
75 75
76/* command line options */ 76/* command line options */
77int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, 77int 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;
79const char *command = NULL, 79const 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
83struct logfile_entry *loglist = NULL, *loglist_tail = NULL; 83struct logfile_entry *loglist = NULL, *loglist_tail = NULL;
104void blank_window (int); 104void blank_window (int);
105 105
106void InitWindow (void); 106void InitWindow (void);
107unsigned long GetColor (const char *); 107unsigned long GetColor (const char *);
108void redraw (void); 108void redraw (void);
109void refresh (int, int); 109void refresh (int, int, int);
110 110
111void transform_line (char *s); 111void transform_line (char *s);
112int lineinput (struct logfile_entry *); 112int lineinput (struct logfile_entry *);
113void reopen (void); 113void reopen (void);
114void check_open_files (void); 114void 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 */
317void 317void
318redraw (void) 318redraw (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) */
326void 325void
327refresh (int miny, int maxy) 326refresh (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"))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines