1 | /* |
1 | /* |
2 | * Copyright 2001 by Marco d'Itri <md@linux.it> |
2 | * Copyright 2001 by Marco d'Itri <md@linux.it> |
3 | * Copyright 2000,2001,2002,2003,2004 |
3 | * Copyright 2000,2001,2002,2003,2004 |
4 | * Marc Lehmann <pcg@goof.com>, |
4 | * Marc Lehmann <pcg@goof.com>, |
|
|
5 | * Chris Moore <chris.moore@mail.com>, |
5 | * and many others, see README |
6 | * and many others, see README |
6 | * |
7 | * |
7 | * Original version by Mike Baker. |
8 | * Original version by Mike Baker. |
8 | * |
9 | * |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
11 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
20 | * along with this program; if not, write to the Free Software |
21 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include "config.h" |
25 | #include "config.h" |
|
|
26 | #include <assert.h> |
25 | #include <stdlib.h> |
27 | #include <stdlib.h> |
26 | #include <stdio.h> |
28 | #include <stdio.h> |
27 | #include <unistd.h> |
29 | #include <unistd.h> |
28 | #include <string.h> |
30 | #include <string.h> |
29 | #include <signal.h> |
31 | #include <signal.h> |
… | |
… | |
45 | #endif |
47 | #endif |
46 | |
48 | |
47 | #define SHADE_X 2 |
49 | #define SHADE_X 2 |
48 | #define SHADE_Y 2 |
50 | #define SHADE_Y 2 |
49 | |
51 | |
|
|
52 | /* some italic fonts still go over the margin - this margin of error cleans up the mess */ |
|
|
53 | #define MARGIN_OF_ERROR 2 |
|
|
54 | |
50 | /* data structures */ |
55 | /* data structures */ |
51 | struct logfile_entry |
56 | struct logfile_entry |
52 | { |
57 | { |
53 | struct logfile_entry *next; |
58 | struct logfile_entry *next; |
54 | |
59 | |
55 | char *fname; /* name of file */ |
60 | char *fname; /* name of file */ |
56 | char *desc; /* alternative description */ |
61 | char *desc; /* alternative description */ |
57 | char *buf; /* text read but not yet displayed */ |
62 | char *buf; /* text read but not yet displayed */ |
|
|
63 | const char *fontname; |
|
|
64 | XFontSet fontset; |
|
|
65 | int font_height; |
|
|
66 | int font_ascent; |
58 | FILE *fp; /* FILE struct associated with file */ |
67 | FILE *fp; /* FILE struct associated with file */ |
59 | ino_t inode; /* inode of the file opened */ |
68 | ino_t inode; /* inode of the file opened */ |
60 | off_t last_size; /* file size at the last check */ |
69 | off_t last_size; /* file size at the last check */ |
61 | unsigned long color; /* color to be used for printing */ |
70 | unsigned long color; /* color to be used for printing */ |
62 | int partial; /* true if the last line isn't complete */ |
71 | int partial; /* true if the last line isn't complete */ |
63 | int lastpartial; /* true if the previous output wasn't complete */ |
72 | int lastpartial; /* true if the previous output wasn't complete */ |
64 | int index; /* index into linematrix of a partial line */ |
73 | struct line_node *last; /* last line we output */ |
65 | int modified; /* true if line is modified & needs displaying */ |
74 | int modified; /* true if line is modified & needs displaying */ |
66 | }; |
75 | }; |
67 | |
76 | |
|
|
77 | struct line_node |
|
|
78 | { |
|
|
79 | struct line_node *next; |
|
|
80 | struct line_node *prev; |
|
|
81 | struct logfile_entry *logfile; |
|
|
82 | |
|
|
83 | char *line; /* the text of the line (so far) */ |
|
|
84 | int len; /* the length of the line (in bytes) so far */ |
|
|
85 | int wrapped_left; /* true if wrapped from the previous line */ |
|
|
86 | int wrapped_right; /* true if wrapped to the next line */ |
|
|
87 | struct breakinfo *breaks; /* array of indicies to spaces if wrapped_right */ |
|
|
88 | int num_words; /* the number of words in the line */ |
|
|
89 | int free_pixels; /* the number of free pixels to spread out */ |
|
|
90 | }; |
|
|
91 | |
|
|
92 | struct breakinfo |
|
|
93 | { |
|
|
94 | int index; /* index into string of start of substring */ |
|
|
95 | int width; /* width in pixels of start of substring */ |
|
|
96 | int len; /* length of substring */ |
|
|
97 | }; |
|
|
98 | |
68 | struct linematrix |
99 | struct displaymatrix |
69 | { |
100 | { |
70 | char *line; |
101 | char *line; |
71 | int len; |
102 | int len; |
72 | unsigned long color; |
103 | int offset; |
73 | }; |
|
|
74 | |
|
|
75 | struct displaymatrix |
|
|
76 | { |
|
|
77 | char *line; |
|
|
78 | int len; |
|
|
79 | int buffer_size; |
104 | int buffer_size; |
80 | unsigned long color; |
105 | unsigned long color; |
81 | }; |
106 | }; |
82 | |
107 | |
83 | /* global variables */ |
108 | /* global variables */ |
84 | struct linematrix *lines; |
109 | struct line_node *linelist = NULL, *linelist_tail = NULL; |
85 | struct displaymatrix *display; |
110 | struct displaymatrix *display; |
|
|
111 | int continuation_width = -1; |
|
|
112 | int continuation_color; |
|
|
113 | int continuation_length; |
|
|
114 | |
|
|
115 | /* HACK - ideally listlen will start at however many '~'s will fit on |
|
|
116 | * the screen */ |
86 | int width = STD_WIDTH, height = STD_HEIGHT, listlen; |
117 | int width = STD_WIDTH, height = STD_HEIGHT, listlen = 50; |
87 | int win_x = LOC_X, win_y = LOC_Y; |
118 | int win_x = LOC_X, win_y = LOC_Y; |
88 | int font_ascent, font_height; |
|
|
89 | int effect_x_space, effect_y_space; /* how much space does shading / outlining take up */ |
119 | int effect_x_space, effect_y_space; /* how much space does shading / outlining take up */ |
90 | int effect_x_offset, effect_y_offset; /* and how does it offset the usable space */ |
120 | int effect_x_offset, effect_y_offset; /* and how does it offset the usable space */ |
91 | int do_reopen; |
121 | int do_reopen; |
92 | struct timeval interval = { 2, 400000 }; |
122 | struct timeval interval = { 2, 400000 }; |
93 | XFontSet fontset; |
|
|
94 | |
123 | |
95 | /* command line options */ |
124 | /* command line options */ |
96 | int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
125 | int opt_noinitial, opt_shade, opt_frame, opt_reverse, opt_nofilename, |
97 | opt_outline, opt_noflicker, opt_whole, opt_update, opt_wordwrap, |
126 | opt_outline, opt_noflicker, opt_whole, opt_update, opt_wordwrap, |
98 | geom_mask, reload = 0; |
127 | opt_justify, geom_mask, reload = 0; |
99 | const char *command = NULL, |
128 | const char *command = NULL, |
100 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
129 | *fontname = USE_FONT, *dispname = NULL, *def_color = DEF_COLOR, |
101 | *continuation = "[+]"; |
130 | *continuation = "|| ", *cont_color = DEF_CONT_COLOR; |
102 | |
131 | |
103 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
132 | struct logfile_entry *loglist = NULL, *loglist_tail = NULL; |
104 | |
133 | |
105 | Display *disp; |
134 | Display *disp; |
106 | Window root; |
135 | Window root; |
… | |
… | |
169 | } |
198 | } |
170 | |
199 | |
171 | void |
200 | void |
172 | blank_window (int dummy) |
201 | blank_window (int dummy) |
173 | { |
202 | { |
174 | XClearArea (disp, root, win_x - 2, win_y - 2, width + 5, height + 5, False); |
203 | XClearArea (disp, root, win_x, win_y, width + MARGIN_OF_ERROR, height, False); |
175 | XFlush (disp); |
204 | XFlush (disp); |
176 | exit (0); |
205 | exit (0); |
177 | } |
206 | } |
178 | |
207 | |
179 | /* X related functions */ |
208 | /* X related functions */ |
… | |
… | |
206 | if (SWM_VROOT != None) |
235 | if (SWM_VROOT != None) |
207 | { |
236 | { |
208 | Window unused, *windows; |
237 | Window unused, *windows; |
209 | unsigned int count; |
238 | unsigned int count; |
210 | |
239 | |
211 | if (XQueryTree (display, real_root_window, &unused, &unused, &windows, |
240 | if (XQueryTree (display, real_root_window, &unused, &unused, &windows, &count)) |
212 | &count)) |
|
|
213 | { |
241 | { |
214 | int i; |
242 | int i; |
215 | |
243 | |
216 | for (i = 0; i < count; i++) |
244 | for (i = 0; i < count; i++) |
217 | { |
245 | { |
… | |
… | |
227 | { |
255 | { |
228 | if (type != None) |
256 | if (type != None) |
229 | { |
257 | { |
230 | if (type == XA_WINDOW) |
258 | if (type == XA_WINDOW) |
231 | { |
259 | { |
|
|
260 | root = *(Window *)virtual_root_window; |
232 | XFree (windows); |
261 | XFree (windows); |
233 | return (Window) virtual_root_window; |
262 | XFree (virtual_root_window); |
|
|
263 | return root; |
234 | } |
264 | } |
235 | else |
265 | else |
236 | fprintf (stderr, |
|
|
237 | "__SWM_VROOT property type mismatch"); |
266 | fprintf (stderr, "__SWM_VROOT property type mismatch"); |
238 | } |
267 | } |
239 | } |
268 | } |
240 | else |
269 | else |
241 | fprintf (stderr, |
270 | fprintf (stderr, |
242 | "failed to get __SWM_VROOT property on window 0x%lx", |
271 | "failed to get __SWM_VROOT property on window 0x%lx", |
… | |
… | |
261 | InitWindow (void) |
290 | InitWindow (void) |
262 | { |
291 | { |
263 | XGCValues gcv; |
292 | XGCValues gcv; |
264 | unsigned long gcm; |
293 | unsigned long gcm; |
265 | int screen, ScreenWidth, ScreenHeight; |
294 | int screen, ScreenWidth, ScreenHeight; |
|
|
295 | struct logfile_entry *e; |
266 | |
296 | |
267 | if (!(disp = XOpenDisplay (dispname))) |
297 | if (!(disp = XOpenDisplay (dispname))) |
268 | { |
298 | { |
269 | fprintf (stderr, "Can't open display %s.\n", dispname); |
299 | fprintf (stderr, "Can't open display %s.\n", dispname); |
270 | exit (1); |
300 | exit (1); |
… | |
… | |
280 | gcv.graphics_exposures = True; |
310 | gcv.graphics_exposures = True; |
281 | WinGC = XCreateGC (disp, root, gcm, &gcv); |
311 | WinGC = XCreateGC (disp, root, gcm, &gcv); |
282 | XMapWindow (disp, root); |
312 | XMapWindow (disp, root); |
283 | XSetForeground (disp, WinGC, GetColor (DEF_COLOR)); |
313 | XSetForeground (disp, WinGC, GetColor (DEF_COLOR)); |
284 | |
314 | |
|
|
315 | for (e = loglist; e; e = e->next) |
285 | { |
316 | { |
286 | char **missing_charset_list; |
317 | char **missing_charset_list; |
287 | int missing_charset_count; |
318 | int missing_charset_count; |
288 | char *def_string; |
319 | char *def_string; |
289 | |
320 | |
290 | fontset = XCreateFontSet (disp, fontname, |
321 | e->fontset = XCreateFontSet (disp, e->fontname, |
291 | &missing_charset_list, &missing_charset_count, |
322 | &missing_charset_list, &missing_charset_count, |
292 | &def_string); |
323 | &def_string); |
293 | |
324 | |
294 | if (missing_charset_count) |
325 | if (missing_charset_count) |
|
|
326 | { |
|
|
327 | fprintf (stderr, |
|
|
328 | "Missing charsets in String to FontSet conversion (%s)\n", |
|
|
329 | missing_charset_list[0]); |
|
|
330 | XFreeStringList (missing_charset_list); |
|
|
331 | } |
|
|
332 | |
|
|
333 | if (!e->fontset) |
|
|
334 | { |
|
|
335 | fprintf (stderr, "unable to create fontset for font '%s', exiting.\n", e->fontname); |
|
|
336 | exit (1); |
|
|
337 | } |
|
|
338 | |
295 | { |
339 | { |
296 | fprintf (stderr, |
340 | XFontSetExtents *xfe = XExtentsOfFontSet (e->fontset); |
297 | "Missing charsets in String to FontSet conversion (%s)\n", |
341 | |
298 | missing_charset_list[0]); |
342 | e->font_height = xfe->max_logical_extent.height; |
299 | XFreeStringList (missing_charset_list); |
343 | e->font_ascent = -xfe->max_logical_extent.y; |
300 | } |
344 | } |
301 | } |
|
|
302 | |
|
|
303 | if (!fontset) |
|
|
304 | { |
345 | } |
305 | fprintf (stderr, "unable to create fontset, exiting.\n"); |
|
|
306 | exit (1); |
|
|
307 | } |
|
|
308 | |
|
|
309 | { |
|
|
310 | XFontSetExtents *xfe = XExtentsOfFontSet (fontset); |
|
|
311 | |
|
|
312 | font_height = xfe->max_logical_extent.height; |
|
|
313 | font_ascent = -xfe->max_logical_extent.y; |
|
|
314 | } |
|
|
315 | |
346 | |
316 | if (geom_mask & XNegative) |
347 | if (geom_mask & XNegative) |
317 | win_x = win_x + ScreenWidth - width; |
348 | win_x = win_x + ScreenWidth - width; |
318 | if (geom_mask & YNegative) |
349 | if (geom_mask & YNegative) |
319 | win_y = win_y + ScreenHeight - height; |
350 | win_y = win_y + ScreenHeight - height; |
320 | |
351 | |
321 | if (opt_outline) |
352 | if (opt_outline) |
322 | { |
353 | { |
323 | /* adding outline increases the total width and height by 2 |
354 | /* adding outline increases the total width and height by 2 |
324 | pixels each, and offsets the text one pixel right and one |
355 | pixels each, and offsets the text one pixel right and one |
325 | pixel down */ |
356 | pixel down */ |
326 | effect_x_space = effect_y_space = 2; |
357 | effect_x_space = effect_y_space = 2; |
327 | effect_x_offset = effect_y_offset = 1; |
358 | effect_x_offset = effect_y_offset = 1; |
328 | } |
359 | } |
329 | else if (opt_shade) |
360 | else if (opt_shade) |
330 | { |
361 | { |
331 | /* adding a shadow increases the space used */ |
362 | /* adding a shadow increases the space used */ |
332 | effect_x_space = abs(SHADE_X); |
363 | effect_x_space = abs (SHADE_X); |
333 | effect_y_space = abs(SHADE_Y); |
364 | effect_y_space = abs (SHADE_Y); |
|
|
365 | |
334 | /* if the shadow is to the right and below then we don't need |
366 | /* if the shadow is to the right and below then we don't need |
335 | * to move the text to make space for it, but shadows to the left |
367 | * to move the text to make space for it, but shadows to the left |
336 | * and above need accomodating */ |
368 | * and above need accomodating */ |
337 | effect_x_offset = SHADE_X > 0 ? 0 : -SHADE_X; |
369 | effect_x_offset = SHADE_X > 0 ? 0 : -SHADE_X; |
338 | effect_y_offset = SHADE_Y > 0 ? 0 : -SHADE_Y; |
370 | effect_y_offset = SHADE_Y > 0 ? 0 : -SHADE_Y; |
… | |
… | |
341 | { |
373 | { |
342 | effect_x_space = effect_y_space = 0; |
374 | effect_x_space = effect_y_space = 0; |
343 | effect_x_offset = effect_y_offset = 0; |
375 | effect_x_offset = effect_y_offset = 0; |
344 | } |
376 | } |
345 | |
377 | |
346 | /* if we are using -shade or -outline, there will be less usable |
|
|
347 | * space for output */ |
|
|
348 | listlen = (height - effect_y_space) / font_height; |
|
|
349 | |
|
|
350 | if (!listlen) |
|
|
351 | { |
|
|
352 | fprintf (stderr, "height too small for a single line, setting to %d\n", |
|
|
353 | font_height); |
|
|
354 | listlen = 1; |
|
|
355 | } |
|
|
356 | |
|
|
357 | /* leave the height how the user requested it. it might not all be |
|
|
358 | * used, but this will allow the geometry to be tuned more accurately |
|
|
359 | * (with the -frame option) |
|
|
360 | * the old code did this: |
|
|
361 | * height = listlen * font_height + effect_y_space; */ |
|
|
362 | |
|
|
363 | XSelectInput (disp, root, ExposureMask | FocusChangeMask); |
378 | XSelectInput (disp, root, ExposureMask | FocusChangeMask); |
364 | } |
379 | } |
365 | |
380 | |
366 | /* |
381 | /* |
367 | * if redraw() is passwd a non-zero argument, it does a complete |
382 | * if redraw () is passwd a non-zero argument, it does a complete |
368 | * redraw, rather than an update. if the argument is zero (and |
383 | * redraw, rather than an update. if the argument is zero (and |
369 | * -noflicker is in effect) then only the lines which have changed |
384 | * -noflicker is in effect) then only the lines which have changed |
370 | * since the last draw are redrawn. |
385 | * since the last draw are redrawn. |
371 | * |
386 | * |
372 | * the rest is handled by regular refresh()'es |
387 | * the rest is handled by regular refresh ()'es |
373 | */ |
388 | */ |
374 | void |
389 | void |
375 | redraw (int redraw_all) |
390 | redraw (int redraw_all) |
376 | { |
391 | { |
377 | XSetClipMask (disp, WinGC, None); |
392 | XSetClipMask (disp, WinGC, None); |
378 | refresh (0, 32768, 1, redraw_all); |
393 | refresh (0, 32768, 1, redraw_all); |
379 | } |
394 | } |
380 | |
395 | |
|
|
396 | void draw_text (Display *disp, Window root, GC WinGC, int x, int y, struct line_node *line, int foreground) |
|
|
397 | { |
|
|
398 | if (line->wrapped_right && opt_justify && line->breaks) |
|
|
399 | { |
|
|
400 | int i; |
|
|
401 | for (i = 0; i < line->num_words; i++) |
|
|
402 | XmbDrawString (disp, root, line->logfile->fontset, WinGC, |
|
|
403 | x + line->breaks[i].width + ((i * line->free_pixels) / (line->num_words - 1)) |
|
|
404 | + continuation_width * line->wrapped_left, y, |
|
|
405 | line->line + line->breaks[i].index, |
|
|
406 | line->breaks[i].len); |
|
|
407 | |
|
|
408 | if (line->wrapped_left) |
|
|
409 | { |
|
|
410 | if (foreground) XSetForeground (disp, WinGC, continuation_color); |
|
|
411 | XmbDrawString (disp, root, line->logfile->fontset, WinGC, x, y, continuation, continuation_length); |
|
|
412 | } |
|
|
413 | } |
|
|
414 | else |
|
|
415 | { |
|
|
416 | XmbDrawString (disp, root, line->logfile->fontset, WinGC, x + continuation_width * line->wrapped_left, |
|
|
417 | y, line->line, line->len); |
|
|
418 | |
|
|
419 | if (line->wrapped_left) |
|
|
420 | { |
|
|
421 | if (foreground) XSetForeground (disp, WinGC, continuation_color); |
|
|
422 | XmbDrawString (disp, root, line->logfile->fontset, WinGC, x, y, continuation, continuation_length); |
|
|
423 | } |
|
|
424 | } |
|
|
425 | } |
|
|
426 | |
381 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
427 | /* Just redraw everything without clearing (i.e. after an EXPOSE event) */ |
382 | void |
428 | void |
383 | refresh (int miny, int maxy, int clear, int refresh_all) |
429 | refresh (int miny, int maxy, int clear, int refresh_all) |
384 | { |
430 | { |
385 | int lin; |
431 | int lin = 0; |
386 | int offset = listlen * font_height + font_ascent + effect_y_offset; |
432 | int space = height; |
|
|
433 | int offset; |
387 | unsigned long black_color = GetColor ("black"); |
434 | unsigned long black_color = GetColor ("black"); |
|
|
435 | struct line_node *line; |
|
|
436 | int step_per_line; |
|
|
437 | int foreground = 0; |
388 | |
438 | |
389 | miny -= win_y + font_height; |
439 | if (opt_reverse) |
390 | maxy -= win_y - font_height; |
440 | offset = effect_y_offset; |
|
|
441 | else |
|
|
442 | offset = height + effect_y_offset; |
|
|
443 | |
|
|
444 | miny -= win_y; |
|
|
445 | maxy -= win_y; |
391 | |
446 | |
392 | if (clear && !opt_noflicker) |
447 | if (clear && !opt_noflicker) |
393 | XClearArea (disp, root, win_x, win_y, width, height, False); |
448 | XClearArea (disp, root, win_x, win_y, width + MARGIN_OF_ERROR, height, False); |
394 | |
449 | |
395 | for (lin = listlen; lin--;) |
450 | for (line = linelist; line; line = line->next, lin++) |
396 | { |
451 | { |
397 | struct linematrix *line = lines + (opt_reverse ? listlen - lin - 1 : lin); |
|
|
398 | struct displaymatrix *display_line = display + lin; |
452 | struct displaymatrix *display_line; |
399 | |
453 | |
400 | offset -= font_height; |
454 | if (opt_noflicker && lin >= listlen) |
|
|
455 | { |
|
|
456 | int i = listlen; |
|
|
457 | listlen *= 1.5; |
|
|
458 | display = xrealloc(display, listlen * sizeof(struct displaymatrix)); |
|
|
459 | for (; i < listlen; i++) |
|
|
460 | { |
|
|
461 | display[i].line = xstrdup (""); |
|
|
462 | display[i].len = 0; |
|
|
463 | display[i].offset = 0; |
|
|
464 | display[i].buffer_size = 0; |
|
|
465 | } |
|
|
466 | } |
401 | |
467 | |
|
|
468 | display_line = display + lin; |
|
|
469 | |
|
|
470 | step_per_line = line->logfile->font_height + effect_y_space; |
|
|
471 | if (step_per_line > space) |
|
|
472 | break; |
|
|
473 | |
|
|
474 | if (!opt_reverse) |
|
|
475 | offset -= step_per_line; |
|
|
476 | |
|
|
477 | offset += line->logfile->font_ascent; |
|
|
478 | |
|
|
479 | miny -= line->logfile->font_height; |
|
|
480 | maxy += line->logfile->font_height; |
|
|
481 | |
402 | if (offset < miny || offset > maxy) |
482 | if (offset >= miny && offset <= maxy) |
403 | continue; |
483 | { |
404 | |
|
|
405 | /* if this line is a different than it was, then it |
484 | /* if this line is a different than it was, then it |
406 | * needs displaying */ |
485 | * needs displaying */ |
407 | if (!opt_noflicker |
486 | if (!opt_noflicker |
408 | || refresh_all |
487 | || refresh_all |
409 | || display_line->len != line->len |
488 | || display_line->len != line->len |
410 | || display_line->color != line->color |
489 | || display_line->color != line->logfile->color |
|
|
490 | || display_line->offset != offset |
411 | || memcmp (display_line->line, line->line, line->len)) |
491 | || memcmp (display_line->line, line->line, line->len)) |
412 | { |
492 | { |
413 | /* don't bother updating the record of what has been |
493 | /* don't bother updating the record of what has been |
414 | * displayed if -noflicker isn't in effect, since we redraw |
494 | * displayed if -noflicker isn't in effect, since we redraw |
415 | * the whole display every time anyway */ |
495 | * the whole display every time anyway */ |
416 | if (opt_noflicker) |
496 | if (opt_noflicker) |
417 | { |
497 | { |
418 | /* update the record of what has been displayed; |
498 | /* update the record of what has been displayed; |
419 | * first make sure the buffer is big enough */ |
499 | * first make sure the buffer is big enough */ |
420 | if (display_line->buffer_size < line->len) |
500 | if (display_line->buffer_size < line->len) |
421 | { |
501 | { |
422 | display_line->buffer_size = line->len; |
502 | display_line->buffer_size = line->len; |
423 | display_line->line = xrealloc (display_line->line, display_line->buffer_size); |
503 | display_line->line = xrealloc (display_line->line, display_line->buffer_size); |
424 | } |
504 | } |
425 | |
505 | |
426 | display_line->len = line->len; |
506 | display_line->len = line->len; |
427 | display_line->color = line->color; |
507 | display_line->color = line->logfile->color; |
|
|
508 | display_line->offset = offset; |
428 | memcpy (display_line->line, line->line, line->len); |
509 | memcpy (display_line->line, line->line, line->len); |
429 | |
510 | |
430 | if (clear) |
511 | if (clear) |
|
|
512 | { |
|
|
513 | #ifdef DEBUG |
|
|
514 | static int toggle; |
|
|
515 | toggle = 1 - toggle; |
|
|
516 | XSetForeground (disp, WinGC, toggle ? GetColor ("cyan") : GetColor ("yellow")); |
|
|
517 | XFillRectangle (disp, root, WinGC, win_x, win_y + offset - line->logfile->font_ascent, |
|
|
518 | width, step_per_line); |
|
|
519 | #else /* DEBUG */ |
431 | XClearArea (disp, root, win_x, win_y + offset - font_ascent, |
520 | XClearArea (disp, root, win_x, win_y + offset - line->logfile->font_ascent, |
432 | width + effect_x_space, font_height + effect_y_space, False); |
521 | width + MARGIN_OF_ERROR, step_per_line, False); |
433 | } |
522 | #endif /* DEBUG */ |
|
|
523 | } |
|
|
524 | } |
434 | |
525 | |
435 | if (opt_outline) |
526 | if (opt_outline) |
436 | { |
527 | { |
437 | int x, y; |
528 | int x, y; |
438 | XSetForeground (disp, WinGC, black_color); |
529 | XSetForeground (disp, WinGC, black_color); |
439 | |
530 | |
440 | for (x = -1; x <= 1; x += 2) |
531 | for (x = -1; x <= 1; x += 2) |
441 | for (y = -1; y <= 1; y += 2) |
532 | for (y = -1; y <= 1; y += 2) |
442 | XmbDrawString (disp, root, fontset, WinGC, |
533 | draw_text (disp, root, WinGC, |
443 | win_x + effect_x_offset + x, |
534 | win_x + effect_x_offset + x, |
444 | win_y + y + offset, |
535 | win_y + y + offset, line, foreground = 0); |
445 | line->line, line->len); |
|
|
446 | } |
536 | } |
447 | else if (opt_shade) |
537 | else if (opt_shade) |
448 | { |
538 | { |
449 | XSetForeground (disp, WinGC, black_color); |
539 | XSetForeground (disp, WinGC, black_color); |
450 | XmbDrawString (disp, root, fontset, WinGC, |
540 | draw_text (disp, root, WinGC, |
451 | win_x + effect_x_offset + SHADE_X, |
541 | win_x + effect_x_offset + SHADE_X, |
452 | win_y + offset + SHADE_Y, |
542 | win_y + offset + SHADE_Y, line, foreground = 0); |
453 | line->line, line->len); |
|
|
454 | } |
543 | } |
455 | |
544 | |
456 | XSetForeground (disp, WinGC, line->color); |
545 | XSetForeground (disp, WinGC, line->logfile->color); |
457 | XmbDrawString (disp, root, fontset, WinGC, |
546 | draw_text (disp, root, WinGC, |
458 | win_x + effect_x_offset, |
547 | win_x + effect_x_offset, |
459 | win_y + offset, |
548 | win_y + offset, line, foreground = 1); |
460 | line->line, line->len); |
549 | } |
461 | } |
550 | } |
|
|
551 | |
|
|
552 | if (opt_reverse) |
|
|
553 | offset += step_per_line; |
|
|
554 | offset -= line->logfile->font_ascent; |
|
|
555 | |
|
|
556 | miny += line->logfile->font_height; |
|
|
557 | maxy -= line->logfile->font_height; |
|
|
558 | |
|
|
559 | space -= step_per_line; |
|
|
560 | } |
|
|
561 | |
|
|
562 | if (space > 0 && clear) |
|
|
563 | { |
|
|
564 | #ifdef DEBUG |
|
|
565 | XSetForeground (disp, WinGC, GetColor ("orange")); |
|
|
566 | XFillRectangle (disp, root, WinGC, win_x, win_y + offset - (opt_reverse ? 0 : space), |
|
|
567 | width, space); |
|
|
568 | #else /* DEBUG */ |
|
|
569 | XClearArea (disp, root, win_x, win_y + offset - (opt_reverse ? 0 : space), |
|
|
570 | width + MARGIN_OF_ERROR, space, False); |
|
|
571 | #endif |
|
|
572 | } |
|
|
573 | |
|
|
574 | /* any lines that didn't just get looked at are never going to be, so break the chain */ |
|
|
575 | if (line) line->prev->next = 0; |
|
|
576 | |
|
|
577 | /* and throw them all away */ |
|
|
578 | while (line) |
|
|
579 | { |
|
|
580 | struct line_node *this = line; |
|
|
581 | line = line->next; |
|
|
582 | if (this->logfile && this->logfile->last == this) |
|
|
583 | this->logfile->last = NULL; |
|
|
584 | free (this->line); |
|
|
585 | free (this->breaks); |
|
|
586 | free (this); |
462 | } |
587 | } |
463 | |
588 | |
464 | if (opt_frame) |
589 | if (opt_frame) |
465 | { |
590 | { |
466 | XSetForeground (disp, WinGC, GetColor (def_color)); |
591 | XSetForeground (disp, WinGC, GetColor (def_color)); |
|
|
592 | /* note that XDrawRectangle() draws a rectangle one pixel bigger |
|
|
593 | * in both dimensions than you ask for, hence the subtractions. |
|
|
594 | * XFillRectangle() doesn't suffer from this problem */ |
467 | XDrawRectangle (disp, root, WinGC, win_x - 0, win_y - 0, width - 1, height - 1); |
595 | XDrawRectangle (disp, root, WinGC, win_x - 0, win_y - 0, width - 1, height - 1); |
468 | } |
596 | } |
469 | } |
597 | } |
470 | |
598 | |
471 | #if HAS_REGEX |
599 | #if HAS_REGEX |
… | |
… | |
488 | regmatch_t matched[16]; |
616 | regmatch_t matched[16]; |
489 | |
617 | |
490 | i = regexec (transformre, s, 16, matched, 0); |
618 | i = regexec (transformre, s, 16, matched, 0); |
491 | if (i == 0) |
619 | if (i == 0) |
492 | { /* matched */ |
620 | { /* matched */ |
493 | int match_start = matched[0].rm_so; |
621 | int match_start = matched[0].rm_so; |
494 | int match_end = matched[0].rm_eo; |
622 | int match_end = matched[0].rm_eo; |
495 | int old_len = match_end - match_start; |
623 | int old_len = match_end - match_start; |
496 | int new_len = strlen (transform_to); |
624 | int new_len = strlen (transform_to); |
497 | int old_whole_len = strlen (s); |
625 | int old_whole_len = strlen (s); |
498 | |
626 | |
499 | printf ("regexp was matched by '%s' - replace with '%s'\n", s, transform_to); |
627 | printf ("regexp was matched by '%s' - replace with '%s'\n", s, transform_to); |
500 | printf ("match is from %d to %d\n", match_start, match_end); |
628 | printf ("match is from %d to %d\n", match_start, match_end); |
501 | if (new_len > old_len) |
629 | if (new_len > old_len) |
502 | s = xrealloc(s, old_whole_len + new_len - old_len); |
630 | s = xrealloc (s, old_whole_len + new_len - old_len); |
503 | |
631 | |
504 | if (new_len != old_len) |
632 | if (new_len != old_len) |
505 | { |
633 | { |
506 | memcpy(s + match_end + new_len - old_len, |
634 | memcpy (s + match_end + new_len - old_len, |
507 | s + match_end, |
635 | s + match_end, |
508 | old_whole_len - match_end); |
636 | old_whole_len - match_end); |
509 | s[old_whole_len + new_len - old_len] = '\0'; |
637 | s[old_whole_len + new_len - old_len] = '\0'; |
510 | } |
638 | } |
511 | |
639 | |
512 | memcpy (s + match_start, |
640 | memcpy (s + match_start, |
513 | transform_to, |
641 | transform_to, |
514 | new_len); |
642 | new_len); |
515 | printf ("transformed to '%s'\n", s); |
643 | printf ("transformed to '%s'\n", s); |
516 | } |
644 | } |
517 | else |
645 | else |
518 | { |
|
|
519 | printf ("regexp was not matched by '%s'\n", s); |
646 | printf ("regexp was not matched by '%s'\n", s); |
520 | } |
|
|
521 | } |
647 | } |
522 | } |
648 | } |
523 | #endif |
649 | #endif |
524 | |
650 | |
|
|
651 | /* |
|
|
652 | * appends p2 to the end of p1, if p1 is not null |
|
|
653 | * otherwise allocates a new string and copies p2 to it |
|
|
654 | */ |
525 | char * |
655 | char * |
526 | concat_line (const char *p1, const char *p2) |
656 | concat_line (char *p1, const char *p2) |
527 | { |
657 | { |
|
|
658 | assert(p2); |
|
|
659 | |
528 | int l1 = p1 ? strlen (p1) : 0; |
660 | int l1 = p1 ? strlen (p1) : 0; |
529 | int l2 = strlen (p2); |
661 | int l2 = strlen (p2); |
530 | char *r = xmalloc (l1 + l2 + 1); |
662 | char *r; |
531 | |
663 | |
532 | memcpy (r, p1, l1); |
664 | if (p1) |
|
|
665 | r = xrealloc(p1, l1 + l2 + 1); |
|
|
666 | else |
|
|
667 | r = xmalloc (l2 + 1); |
|
|
668 | |
533 | memcpy (r + l1, p2, l2); |
669 | memcpy (r + l1, p2, l2); |
534 | r[l1 + l2] = 0; |
670 | r[l1 + l2] = 0; |
535 | |
671 | |
536 | return r; |
672 | return r; |
537 | } |
673 | } |
… | |
… | |
553 | * until we've seen how (ie. whether) it ends */ |
689 | * until we've seen how (ie. whether) it ends */ |
554 | do |
690 | do |
555 | { |
691 | { |
556 | p = buff; |
692 | p = buff; |
557 | do |
693 | do |
558 | { |
694 | { |
559 | ch = fgetc (logfile->fp); |
695 | ch = fgetc (logfile->fp); |
560 | |
696 | |
561 | if (ch == '\n' || ch == EOF) |
697 | if (ch == '\n' || ch == EOF) |
562 | break; |
698 | break; |
563 | else if (ch == '\r') |
699 | else if (ch == '\r') |
564 | continue; /* skip */ |
700 | continue; /* skip */ |
565 | else if (ch == '\t') |
701 | else if (ch == '\t') |
566 | { |
702 | { |
567 | do |
703 | do |
568 | { |
704 | { |
569 | *p++ = ' '; |
705 | *p++ = ' '; |
570 | ofs++; |
706 | ofs++; |
571 | } |
707 | } |
572 | while (ofs & 7); |
708 | while (ofs & 7); |
573 | } |
709 | } |
574 | else |
710 | else |
575 | { |
711 | { |
576 | *p++ = ch; |
712 | *p++ = ch; |
577 | ofs++; |
713 | ofs++; |
578 | } |
714 | } |
579 | } |
715 | } |
580 | while (p < buff + (sizeof buff) - 8 - 1); |
716 | while (p < buff + (sizeof buff) - 8 - 1); |
581 | |
717 | |
582 | if (p == buff && ch == EOF) |
718 | if (p == buff && ch == EOF) |
583 | return 0; |
719 | return 0; |
584 | |
720 | |
585 | *p = 0; |
721 | *p = 0; |
586 | |
722 | |
587 | p = concat_line (logfile->buf, buff); |
723 | p = logfile->buf = concat_line (logfile->buf, buff); |
588 | free (logfile->buf); logfile->buf = p; |
|
|
589 | } |
724 | } |
590 | while (ch != '\n' && ch != EOF); |
725 | while (ch != '\n' && ch != EOF); |
591 | |
726 | |
592 | logfile->lastpartial = logfile->partial; |
727 | logfile->lastpartial = logfile->partial; |
593 | /* there are 3 ways we could have exited the loop: reading '\n', |
728 | /* there are 3 ways we could have exited the loop: reading '\n', |
594 | * reaching EOF, or filling the buffer; the 2nd and 3rd of these |
729 | * reaching EOF, or filling the buffer; the 2nd and 3rd of these |
595 | * both result in a partial line */ |
730 | * both result in a partial line */ |
596 | logfile->partial = ch != '\n'; |
731 | logfile->partial = ch != '\n'; |
597 | |
732 | |
598 | if (logfile->partial && opt_whole) |
733 | if (logfile->partial && opt_whole) |
599 | return 0; |
734 | return 0; |
600 | |
735 | |
601 | #if HAS_REGEX |
736 | #if HAS_REGEX |
602 | transform_line (logfile->buf); |
737 | transform_line (logfile->buf); |
… | |
… | |
630 | else |
765 | else |
631 | file->inode = stats.st_ino; |
766 | file->inode = stats.st_ino; |
632 | |
767 | |
633 | if (opt_noinitial) |
768 | if (opt_noinitial) |
634 | fseek (file->fp, 0, SEEK_END); |
769 | fseek (file->fp, 0, SEEK_END); |
635 | else if (stats.st_size > (listlen + 1) * width) |
770 | else /* if (stats.st_size > (listlen + 1) * width) |
|
|
771 | * HACK - 'width' is in pixels - how are we to know how much text will fit? |
636 | fseek (file->fp, -((listlen + 2) * width), SEEK_END); |
772 | * fseek (file->fp, -((listlen + 2) * width/10), SEEK_END); */ |
|
|
773 | fseek (file->fp, -5000, SEEK_END); |
637 | |
774 | |
638 | file->last_size = stats.st_size; |
775 | file->last_size = stats.st_size; |
639 | return file->fp; |
776 | return file->fp; |
640 | } |
777 | } |
641 | |
778 | |
… | |
… | |
697 | } |
834 | } |
698 | } |
835 | } |
699 | } |
836 | } |
700 | |
837 | |
701 | /* |
838 | /* |
702 | * insert a single physical line (that must be short enough to fit) |
839 | * insert a single node in the list of screen lines and return a |
703 | * at position "idx" by pushing up lines above it. the caller |
840 | * pointer to the new node. |
704 | * MUST then fill in lines[idx] with valid data. |
841 | * the caller MUST then fill in ret->line and ret->len with valid |
|
|
842 | * data. |
|
|
843 | */ |
|
|
844 | static struct line_node * |
|
|
845 | new_line_node (struct logfile_entry *log) |
|
|
846 | { |
|
|
847 | struct line_node *new = xmalloc (sizeof (struct line_node)); |
|
|
848 | |
|
|
849 | new->logfile = log; |
|
|
850 | new->wrapped_left = 0; |
|
|
851 | new->wrapped_right = 0; |
|
|
852 | new->breaks = 0; |
|
|
853 | |
|
|
854 | assert(log); |
|
|
855 | |
|
|
856 | if (!log || !log->last) |
|
|
857 | { |
|
|
858 | new->next = linelist; |
|
|
859 | new->next->prev = new; |
|
|
860 | |
|
|
861 | new->prev = NULL; |
|
|
862 | linelist = new; |
|
|
863 | } |
|
|
864 | else |
|
|
865 | { |
|
|
866 | /* 2 pointers from the new node */ |
|
|
867 | new->next = log->last; |
|
|
868 | new->prev = log->last->prev; |
|
|
869 | |
|
|
870 | /* 2 pointers back to the new node */ |
|
|
871 | if (new->next) new->next->prev = new; |
|
|
872 | if (new->prev) new->prev->next = new; |
|
|
873 | |
|
|
874 | /* if this is a new first entry in the list then update |
|
|
875 | * 'linelist' */ |
|
|
876 | if (log->last == linelist) |
|
|
877 | linelist = new; |
|
|
878 | } |
|
|
879 | |
|
|
880 | /* update the logfile record */ |
|
|
881 | if (log) |
|
|
882 | log->last = new; |
|
|
883 | |
|
|
884 | return new; |
|
|
885 | } |
|
|
886 | |
|
|
887 | /* |
|
|
888 | * this is called after either adding a new line or appending to an |
|
|
889 | * old one. in both cases it's possible that the line no longer fits, |
|
|
890 | * and needs wrapping. this function checks the last line associated |
|
|
891 | * with the supplied logfile. |
705 | */ |
892 | */ |
706 | static void |
893 | static void |
707 | insert_line (int idx) |
894 | possibly_split_long_line (struct logfile_entry *log) |
708 | { |
895 | { |
709 | int cur_line; |
896 | char *str = log->last->line; |
710 | struct logfile_entry *current; |
|
|
711 | |
|
|
712 | free (lines[0].line); |
|
|
713 | |
|
|
714 | for (cur_line = 0; cur_line < idx; cur_line++) |
|
|
715 | lines[cur_line] = lines[cur_line + 1]; |
|
|
716 | |
|
|
717 | for (current = loglist; current; current = current->next) |
|
|
718 | if (current->index <= idx) |
|
|
719 | current->index--; |
|
|
720 | } |
|
|
721 | |
|
|
722 | /* |
|
|
723 | * remove a single physical line at position "idx" by moving the lines above it |
|
|
724 | * down and inserting a "~" line at the top. |
|
|
725 | */ |
|
|
726 | static void |
|
|
727 | delete_line (int idx) |
|
|
728 | { |
|
|
729 | int cur_line; |
|
|
730 | struct logfile_entry *current; |
|
|
731 | |
|
|
732 | for (cur_line = idx; cur_line > 0; cur_line--) |
|
|
733 | lines[cur_line] = lines[cur_line - 1]; |
|
|
734 | |
|
|
735 | lines[0].line = xstrdup ("~"); |
|
|
736 | |
|
|
737 | for (current = loglist; current; current = current->next) |
|
|
738 | if (current->index >= 0 && current->index <= idx) |
|
|
739 | current->index++; |
|
|
740 | } |
|
|
741 | |
|
|
742 | /* |
|
|
743 | * takes a logical log file line and splits it into multiple physical |
|
|
744 | * screen lines by splitting it whenever a part becomes too long. |
|
|
745 | * lal lines will be inserted at position "idx". |
|
|
746 | */ |
|
|
747 | static void |
|
|
748 | split_line (int idx, const char *str, unsigned long color) |
|
|
749 | { |
|
|
750 | int l = strlen (str); |
897 | int l = strlen (str); |
751 | int last_wrapped = 0; |
|
|
752 | const char *p = str; |
898 | char *p = str; |
753 | static int continuation_width = -1; |
899 | struct line_node *line; |
754 | static int continuation_length; |
900 | int spaces; |
|
|
901 | static struct breakinfo *breaks; |
|
|
902 | static int break_buffer_size; |
755 | |
903 | |
756 | /* only calculate the continuation's width once */ |
904 | /* only calculate the continuation's width once */ |
757 | if (continuation_width == -1) |
905 | if (continuation_width == -1) |
758 | { |
906 | { |
759 | continuation_length = strlen (continuation); |
907 | continuation_length = strlen (continuation); |
760 | continuation_width = XmbTextEscapement (fontset, continuation, continuation_length); |
908 | continuation_width = XmbTextEscapement (log->fontset, continuation, continuation_length); |
|
|
909 | continuation_color = GetColor (cont_color); |
|
|
910 | |
|
|
911 | /* make an array to store information about the location of |
|
|
912 | * spaces in the line */ |
|
|
913 | if (opt_justify) |
|
|
914 | { |
|
|
915 | break_buffer_size = 32; |
|
|
916 | breaks = xmalloc (break_buffer_size * sizeof (struct breakinfo)); |
|
|
917 | } |
761 | } |
918 | } |
762 | |
919 | |
763 | do |
920 | do |
764 | { |
921 | { |
765 | const char *beg = p; |
922 | const char *beg = p; |
766 | int w = last_wrapped ? continuation_width : 0; |
923 | int start_w = log->last->wrapped_left ? continuation_width : 0; |
|
|
924 | int w = start_w; |
767 | int wrapped = 0; |
925 | int wrapped = 0; |
768 | const char *break_p = NULL; |
926 | char *break_p = NULL; |
|
|
927 | int width_at_break_p = 0; |
|
|
928 | spaces = 0; |
|
|
929 | |
|
|
930 | if (opt_justify) |
|
|
931 | breaks[spaces].index = breaks[spaces].width = 0; |
769 | |
932 | |
770 | while (*p) |
933 | while (*p) |
771 | { |
934 | { |
772 | int cw, len; |
935 | int cw, len; |
773 | |
936 | |
774 | /* find the length in bytes of the next multibyte character */ |
937 | /* find the length in bytes of the next multibyte character */ |
775 | len = mblen (p, l); |
938 | len = mblen (p, l); |
776 | if (len <= 0) |
939 | if (len <= 0) |
777 | len = 1; /* ignore (don't skip) illegal character sequences */ |
940 | len = 1; /* ignore (don't skip) illegal character sequences */ |
778 | |
941 | |
779 | /* find the width in pixels of the next character */ |
942 | /* find the width in pixels of the next character */ |
780 | cw = XmbTextEscapement (fontset, p, len); |
943 | cw = XmbTextEscapement (log->fontset, p, len); |
|
|
944 | if (opt_wordwrap && len == 1 && p[0] == ' ' && p != break_p + 1) |
|
|
945 | { |
|
|
946 | break_p = p; |
|
|
947 | width_at_break_p = w; |
|
|
948 | spaces++; |
|
|
949 | |
|
|
950 | if (opt_justify) |
|
|
951 | { |
|
|
952 | /* increase the size of the 'breaks' array when |
|
|
953 | * necessary */ |
|
|
954 | if (spaces >= break_buffer_size) |
|
|
955 | { |
|
|
956 | break_buffer_size *= 1.5; |
|
|
957 | breaks = xrealloc (breaks, break_buffer_size * sizeof (struct breakinfo)); |
|
|
958 | } |
|
|
959 | |
|
|
960 | /* store information about (a) the location of each |
|
|
961 | * space */ |
|
|
962 | breaks[spaces].index = p + 1 - beg; |
|
|
963 | /* (b) the width (in pixels) of the string up to |
|
|
964 | * this space */ |
|
|
965 | breaks[spaces].width = cw + w - start_w; |
|
|
966 | /* (c) the length of each 'word' */ |
|
|
967 | breaks[spaces-1].len = breaks[spaces].index - breaks[spaces-1].index; |
|
|
968 | } |
|
|
969 | } |
|
|
970 | |
781 | if (cw + w > width - effect_x_space) |
971 | if (cw + w > width - effect_x_space) |
782 | { |
972 | { |
783 | if (p == beg) |
973 | if (p == beg) |
784 | { |
974 | { |
785 | fprintf (stderr, "we can't even fit a single character onto the line\n"); |
975 | fprintf (stderr, "we can't even fit a single character onto the line\n"); |
786 | if (len == 1) fprintf (stderr, "(the character we couldn't fit was '%c')\n", *p); |
976 | if (len == 1) fprintf (stderr, "(the character we couldn't fit was '%c')\n", *p); |
787 | exit (1); |
977 | exit (1); |
788 | } |
978 | } |
789 | |
979 | |
790 | wrapped = 1; |
980 | wrapped = 1; |
791 | break; |
981 | break; |
792 | } |
982 | } |
793 | |
|
|
794 | if (opt_wordwrap && len == 1 && p[0] == ' ') |
|
|
795 | break_p = p; |
|
|
796 | |
983 | |
797 | w += cw; |
984 | w += cw; |
798 | p += len; |
985 | p += len; |
799 | l -= len; |
986 | l -= len; |
800 | } |
987 | } |
801 | |
988 | |
802 | /* if we're wrapping at spaces, and the line is long enough to |
989 | /* if we're wrapping at spaces, and the line is long enough to |
803 | * wrap, and we've seen a space already, and the space wasn't |
990 | * wrap, and we've seen a space already, and the space wasn't |
804 | * the first character on the line, then wrap at the space */ |
991 | * the first character on the line, then wrap at the space */ |
|
|
992 | if (!wrapped) |
|
|
993 | break; |
|
|
994 | |
|
|
995 | int prefix_len; |
|
|
996 | |
|
|
997 | /* choose where to break the line */ |
805 | if (opt_wordwrap && wrapped && break_p && break_p != beg) |
998 | if (opt_wordwrap && break_p && break_p != beg) |
806 | { |
|
|
807 | l += p - break_p; |
|
|
808 | p = break_p; |
|
|
809 | } |
|
|
810 | |
|
|
811 | { |
999 | { |
812 | int len = p - beg + (last_wrapped ? continuation_length : 0); |
1000 | prefix_len = break_p - beg; |
813 | char *s = xmalloc (len + 1); |
1001 | p = break_p; |
814 | if (last_wrapped) |
1002 | w = width_at_break_p; |
815 | { |
|
|
816 | memcpy (s, continuation, continuation_length); |
|
|
817 | memcpy (s + continuation_length, beg, p - beg); |
|
|
818 | } |
|
|
819 | else |
|
|
820 | memcpy (s, beg, len); |
|
|
821 | |
1003 | |
822 | s[len] = 0; |
1004 | /* if breaking at a space, skip all adjacent spaces */ |
823 | insert_line (idx); |
1005 | while (*p == ' ') |
824 | lines[idx].line = s; |
1006 | { |
825 | lines[idx].len = len; |
1007 | int len = mblen (p, l); |
826 | lines[idx].color = color; |
1008 | if (len != 1) break; |
|
|
1009 | p++; |
|
|
1010 | } |
|
|
1011 | |
|
|
1012 | if (opt_justify) |
|
|
1013 | { |
|
|
1014 | spaces--; |
|
|
1015 | breaks[spaces].len--; |
|
|
1016 | } |
827 | } |
1017 | } |
|
|
1018 | else |
|
|
1019 | prefix_len = p - beg; |
828 | |
1020 | |
829 | /* if we wrapped at a space, don't display the space */ |
1021 | /* make a copy of the tail end of the string */ |
830 | if (opt_wordwrap && wrapped && break_p && break_p != beg) |
1022 | p = xstrdup (p); |
831 | { |
|
|
832 | l--; |
|
|
833 | p++; |
|
|
834 | } |
|
|
835 | |
1023 | |
836 | last_wrapped = wrapped; |
1024 | /* and reduce the size of the head of the string */ |
|
|
1025 | log->last->line = xrealloc (log->last->line, prefix_len + 1); |
|
|
1026 | log->last->len = prefix_len; |
|
|
1027 | log->last->line[prefix_len] = '\0'; |
|
|
1028 | |
|
|
1029 | /* note that the head was wrapped on it's right */ |
|
|
1030 | log->last->wrapped_right = 1; |
|
|
1031 | |
|
|
1032 | /* 'spaces' includes any space we broke on; we can only justify |
|
|
1033 | * if there's at least one other space */ |
|
|
1034 | if (opt_justify && spaces && |
|
|
1035 | width - effect_x_space - width_at_break_p < spaces * log->font_height) |
|
|
1036 | { |
|
|
1037 | int i; |
|
|
1038 | log->last->free_pixels = width - effect_x_space - w; |
|
|
1039 | log->last->num_words = spaces + 1; |
|
|
1040 | log->last->breaks = malloc (log->last->num_words * sizeof (struct breakinfo)); |
|
|
1041 | for (i = 0; i < log->last->num_words; i++) |
|
|
1042 | log->last->breaks[i] = breaks[i]; |
|
|
1043 | } |
|
|
1044 | |
|
|
1045 | line = new_line_node (log); |
|
|
1046 | line->line = p; |
|
|
1047 | l = line->len = strlen (p); |
|
|
1048 | |
|
|
1049 | /* note that the tail end of the string is wrapped at its left */ |
|
|
1050 | line->wrapped_left = 1; |
837 | } |
1051 | } |
838 | while (l); |
1052 | while (l); |
|
|
1053 | } |
|
|
1054 | |
|
|
1055 | static void |
|
|
1056 | insert_new_line (char *str, struct logfile_entry *log) |
|
|
1057 | { |
|
|
1058 | struct line_node *new; |
|
|
1059 | new = new_line_node (log); |
|
|
1060 | new->line = str; |
|
|
1061 | new->len = strlen (str); |
|
|
1062 | |
|
|
1063 | possibly_split_long_line (log); |
839 | } |
1064 | } |
840 | |
1065 | |
841 | /* |
1066 | /* |
842 | * append something to an existing physical line. this is done |
1067 | * append something to an existing physical line. this is done |
843 | * by deleting the file on-screen, concatenating the new data to it |
1068 | * by deleting the file on-screen, concatenating the new data to it |
844 | * and splitting it again. |
1069 | * and splitting it again. |
845 | */ |
1070 | */ |
846 | static void |
1071 | static void |
847 | append_line (int idx, const char *str) |
1072 | append_to_existing_line (char *str, struct logfile_entry *log) |
848 | { |
1073 | { |
849 | unsigned long color = lines[idx].color; |
1074 | char *old, *new; |
850 | char *old = lines[idx].line; |
1075 | |
|
|
1076 | assert(log); |
|
|
1077 | assert(log->last); |
|
|
1078 | |
|
|
1079 | old = log->last->line; |
|
|
1080 | assert(old); |
|
|
1081 | |
851 | char *new = concat_line (old, str); |
1082 | new = concat_line (old, str); |
852 | |
|
|
853 | free (old); |
1083 | free (str); |
854 | |
1084 | log->last->line = new; |
855 | delete_line (idx); |
1085 | log->last->len = strlen (new); |
856 | split_line (idx, new, color); |
1086 | possibly_split_long_line (log); |
857 | } |
1087 | } |
858 | |
1088 | |
859 | static void |
1089 | static void |
860 | main_loop (void) |
1090 | main_loop (void) |
861 | { |
1091 | { |
… | |
… | |
865 | XEvent xev; |
1095 | XEvent xev; |
866 | struct logfile_entry *lastprinted = NULL; |
1096 | struct logfile_entry *lastprinted = NULL; |
867 | struct logfile_entry *current; |
1097 | struct logfile_entry *current; |
868 | int need_update = 1; |
1098 | int need_update = 1; |
869 | |
1099 | |
870 | lines = xmalloc (sizeof (struct linematrix) * listlen); |
|
|
871 | display = xmalloc (sizeof (struct displaymatrix) * listlen); |
1100 | display = xmalloc (sizeof (struct displaymatrix) * listlen); |
872 | |
1101 | |
873 | lastreload = time (NULL); |
1102 | lastreload = time (NULL); |
874 | |
1103 | |
875 | /* Initialize linematrix */ |
1104 | /* Initialize line_node */ |
876 | for (lin = 0; lin < listlen; lin++) |
1105 | for (lin = 0; lin < listlen; lin++) |
877 | { |
1106 | { |
|
|
1107 | struct line_node *e = xmalloc (sizeof (struct line_node)); |
878 | lines[lin].line = xstrdup ("~"); |
1108 | e->line = xstrdup ("~"); |
879 | lines[lin].len = 1; |
1109 | e->len = 1; |
|
|
1110 | e->logfile = loglist; /* this is only needed to get a color for the '~' */ |
|
|
1111 | e->wrapped_left = 0; |
|
|
1112 | e->wrapped_right = 0; |
|
|
1113 | e->breaks = 0; |
|
|
1114 | e->next = NULL; |
|
|
1115 | e->prev = linelist_tail; |
|
|
1116 | |
|
|
1117 | if (!linelist) |
|
|
1118 | linelist = e; |
|
|
1119 | if (linelist_tail) |
|
|
1120 | linelist_tail->next = e; |
|
|
1121 | linelist_tail = e; |
|
|
1122 | |
880 | display[lin].line = xstrdup(""); |
1123 | display[lin].line = xstrdup (""); |
881 | display[lin].len = 0; |
1124 | display[lin].len = 0; |
|
|
1125 | display[lin].offset = 0; |
882 | display[lin].buffer_size = 0; |
1126 | display[lin].buffer_size = 0; |
883 | lines[lin].color = GetColor (def_color); |
|
|
884 | } |
1127 | } |
885 | |
1128 | |
886 | for (;;) |
1129 | for (;;) |
887 | { |
1130 | { |
888 | /* read logs */ |
1131 | /* read logs */ |
… | |
… | |
899 | /* if we're trying to update old partial lines in |
1142 | /* if we're trying to update old partial lines in |
900 | * place, and the last time this file was updated the |
1143 | * place, and the last time this file was updated the |
901 | * output was partial, and that partial line is not |
1144 | * output was partial, and that partial line is not |
902 | * too close to the top of the screen, then update |
1145 | * too close to the top of the screen, then update |
903 | * that partial line */ |
1146 | * that partial line */ |
904 | if (opt_update && current->lastpartial && current->index >= 0) |
1147 | if (opt_update && current->lastpartial && current->last) |
905 | { |
1148 | { |
906 | int idx = current->index; |
|
|
907 | append_line (idx, current->buf); |
1149 | append_to_existing_line (current->buf, current); |
908 | current->index = idx; |
1150 | current->buf = 0; |
|
|
1151 | continue; |
|
|
1152 | } |
|
|
1153 | |
|
|
1154 | /* if all we just read was a newline ending a line that we've already displayed, skip it */ |
|
|
1155 | if (current->buf[0] == '\0' && current->lastpartial) |
|
|
1156 | { |
909 | free (current->buf), current->buf = 0; |
1157 | free(current->buf); |
|
|
1158 | current->buf = 0; |
910 | continue; |
1159 | continue; |
911 | } |
1160 | } |
912 | |
1161 | |
913 | /* print filename if any, and if last line was from |
1162 | /* print filename if any, and if last line was from |
914 | * different file */ |
1163 | * different file */ |
915 | if (!opt_nofilename && lastprinted != current && current->desc[0]) |
1164 | if (!opt_nofilename && lastprinted != current && current->desc[0]) |
916 | { |
1165 | { |
917 | split_line (listlen - 1, "[", current->color); |
1166 | current->last = 0; |
918 | append_line (listlen - 1, current->desc); |
1167 | insert_new_line (xstrdup ("["), current); |
919 | append_line (listlen - 1, "]"); |
1168 | append_to_existing_line (xstrdup (current->desc), current); |
|
|
1169 | append_to_existing_line (xstrdup ("]"), current); |
920 | } |
1170 | } |
921 | |
1171 | |
922 | /* if we're dealing with partial lines, and the last |
1172 | /* if we're dealing with partial lines, and the last |
923 | * time we showed the line it wasn't finished ... */ |
1173 | * time we showed the line it wasn't finished ... */ |
924 | if (!opt_whole && current->lastpartial) |
1174 | if (!opt_whole && current->lastpartial) |
925 | { |
1175 | { |
926 | /* if this is the same file we showed last then |
1176 | /* if this is the same file we showed last then |
927 | append to the last line shown */ |
1177 | append to the last line shown */ |
928 | if (lastprinted == current) |
1178 | if (lastprinted == current) |
929 | append_line (listlen - 1, current->buf); |
1179 | append_to_existing_line (current->buf, current); |
930 | else |
1180 | else |
931 | { |
1181 | { |
932 | /* but if a different file has been shown in the |
1182 | /* but if a different file has been shown in the |
933 | * mean time, make a new line, starting with the |
1183 | * mean time, make a new line, starting with the |
934 | * continuation string */ |
1184 | * continuation string */ |
935 | split_line (listlen - 1, continuation, current->color); |
1185 | insert_new_line (current->buf, current); |
936 | append_line (listlen - 1, current->buf); |
1186 | current->last->wrapped_left = 1; |
937 | } |
1187 | } |
938 | } |
1188 | } |
939 | else |
1189 | else |
940 | /* otherwise just make a plain and simple new line */ |
1190 | /* otherwise just make a plain and simple new line */ |
941 | split_line (listlen - 1, current->buf, current->color); |
1191 | insert_new_line (current->buf, current); |
942 | |
1192 | |
943 | free (current->buf), current->buf = 0; |
1193 | current->buf = 0; |
944 | current->index = listlen - 1; |
|
|
945 | lastprinted = current; |
1194 | lastprinted = current; |
946 | } |
1195 | } |
947 | } |
1196 | } |
948 | |
1197 | |
949 | if (need_update) |
1198 | if (need_update) |
… | |
… | |
1060 | XParseGeometry (argv[++i], &win_x, &win_y, &width, &height); |
1309 | XParseGeometry (argv[++i], &win_x, &win_y, &width, &height); |
1061 | else if (!strcmp (arg, "-display")) |
1310 | else if (!strcmp (arg, "-display")) |
1062 | dispname = argv[++i]; |
1311 | dispname = argv[++i]; |
1063 | else if (!strcmp (arg, "-cont")) |
1312 | else if (!strcmp (arg, "-cont")) |
1064 | continuation = argv[++i]; |
1313 | continuation = argv[++i]; |
|
|
1314 | else if (!strcmp (arg, "-cont-color")) |
|
|
1315 | cont_color = argv[++i]; |
1065 | else if (!strcmp (arg, "-font") || !strcmp (arg, "-fn")) |
1316 | else if (!strcmp (arg, "-font") || !strcmp (arg, "-fn")) |
1066 | fontname = argv[++i]; |
1317 | fontname = argv[++i]; |
1067 | #if HAS_REGEX |
1318 | #if HAS_REGEX |
1068 | else if (!strcmp (arg, "-t")) |
1319 | else if (!strcmp (arg, "-t")) |
1069 | { |
1320 | { |
1070 | transform = argv[++i]; |
1321 | transform = argv[++i]; |
1071 | transform_to = argv[++i]; |
1322 | transform_to = argv[++i]; |
1072 | printf("transform: '%s' to '%s'\n", transform, transform_to); |
1323 | printf ("transform: '%s' to '%s'\n", transform, transform_to); |
1073 | } |
1324 | } |
1074 | #endif |
1325 | #endif |
1075 | else if (!strcmp (arg, "-fork") || !strcmp (arg, "-f")) |
1326 | else if (!strcmp (arg, "-fork") || !strcmp (arg, "-f")) |
1076 | opt_daemonize = 1; |
1327 | opt_daemonize = 1; |
1077 | else if (!strcmp (arg, "-reload")) |
1328 | else if (!strcmp (arg, "-reload")) |
1078 | { |
1329 | { |
… | |
… | |
1097 | opt_partial = 1; |
1348 | opt_partial = 1; |
1098 | else if (!strcmp (arg, "-update")) |
1349 | else if (!strcmp (arg, "-update")) |
1099 | opt_update = opt_partial = 1; |
1350 | opt_update = opt_partial = 1; |
1100 | else if (!strcmp (arg, "-wordwrap")) |
1351 | else if (!strcmp (arg, "-wordwrap")) |
1101 | opt_wordwrap = 1; |
1352 | opt_wordwrap = 1; |
|
|
1353 | else if (!strcmp (arg, "-justify")) |
|
|
1354 | opt_justify = 1; |
1102 | else if (!strcmp (arg, "-color")) |
1355 | else if (!strcmp (arg, "-color")) |
1103 | def_color = argv[++i]; |
1356 | def_color = argv[++i]; |
1104 | else if (!strcmp (arg, "-noinitial")) |
1357 | else if (!strcmp (arg, "-noinitial")) |
1105 | opt_noinitial = 1; |
1358 | opt_noinitial = 1; |
1106 | else if (!strcmp (arg, "-id")) |
1359 | else if (!strcmp (arg, "-id")) |
… | |
… | |
1142 | } |
1395 | } |
1143 | |
1396 | |
1144 | e = xmalloc (sizeof (struct logfile_entry)); |
1397 | e = xmalloc (sizeof (struct logfile_entry)); |
1145 | e->partial = 0; |
1398 | e->partial = 0; |
1146 | e->buf = 0; |
1399 | e->buf = 0; |
1147 | e->index = -1; |
|
|
1148 | |
1400 | |
1149 | if (arg[0] == '-' && arg[1] == '\0') |
1401 | if (arg[0] == '-' && arg[1] == '\0') |
1150 | { |
1402 | { |
1151 | if ((e->fp = fdopen (0, "r")) == NULL) |
1403 | if ((e->fp = fdopen (0, "r")) == NULL) |
1152 | perror ("fdopen"), exit (1); |
1404 | perror ("fdopen"), exit (1); |
1153 | if (fcntl (0, F_SETFL, O_NONBLOCK) < 0) |
1405 | if (fcntl (0, F_SETFL, O_NONBLOCK) < 0) |
1154 | perror ("fcntl"), exit (1); |
1406 | perror ("fcntl"), exit (1); |
1155 | |
1407 | |
1156 | e->fname = NULL; |
1408 | e->fname = NULL; |
1157 | e->inode = 0; |
1409 | e->inode = 0; |
|
|
1410 | if (desc == arg) |
1158 | e->desc = xstrdup ("stdin"); |
1411 | e->desc = xstrdup ("stdin"); |
|
|
1412 | else |
|
|
1413 | e->desc = xstrdup (desc); |
1159 | } |
1414 | } |
1160 | else |
1415 | else |
1161 | { |
1416 | { |
1162 | e->fname = xstrdup (fname); |
1417 | e->fname = xstrdup (fname); |
1163 | |
1418 | |
… | |
… | |
1167 | e->desc = xstrdup (desc); |
1422 | e->desc = xstrdup (desc); |
1168 | } |
1423 | } |
1169 | |
1424 | |
1170 | e->color = GetColor (fcolor); |
1425 | e->color = GetColor (fcolor); |
1171 | e->partial = 0; |
1426 | e->partial = 0; |
|
|
1427 | e->fontname = fontname; |
|
|
1428 | e->last = NULL; |
1172 | e->next = NULL; |
1429 | e->next = NULL; |
1173 | |
1430 | |
1174 | if (!loglist) |
1431 | if (!loglist) |
1175 | loglist = e; |
1432 | loglist = e; |
1176 | if (loglist_tail) |
1433 | if (loglist_tail) |
… | |
… | |
1195 | else if (opt_partial && opt_whole) |
1452 | else if (opt_partial && opt_whole) |
1196 | { |
1453 | { |
1197 | fprintf (stderr, "Specify at most one of -partial and -whole\n"); |
1454 | fprintf (stderr, "Specify at most one of -partial and -whole\n"); |
1198 | exit (1); |
1455 | exit (1); |
1199 | } |
1456 | } |
|
|
1457 | |
|
|
1458 | /* it doesn't make sense to justify if word wrap isn't on */ |
|
|
1459 | if (opt_justify) |
|
|
1460 | opt_wordwrap = 1; |
1200 | |
1461 | |
1201 | /* HACK-7: do we want to allow both -shade and -outline? */ |
1462 | /* HACK-7: do we want to allow both -shade and -outline? */ |
1202 | if (opt_shade && opt_outline) |
1463 | if (opt_shade && opt_outline) |
1203 | { |
1464 | { |
1204 | fprintf (stderr, "Specify at most one of -shade and -outline\n"); |
1465 | fprintf (stderr, "Specify at most one of -shade and -outline\n"); |
… | |
… | |
1215 | #if HAS_REGEX |
1476 | #if HAS_REGEX |
1216 | if (transform) |
1477 | if (transform) |
1217 | { |
1478 | { |
1218 | int i; |
1479 | int i; |
1219 | |
1480 | |
1220 | printf("compiling regexp '%s'\n", transform); |
1481 | printf ("compiling regexp '%s'\n", transform); |
1221 | transformre = xmalloc (sizeof (regex_t)); |
1482 | transformre = xmalloc (sizeof (regex_t)); |
1222 | i = regcomp (transformre, transform, REG_EXTENDED); |
1483 | i = regcomp (transformre, transform, REG_EXTENDED); |
1223 | if (i != 0) |
1484 | if (i != 0) |
1224 | { |
1485 | { |
1225 | char buf[512]; |
1486 | char buf[512]; |
1226 | |
1487 | |
1227 | regerror (i, transformre, buf, sizeof (buf)); |
1488 | regerror (i, transformre, buf, sizeof (buf)); |
1228 | fprintf (stderr, "Cannot compile regular expression: %s\n", buf); |
1489 | fprintf (stderr, "Cannot compile regular expression: %s\n", buf); |
1229 | } |
1490 | } |
1230 | else |
1491 | else |
1231 | { |
|
|
1232 | printf("compiled '%s' OK to %x\n", transform, (int)transformre); |
1492 | printf ("compiled '%s' OK to %x\n", transform, (int)transformre); |
1233 | } |
|
|
1234 | } |
1493 | } |
1235 | #endif |
1494 | #endif |
1236 | |
1495 | |
1237 | InitWindow (); |
1496 | InitWindow (); |
1238 | |
1497 | |
… | |
… | |
1259 | action.sa_handler = handler; |
1518 | action.sa_handler = handler; |
1260 | sigemptyset (&action.sa_mask); |
1519 | sigemptyset (&action.sa_mask); |
1261 | action.sa_flags = SA_RESTART; |
1520 | action.sa_flags = SA_RESTART; |
1262 | |
1521 | |
1263 | if (sigaction (sig, &action, NULL) < 0) |
1522 | if (sigaction (sig, &action, NULL) < 0) |
1264 | fprintf (stderr, "sigaction(%d): %s\n", sig, strerror (errno)), exit (1); |
1523 | fprintf (stderr, "sigaction (%d): %s\n", sig, strerror (errno)), exit (1); |
1265 | } |
1524 | } |
1266 | |
1525 | |
1267 | void * |
1526 | void * |
1268 | xstrdup (const char *string) |
1527 | xstrdup (const char *string) |
1269 | { |
1528 | { |
1270 | void *p; |
1529 | void *p; |
1271 | |
1530 | |
1272 | while ((p = strdup (string)) == NULL) |
1531 | while ((p = strdup (string)) == NULL) |
1273 | { |
1532 | { |
1274 | fprintf (stderr, "Memory exhausted in xstrdup().\n"); |
1533 | fprintf (stderr, "Memory exhausted in xstrdup ().\n"); |
1275 | sleep (10); |
1534 | sleep (10); |
1276 | } |
1535 | } |
1277 | |
1536 | |
1278 | return p; |
1537 | return p; |
1279 | } |
1538 | } |
… | |
… | |
1283 | { |
1542 | { |
1284 | void *p; |
1543 | void *p; |
1285 | |
1544 | |
1286 | while ((p = malloc (size)) == NULL) |
1545 | while ((p = malloc (size)) == NULL) |
1287 | { |
1546 | { |
1288 | fprintf (stderr, "Memory exhausted in xmalloc().\n"); |
1547 | fprintf (stderr, "Memory exhausted in xmalloc ().\n"); |
1289 | sleep (10); |
1548 | sleep (10); |
1290 | } |
1549 | } |
1291 | |
1550 | |
1292 | return p; |
1551 | return p; |
1293 | } |
1552 | } |
… | |
… | |
1297 | { |
1556 | { |
1298 | void *p; |
1557 | void *p; |
1299 | |
1558 | |
1300 | while ((p = realloc (ptr, size)) == NULL) |
1559 | while ((p = realloc (ptr, size)) == NULL) |
1301 | { |
1560 | { |
1302 | fprintf (stderr, "Memory exhausted in xrealloc().\n"); |
1561 | fprintf (stderr, "Memory exhausted in xrealloc ().\n"); |
1303 | sleep (10); |
1562 | sleep (10); |
1304 | } |
1563 | } |
1305 | |
1564 | |
1306 | return p; |
1565 | return p; |
1307 | } |
1566 | } |
1308 | |
1567 | |
1309 | void |
1568 | void |
1310 | display_help (char *myname) |
1569 | display_help (char *myname) |
1311 | { |
1570 | { |
1312 | printf ("Usage: %s [options] file1[,color[,desc]] " |
1571 | printf ("Usage: %s [options] file1[,color[,desc]]" |
1313 | "[file2[,color[,desc]] ...]\n", myname); |
1572 | "[options] [file2[,color[,desc]] ...]\n", myname); |
1314 | printf (" -g | -geometry geometry -g WIDTHxHEIGHT+X+Y\n" |
1573 | printf (" -g | -geometry geometry -g WIDTHxHEIGHT+X+Y\n" |
1315 | " -color color use color $color as default\n" |
1574 | " -color color use color $color as default\n" |
1316 | " -reload sec command reload after $sec and run command\n" |
1575 | " -reload sec command reload after $sec and run command\n" |
1317 | " -id id window id to use instead of the root window\n" |
1576 | " -id id window id to use instead of the root window\n" |
1318 | " -font FONTSPEC (-fn) font to use\n" |
1577 | " -font FONTSPEC (-fn) font to use\n" |
… | |
… | |
1353 | case -1: |
1612 | case -1: |
1354 | return -1; |
1613 | return -1; |
1355 | case 0: |
1614 | case 0: |
1356 | break; |
1615 | break; |
1357 | default: |
1616 | default: |
1358 | /*printf("%d\n", pid);*/ |
1617 | /*printf ("%d\n", pid);*/ |
1359 | exit (0); |
1618 | exit (0); |
1360 | } |
1619 | } |
1361 | |
1620 | |
1362 | if (setsid () == -1) |
1621 | if (setsid () == -1) |
1363 | return -1; |
1622 | return -1; |
1364 | |
1623 | |
1365 | return 0; |
1624 | return 0; |
1366 | } |
1625 | } |
|
|
1626 | |
|
|
1627 | /* todo - get reverse display working again */ |