debian/0000755000000000000000000000000012170513030007156 5ustar debian/patches/0000755000000000000000000000000012170513030010605 5ustar debian/patches/0001-test.patch0000644000000000000000000000311011537143770013176 0ustar From: Axel Beckert Date: Mon, 11 Oct 2010 01:18:31 +0200 Subject: test Some more tests. Patch extracted from .diff.gz of 1:0.5-1.1. --- test | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/test b/test index 1dd336e..5ba3c8c 100755 --- a/test +++ b/test @@ -9,3 +9,12 @@ ping -i 5 localhost |./xrootconsole -bw 2 -bd '#000000' -fg 'darkgreen' -bg '#66 # testing long lines, column wrapping #{ while [ 1 ] ; do sleep 1; echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; done; } |./xrootconsole -bw 2 -bd '#000000' -fg '#FF3333' -bg '#660099' --wrap -geometry +100+260 $@ + +#extra newline bug test +#{ z=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; while [ 1 ] ; do sleep 1; z=x$z; echo $z; done; } |./xrootconsole -bw 2 -bd '#000000' -fg '#FF3333' -bg '#660099' --wrap -geometry +100+260 $@ + +#bottomup test +#{ z=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; while [ 1 ] ; do sleep 1; z=x$z; echo $z; done; } |./xrootconsole --bottomup -bw 2 -bd '#000000' -fg '#FF3333' -bg '#660099' --wrap -geometry +100+260 $@ + +#transparency test +#{ z=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; while [ 1 ] ; do sleep 1; z=x$z; echo $z; done; } |./xrootconsole --bottomup -bw 2 -bd '#000000' -fg '#FF3333' --wrap -geometry +100+260 $@ -- debian/patches/0002-bottomup.patch0000644000000000000000000000466411537143770014110 0ustar From: Axel Beckert Date: Mon, 11 Oct 2010 01:18:31 +0200 Subject: bottomup Adds --bottomup option and some bugfixes. Patch extracted from .diff.gz of 1:0.5-1.1. [ Julien Viard de Galbert ] * Modified as in original ANSI patch to put the bottomup init outside of the loop as it really need to be done only once. --- main.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index b21c121..65e80d0 100644 --- a/main.c +++ b/main.c @@ -67,6 +67,7 @@ " -c COLUMNS split window into number of text columns (default 1)\n" \ " --solid make background a solid color, not shaded-transparent\n" \ " --topdown insert lines at the top and scroll the rest down\n" \ +" --bottomup start inserting lines at the bottom\n" \ " --wrap wrap long lines, instead of cutting them off\n" \ " -h or --help a familiar-looking help screen\n" \ " -v or --version displays the version number\n" \ @@ -158,13 +159,13 @@ void put(const char* s, InitOptions *io, case '\t': x = (x / 8 + 1) * 8; - if (x >= ws->cols && io->wrap) put("\n",io,ws,cs); + if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",io,ws,cs); break; default: if (*s >= ' ' && x < ws->colwidth) { cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; - if (++x == ws->colwidth && io->wrap) put("\n",io,ws,cs); + if (++x == ws->colwidth && io->wrap && *(s+1)!='\n') put("\n",io,ws,cs); } break; } @@ -242,6 +243,8 @@ void init_options(char **argv, InitOptions *io) { io->wrap = True; else if (!strcmp(*argv, "--topdown")) io->topdown = True; + else if (!strcmp(*argv, "--bottomup")) + io->topdown = -1234; else if (!strcmp(*argv, "--version") || !strcmp(*argv, "-v")) { fprintf(stderr, "xrootconsole %s\n", XROOTCONSOLE_VERSION); exit(EXIT_SUCCESS); @@ -492,6 +495,13 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; + if (io->topdown == -1234) { + int i; + io->topdown = False; + for (i=0; i < ws->nlines; i++) + put("\n", io, ws, cs); + } + while (1) { while ((XPending(ws->dpy) > 0) && -- debian/patches/0004-xrootconsole-0.5_iso02.patch0000644000000000000000000000134611537143770016305 0ustar From: Miroslav Jezbera Date: Tue, 20 Jul 2004 14:56:06 +0200 Subject: xrootconsole-0.5_iso02 Fix for #260255 (xrootconsole don't display correctly localized messages) Further changed to avoid compilation warnings. --- main.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/main.c b/main.c index 65e80d0..b4594a8 100644 --- a/main.c +++ b/main.c @@ -138,9 +138,10 @@ typedef struct { * put */ -void put(const char* s, InitOptions *io, +void put(const char* st, InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { static int x = 0, y = 0; + const unsigned char* s = (const unsigned char*) st; while (*s != '\0') { switch (*s) { -- debian/patches/0005-whitespace.patch0000644000000000000000000003130411537143770014365 0ustar From: Axel Beckert Date: Sun, 17 Oct 2010 16:26:49 +0200 Subject: whitespace Fixes tons of trailing whitespace which hinder the development of utf8.diff Written by Axel Beckert^W^WGNU Emacs with C-M-% +$ [Julien VdG] * Also updated vim modeline to use regular tab size (8) while still indenting with 4 spaces, left the expandtab option set, so source code should have no tabs. (fixed 1 place). --- main.c | 110 ++++++++++++++++++++++++++++++++-------------------------------- 1 files changed, 55 insertions(+), 55 deletions(-) diff --git a/main.c b/main.c index b4594a8..fd0f0e5 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* vim:set ts=4 sw=4 et: +/* vim:set ts=8 sw=4 sts=4 et: * * main.c * xrootconsole * Original version: Copyright (C) 1998, 1999 Eric Youngblut @@ -108,7 +108,7 @@ typedef struct { typedef struct { int x_root; /* position of the window (in pixels) */ int y_root; - int width; /* size of the window (in pixels) */ + int width; /* size of the window (in pixels) */ int height; unsigned int cols; /* size of the window (in characters) */ unsigned int rows; @@ -118,7 +118,7 @@ typedef struct { Pixmap buf; /* the main drawable, copied to win by exposures */ Pixmap bkg; /* the background pixmap, copied to buf before each drawing */ XFontStruct* fn; /* text font */ - GC foregc; + GC foregc; GC backgc; int colwidth; /* width of a column in characters */ int nlines; /* number of lines to keep in memory */ @@ -142,7 +142,7 @@ void put(const char* st, InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { static int x = 0, y = 0; const unsigned char* s = (const unsigned char*) st; - + while (*s != '\0') { switch (*s) { case '\n': @@ -150,19 +150,19 @@ void put(const char* st, InitOptions *io, if (io->topdown) { cs->pos = (cs->pos + ws->nlines - 1) % ws->nlines; memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); - } + } else if (y == ws->nlines - 1) { memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); cs->pos = (cs->pos + 1) % ws->nlines; } else y++; break; - + case '\t': x = (x / 8 + 1) * 8; if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",io,ws,cs); break; - + default: if (*s >= ' ' && x < ws->colwidth) { cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; @@ -170,7 +170,7 @@ void put(const char* st, InitOptions *io, } break; } - + s++; } } @@ -185,21 +185,21 @@ void draw_pixmap(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { int i,j; /* setup the background */ - XCopyArea(ws->dpy, ws->bkg, ws->buf, ws->foregc, 0, 0, + XCopyArea(ws->dpy, ws->bkg, ws->buf, ws->foregc, 0, 0, ws->width, ws->height, 0, 0); - + /* write the string */ for (i = ws->rows; i>0; --i) { for (j = 0; j < io->tc; ++j) { - XDrawString(ws->dpy, ws->buf, ws->foregc, + XDrawString(ws->dpy, ws->buf, ws->foregc, j * (ws->colwidth * ws->fn->max_bounds.width + ws->intercolgap), - rowp, - cs->text + ((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth), - ws->colwidth); + rowp, + cs->text + ((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth), + ws->colwidth); } rowp += ws->fn->ascent + ws->fn->descent; ++rowc; - } + } } @@ -221,10 +221,10 @@ void init_options(char **argv, InitOptions *io) { io->wrap = DEFAULT_WRAP; io->topdown = DEFAULT_TOPDOWN; io->solid = DEFAULT_SOLID; - + /* Process command-line arguments */ while (*++argv != NULL) { - if (!strcmp(*argv, "-geometry") || !strcmp(*argv, "-geo")) + if (!strcmp(*argv, "-geometry") || !strcmp(*argv, "-geo")) io->geometry = *++argv; else if (!strcmp(*argv, "-font") || !strcmp(*argv, "-fn")) io->font_name = *++argv; @@ -260,12 +260,12 @@ void init_options(char **argv, InitOptions *io) { /* sanity check! */ if (io->tc < 1) io->tc = DEFAULT_TEXT_COLUMNS; } -} +} int open_console(const char* console) { int fd; assert(console!=NULL); - fd = open(console, O_RDONLY|O_NONBLOCK); + fd = open(console, O_RDONLY|O_NONBLOCK); if (fd < 0) { fprintf(stderr,"Console %s can't be opened! ",console); perror("Error"); @@ -282,15 +282,15 @@ void reset_console(ConsoleSettings *cs) { cs->fd = -1; } -void init_console(const char *console, - int colwidth, int nlines, +void init_console(const char *console, + int colwidth, int nlines, ConsoleSettings *cs) { - /* we never modify the name through a ConsoleSettings*, + /* we never modify the name through a ConsoleSettings*, so don't bother copying the string */ cs->console = console; - /* Create the text array. We can display "nlines-1" # of rows, and the + /* Create the text array. We can display "nlines-1" # of rows, and the extra one is for the line being read. */ cs->text = (char*)malloc(colwidth * nlines); memset(cs->text, ' ', colwidth * nlines); @@ -298,7 +298,7 @@ void init_console(const char *console, if (cs->console == NULL) cs->fd = 0; /* STDIN special case, */ else cs->fd = open_console(cs->console); /* or open normal file */ } - + /* Return the root window, or a virtual root window if any. */ static Window root_window(Display *display) { @@ -309,7 +309,7 @@ static Window root_window(Display *display) { unsigned int count; if (XQueryTree(display, DefaultRootWindow (display), &unused, &unused, - &windows, &count)) { + &windows, &count)) { int i; for (i=0; iintercolgap = 0; if (io->geometry) { - ws->geometry = XParseGeometry(io->geometry, + ws->geometry = XParseGeometry(io->geometry, &(ws->x_root), &(ws->y_root), &(ws->cols), &(ws->rows)); } @@ -382,8 +382,8 @@ void init_window(InitOptions *io, WindowSettings *ws) { ws->colwidth = ws->cols / io->tc; if (io->tc > 1) { /* ensure at least a 1 char gap between columns */ - if ((ws->cols - ws->colwidth*io->tc)/(io->tc-1) < 1) --(ws->colwidth); - ws->intercolgap = (ws->cols - ws->colwidth*io->tc) * + if ((ws->cols - ws->colwidth*io->tc)/(io->tc-1) < 1) --(ws->colwidth); + ws->intercolgap = (ws->cols - ws->colwidth*io->tc) * ws->fn->max_bounds.width / (io->tc-1); } @@ -391,12 +391,12 @@ void init_window(InitOptions *io, WindowSettings *ws) { ws->width = ws->cols * ws->fn->max_bounds.width; ws->height = ws->rows * (ws->fn->ascent + ws->fn->descent); ws->x_root = (ws->geometry & XNegative) ? - (DisplayWidth(ws->dpy, DefaultScreen(ws->dpy)) - - ws->width + ws->x_root - (2*io->bw)) : + (DisplayWidth(ws->dpy, DefaultScreen(ws->dpy)) - + ws->width + ws->x_root - (2*io->bw)) : ws->x_root; ws->y_root = (ws->geometry & YNegative) ? - (DisplayHeight(ws->dpy, DefaultScreen(ws->dpy)) - - ws->height + ws->y_root - (2*io->bw)) : + (DisplayHeight(ws->dpy, DefaultScreen(ws->dpy)) - + ws->height + ws->y_root - (2*io->bw)) : ws->y_root; @@ -404,14 +404,14 @@ void init_window(InitOptions *io, WindowSettings *ws) { ws->swa.border_pixel = load_color(io->bd, ws->dpy); ws->swa.event_mask = ExposureMask; ws->swa.override_redirect = True; - - ws->win = XCreateWindow(ws->dpy, root_window(ws->dpy), + + ws->win = XCreateWindow(ws->dpy, root_window(ws->dpy), ws->x_root, ws->y_root, ws->width, ws->height, io->bw, CopyFromParent, CopyFromParent, DefaultVisual(ws->dpy, DefaultScreen(ws->dpy)), CWOverrideRedirect | CWBackPixmap | CWEventMask | CWBorderPixel, &(ws->swa)); - + XMapWindow(ws->dpy, ws->win); /* Create the pixmaps */ @@ -424,25 +424,25 @@ void init_window(InitOptions *io, WindowSettings *ws) { values.font = ws->fn->fid; values.foreground = load_color(io->fg, ws->dpy); values.graphics_exposures = 0; - ws->foregc = XCreateGC(ws->dpy, ws->win, - GCFont | GCForeground | GCGraphicsExposures, + ws->foregc = XCreateGC(ws->dpy, ws->win, + GCFont | GCForeground | GCGraphicsExposures, &values); - + /* initialize the background pixmap */ values.background = values.foreground; values.foreground = load_color(io->bg, ws->dpy); if (io->solid == True) { XLowerWindow(ws->dpy, ws->win); - ws->backgc = XCreateGC(ws->dpy, ws->win, + ws->backgc = XCreateGC(ws->dpy, ws->win, GCForeground | GCBackground, &values); - XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, + XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, ws->width, ws->height); } else { /* shaded/transparent background */ - + values.function = GXand; - ws->backgc = XCreateGC(ws->dpy, ws->win, + ws->backgc = XCreateGC(ws->dpy, ws->win, GCForeground | GCBackground | GCFunction, &values); @@ -450,8 +450,8 @@ void init_window(InitOptions *io, WindowSettings *ws) { XClearWindow(ws->dpy,ws->win); /* take a snapshot for the root pixmap */ - XCopyArea(ws->dpy, ws->win, ws->bkg, ws->foregc, 0, 0, - ws->width, ws->height, 0, 0); + XCopyArea(ws->dpy, ws->win, ws->bkg, ws->foregc, 0, 0, + ws->width, ws->height, 0, 0); /* in order to get the full pixmap we have to wait until the pixmap is copied before lowering the window */ @@ -493,7 +493,7 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { int maxfd; struct timeval select_timeout; XEvent ev; - + maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; if (io->topdown == -1234) { @@ -505,8 +505,8 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { while (1) { - while ((XPending(ws->dpy) > 0) && - (XCheckMaskEvent(ws->dpy, ExposureMask, &ev) == True)) { + while ((XPending(ws->dpy) > 0) && + (XCheckMaskEvent(ws->dpy, ExposureMask, &ev) == True)) { handle_expose((XExposeEvent*)&ev.xexpose, ws); } @@ -518,7 +518,7 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; } - FD_ZERO(&rfds); + FD_ZERO(&rfds); FD_ZERO(&efds); FD_SET(Xfd, &rfds); FD_SET(cs->fd, &rfds); @@ -529,7 +529,7 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { perror("select error"); exit(EXIT_FAILURE); } - + if (FD_ISSET(cs->fd, &rfds)) { char buf[1024]; int n; @@ -543,9 +543,9 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { put(buf,io,ws,cs); draw_pixmap(io,ws,cs); /* make an exposure event */ - XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); + XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); } else { /* n == 0 --> EOF */ - sleep(1); + sleep(1); } } @@ -553,7 +553,7 @@ void event_loop(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { reset_console(cs); sleep(1); } - + } /* end loop */ } @@ -565,7 +565,7 @@ int main(int argc, char** argv) { InitOptions io; ConsoleSettings cs; WindowSettings ws; - + init_options(argv, &io); init_window(&io,&ws); init_console(io.console_name, ws.colwidth, ws.nlines, &cs); @@ -574,11 +574,11 @@ int main(int argc, char** argv) { put("xrootconsole ",&io,&ws,&cs); put(XROOTCONSOLE_VERSION,&io,&ws,&cs); put("\n",&io,&ws,&cs); - + draw_pixmap(&io,&ws,&cs); event_loop(&io,&ws,&cs); - + XCloseDisplay(ws.dpy); exit(EXIT_SUCCESS); } -- debian/patches/series0000644000000000000000000000051712170350620012031 0ustar 0001-test.patch 0002-bottomup.patch 0003-build-options.patch 0004-xrootconsole-0.5_iso02.patch 0005-whitespace.patch 0006-utf8.patch 0007-nautilus-support.patch 0008-non-zero-ending-strings.patch 0009-ansi-color.patch 0010-no-sleep-in-event-loop.patch 0011-detect-background-changes.patch 0012-fix-segfault-on-empty-bw-parameter.patch debian/patches/0003-build-options.patch0000644000000000000000000000201712170344772015015 0ustar From: Axel Beckert Date: Mon, 11 Oct 2010 01:18:31 +0200 Subject: build-options Patch initially extracted from .diff.gz of 1:0.5-1.1. Updated with 1:0.6-3 to work properly with dpkg-buildflags --- Makefile | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) Index: xrootconsole/Makefile =================================================================== --- xrootconsole.orig/Makefile 2013-07-13 23:32:46.110181497 +0200 +++ xrootconsole/Makefile 2013-07-13 23:33:03.910030520 +0200 @@ -44,19 +44,17 @@ fi;) CC = gcc -CPPFLAGS = # for production -CFLAGS = -O2 -DNDEBUG -Wall "-DXROOTCONSOLE_VERSION=\"$(VERSION)\"" \ +CFLAGS += -Wall "-DXROOTCONSOLE_VERSION=\"$(VERSION)\"" \ -I /usr/X11R6/include -LDFLAGS = -s # for testing #CFLAGS = -g -Wall "-DXROOTCONSOLE_VERSION=\"$(VERSION) (debug build)\"" \ - -I /usr/X11R6/include +# -I /usr/X11R6/include #LDFLAGS = -LIBS = -L/usr/X11R6/lib -lX11 -lutil +LIBS = -L/usr/X11R6/lib -lX11 OBJS = main.o util.o debian/patches/0006-utf8.patch0000644000000000000000000001335212170513030013103 0ustar From: Axel Beckert Date: Sun, 17 Oct 2010 16:26:49 +0200 Subject: utf8 Add multibyte character/UTF-8 support. Patch by Axel Beckert and inspired by the multibyte/UTF-8 patch for ratmen/ratmenu which fixed #531036. --- main.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 42 insertions(+), 11 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 13:44:54.184912631 +0200 +++ xrootconsole/main.c 2013-07-14 13:52:13.042189822 +0200 @@ -49,6 +49,7 @@ #include #include #include +#include #ifndef XROOTCONSOLE_VERSION #define XROOTCONSOLE_VERSION "undefined" @@ -117,7 +118,10 @@ Window win; Pixmap buf; /* the main drawable, copied to win by exposures */ Pixmap bkg; /* the background pixmap, copied to buf before each drawing */ - XFontStruct* fn; /* text font */ + XFontSet fn; /* text font */ + XFontSetExtents *extent; + short font_ascent; + short font_descent; GC foregc; GC backgc; int colwidth; /* width of a column in characters */ @@ -181,7 +185,7 @@ */ void draw_pixmap(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { int rowc = cs->pos + (io->topdown==True); /* row in caracters */ - int rowp = ws->fn->ascent; /* row in pixels */ + int rowp = ws->font_ascent; /* row in pixels */ int i,j; /* setup the background */ @@ -191,13 +195,13 @@ /* write the string */ for (i = ws->rows; i>0; --i) { for (j = 0; j < io->tc; ++j) { - XDrawString(ws->dpy, ws->buf, ws->foregc, - j * (ws->colwidth * ws->fn->max_bounds.width + ws->intercolgap), + XmbDrawString(ws->dpy, ws->buf, ws->fn, ws->foregc, + j * (ws->colwidth * ws->extent->max_logical_extent.width + ws->intercolgap), rowp, cs->text + ((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth), ws->colwidth); } - rowp += ws->fn->ascent + ws->fn->descent; + rowp += ws->font_ascent + ws->font_descent; ++rowc; } } @@ -376,6 +380,7 @@ } ws->fn = load_font(io->font_name, ws->dpy); + ws->extent = XExtentsOfFontSet(ws->fn); /* compute text column geometry */ ws->nlines = ws->rows * io->tc + 1; @@ -384,12 +389,15 @@ /* ensure at least a 1 char gap between columns */ if ((ws->cols - ws->colwidth*io->tc)/(io->tc-1) < 1) --(ws->colwidth); ws->intercolgap = (ws->cols - ws->colwidth*io->tc) * - ws->fn->max_bounds.width / (io->tc-1); + ws->extent->max_logical_extent.width / (io->tc-1); } /* Calculate the position of window on the screen */ - ws->width = ws->cols * ws->fn->max_bounds.width; - ws->height = ws->rows * (ws->fn->ascent + ws->fn->descent); + ws->font_ascent = ws->extent->max_logical_extent.height * 4 / 5; + ws->font_descent = ws->extent->max_logical_extent.height / 5; + + ws->width = ws->cols * ws->extent->max_logical_extent.width; + ws->height = ws->rows * (ws->font_ascent + ws->font_descent); ws->x_root = (ws->geometry & XNegative) ? (DisplayWidth(ws->dpy, DefaultScreen(ws->dpy)) - ws->width + ws->x_root - (2*io->bw)) : @@ -421,11 +429,10 @@ DefaultDepth(ws->dpy, DefaultScreen(ws->dpy))); /* Create the foreground GC */ - values.font = ws->fn->fid; values.foreground = load_color(io->fg, ws->dpy); values.graphics_exposures = 0; ws->foregc = XCreateGC(ws->dpy, ws->win, - GCFont | GCForeground | GCGraphicsExposures, + GCForeground | GCGraphicsExposures, &values); /* initialize the background pixmap */ @@ -566,6 +573,8 @@ ConsoleSettings cs; WindowSettings ws; + setlocale(LC_CTYPE, ""); + init_options(argv, &io); init_window(&io,&ws); init_console(io.console_name, ws.colwidth, ws.nlines, &cs); Index: xrootconsole/util.c =================================================================== --- xrootconsole.orig/util.c 2013-07-14 13:44:54.184912631 +0200 +++ xrootconsole/util.c 2013-07-14 13:52:53.770308989 +0200 @@ -38,14 +38,30 @@ #include "util.h" #include #include +#include +XFontSet XLoadQueryFontSet(Display *disp, const char *fontset_name) +{ + XFontSet fontset; + int missing_charset_count; + char **missing_charset_list; + char *def_string; + fontset = XCreateFontSet(disp, fontset_name, + &missing_charset_list, &missing_charset_count, + &def_string); + if (missing_charset_count /* && debug */) { + fprintf(stderr, "Missing charsets in FontSet(%s) creation.\n", fontset_name); + XFreeStringList(missing_charset_list); + } + return fontset; +} -XFontStruct* load_font(const char* s, Display *dpy) { - XFontStruct* f = XLoadQueryFont(dpy, s); +XFontSet* load_font(const char* s, Display *dpy) { + XFontSet* f = XLoadQueryFontSet(dpy, s); if (f == NULL) { - fprintf(stderr, "Unable to open font"); + fprintf(stderr, "Unable to open font '%s'\n", s); exit(EXIT_FAILURE); } return f; Index: xrootconsole/util.h =================================================================== --- xrootconsole.orig/util.h 2013-07-14 13:44:54.184912631 +0200 +++ xrootconsole/util.h 2013-07-14 13:53:41.010445250 +0200 @@ -39,10 +39,11 @@ #include +#include -XFontStruct* load_font(const char* s, Display *dpy); +XFontSet* load_font(const char* s, Display *dpy); unsigned long load_color(const char* s, Display *dpy); debian/patches/0007-nautilus-support.patch0000644000000000000000000000440212170513030015570 0ustar From: Julien Viard de Galbert Date: Sun, 24 Oct 2010 19:13:15 +0200 Subject: nautilus-support Detecting Nautilus and using it instead of the root window if present. Code highly inspired from root-tail's code (http://root-tail.plan9.de/). --- main.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:09:53.225085145 +0200 +++ xrootconsole/main.c 2013-07-14 14:09:53.217085131 +0200 @@ -307,6 +307,29 @@ /* Return the root window, or a virtual root window if any. */ static Window root_window(Display *display) { Atom __SWM_VROOT = XInternAtom(display, "__SWM_VROOT", False); + Atom NAUTILUS_DESKTOP_WINDOW_ID = XInternAtom (display, "NAUTILUS_DESKTOP_WINDOW_ID", False); + Window root = DefaultRootWindow (display); + + /* First check for Nautilus */ + if (NAUTILUS_DESKTOP_WINDOW_ID != None) { + Atom type; + int format; + unsigned long nitems, bytes_after_return; + Window *virtual_root_window; + if (XGetWindowProperty (display, root, NAUTILUS_DESKTOP_WINDOW_ID, + 0, 1, False, XA_WINDOW, &type, &format, + &nitems, &bytes_after_return, + (unsigned char **) &virtual_root_window) == Success + && type == XA_WINDOW) { + Window unused, *windows = 0; + unsigned int count; + if (XQueryTree (display, *(Window *)virtual_root_window, &unused, &unused, &windows, &count)) { + XFree (virtual_root_window); + return windows[count - 1]; + } + XFree (virtual_root_window); + } + } if (__SWM_VROOT != None) { Window unused, *windows; @@ -346,14 +369,14 @@ XFree(windows); } else { fprintf(stderr, "Can't query tree on root window 0x%lx", - DefaultRootWindow (display)); + root); } } else { /* This shouldn't happen. The Xlib documentation is wrong BTW. */ fprintf (stderr, "Can't intern atom __SWM_VROOT"); } - return DefaultRootWindow (display); + return root; } debian/patches/0008-non-zero-ending-strings.patch0000644000000000000000000000530412170513030016715 0ustar From: Julien Viard de Galbert Date: Tue, 16 Nov 2010 18:14:46 +0100 Subject: non-zero-ending-strings * Don't rely on end of string being \0 This will fix colortail support as it sends some \0 --- main.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:10:00.117104123 +0200 +++ xrootconsole/main.c 2013-07-14 14:10:00.085104033 +0200 @@ -142,12 +142,12 @@ * put */ -void put(const char* st, InitOptions *io, +void put(const char* st, int len, InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { static int x = 0, y = 0; const unsigned char* s = (const unsigned char*) st; - while (*s != '\0') { + while ( (len==-1)?(*s != '\0'):(len-->0) ) { switch (*s) { case '\n': x = 0; @@ -164,13 +164,13 @@ case '\t': x = (x / 8 + 1) * 8; - if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",io,ws,cs); + if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); break; default: if (*s >= ' ' && x < ws->colwidth) { cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; - if (++x == ws->colwidth && io->wrap && *(s+1)!='\n') put("\n",io,ws,cs); + if (++x == ws->colwidth && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); } break; } @@ -530,7 +530,7 @@ int i; io->topdown = False; for (i=0; i < ws->nlines; i++) - put("\n", io, ws, cs); + put("\n", 1, io, ws, cs); } while (1) { @@ -564,13 +564,12 @@ char buf[1024]; int n; - n = read(cs->fd, buf, sizeof(buf) - 1); + n = read(cs->fd, buf, sizeof(buf)); if (n == -1) { sleep(1); if (errno != EAGAIN) {reset_console(cs);} } else if (n > 0) { - buf[n] = '\0'; - put(buf,io,ws,cs); + put(buf,n,io,ws,cs); draw_pixmap(io,ws,cs); /* make an exposure event */ XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); @@ -603,9 +602,9 @@ init_console(io.console_name, ws.colwidth, ws.nlines, &cs); /* Display a message */ - put("xrootconsole ",&io,&ws,&cs); - put(XROOTCONSOLE_VERSION,&io,&ws,&cs); - put("\n",&io,&ws,&cs); + put("xrootconsole ",-1,&io,&ws,&cs); + put(XROOTCONSOLE_VERSION,-1,&io,&ws,&cs); + put("\n",1,&io,&ws,&cs); draw_pixmap(&io,&ws,&cs); debian/patches/0009-ansi-color.patch0000644000000000000000000004764012170513030014275 0ustar From: Julien Viard de Galbert Date: Wed, 1 Apr 2009 23:42:39 +0200 Subject: ansi-color Origin: http://silicone.homelinux.org/2009/04/02/ansi-color-support-for-xrootconsole/ Slightly modified by Axel Beckert to work together with the UTF-8 support of the previous patch. Later updated by Julien Vdg (original author) * Handle multiple SRG parameters * Fix c++ style comments * So now both colortail and lwatch should be supported. * Add --ansi-color to enable the feature --- main.c | 362 +++++++++++++++++++++++++++++++++++++++++++++++++++----- test | 3 + xrootconsole.1 | 2 + 3 files changed, 337 insertions(+), 30 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:10:04.693116723 +0200 +++ xrootconsole/main.c 2013-07-14 14:10:04.681116686 +0200 @@ -10,6 +10,13 @@ * $Id: main.c,v 1.13 2004/02/20 22:31:53 bob Exp $ * * + * ANSI colors: Copyright (C) 2009, 2010 Julien Viard de Galbert + * | ref: http://en.wikipedia.org/wiki/ANSI_escape_code + * | + * | TODO: allow customizing color table from cmd line ? + * | + * | usage: tail -f /var/log/messages | stdbuf -oL ccze -A | xrootconsole --ansi-color + * * * ************************************************************************** @@ -70,6 +77,7 @@ " --topdown insert lines at the top and scroll the rest down\n" \ " --bottomup start inserting lines at the bottom\n" \ " --wrap wrap long lines, instead of cutting them off\n" \ +" --ansi-color enable ANSI escape sequence parsing for color support\n"\ " -h or --help a familiar-looking help screen\n" \ " -v or --version displays the version number\n" \ " [console] filename to read (defaults to standard input)\n" \ @@ -77,6 +85,52 @@ "Report bugs to .\n" +#define ESC_SEQ_START 0x10000 +#define ESC_SEQ_CONT 0x20000 +#define ESC_SEQ_DATA_MASK 0xFFFF + + +#define REND_DEFAULT 0 +#define REND_FG_COLOR_MASK 0x0007 +#define REND_FG_SET_COLOR 0x0008 +#define REND_FG_FULLCOLOR_MASK (REND_FG_COLOR_MASK | REND_FG_SET_COLOR) +#define REND_FG_COLOR(c) (REND_FG_SET_COLOR + ((c) & REND_FG_COLOR_MASK)) +#define REND_FG_COLOR_GET(r) (r & REND_FG_COLOR_MASK) +#define REND_BG_COLOR_MASK 0x0070 +#define REND_BG_SET_COLOR 0x0080 +#define REND_BG_FULLCOLOR_MASK (REND_BG_COLOR_MASK | REND_BG_SET_COLOR) +#define REND_BG_COLOR(c) (REND_BG_SET_COLOR + (((c)<<4) & REND_BG_COLOR_MASK)) +#define REND_BG_COLOR_GET(r) ((r & REND_BG_COLOR_MASK)>>4) + +#define REND_BOLD 0x0100 /* used as fg high intensity */ +#define REND_BLINK 0x0200 /* used as bg high intensity */ +#define REND_ULINE 0x0400 +#define REND_RVIDEO 0x0800 + +static const char *def_colorName[] = +{ +/* low-intensity colors */ + "Black", /* 0: black (#000000) */ + "Red3", /* 1: red (#CD0000) */ + "Green3", /* 2: green (#00CD00) */ +// "Yellow3", /* 3: yellow (#CDCD00) */ + "#AB5700", /* 3: brown actually (EGA/DOS ANSY.SYS compatible) */ + "Blue3", /* 4: blue (#0000CD) */ + "Magenta3", /* 5: magenta (#CD00CD) */ + "Cyan3", /* 6: cyan (#00CDCD) */ + "AntiqueWhite", /* 7: white (#FAEBD7) */ +/* high-intensity colors */ + "Grey25", /* 8: bright black (#404040) */ + "Red", /* 9: bright red (#FF0000) */ + "Green", /* 10: bright green (#00FF00) */ + "Yellow", /* 11: bright yellow (#FFFF00) */ + "Blue", /* 12: bright blue (#0000FF) */ + "Magenta", /* 13: bright magenta (#FF00FF) */ + "Cyan", /* 14: bright cyan (#00FFFF) */ + "White", /* 15: bright white (#FFFFFF) */ +}; + + #define DEFAULT_X 0 #define DEFAULT_Y 0 #define DEFAULT_COLS 80 @@ -90,6 +144,7 @@ #define DEFAULT_WRAP False #define DEFAULT_TOPDOWN False #define DEFAULT_SOLID False +#define DEFAULT_ANSI False typedef struct { @@ -104,6 +159,7 @@ int wrap; int topdown; int solid; + int ansi; } InitOptions; typedef struct { @@ -128,15 +184,86 @@ int nlines; /* number of lines to keep in memory */ int intercolgap; /* width between two columns */ XSetWindowAttributes swa; + unsigned long colortable[16]; + unsigned long fgcolor; + unsigned long bgcolor; } WindowSettings; typedef struct { const char* console; /* name of the console file */ int fd; /* file descriptor of the console file */ char* text; /* circular buffer to store the characters */ + short* rend; /* circular buffer to store the rendition options */ int pos; /* where the actual first line in text is */ + int escapeseq; /* we are in an escape sequence */ + short currend; /* current renditions options */ + short tmprend; /* temporary renditions options (to handle ; )*/ } ConsoleSettings; +/* decode SGR */ +static short select_graphic_rendition(short rendition, int code) +{ + switch(code) { + case 0: + rendition = REND_DEFAULT; + break; + case 1: + rendition |= REND_BOLD; + break; + case 4: + rendition |= REND_ULINE; + break; + case 5: + rendition |= REND_BLINK; + break; + case 7: + rendition |= REND_RVIDEO; + break; + case 22: + rendition &= ~REND_BOLD; + break; + case 24: + rendition &= ~REND_ULINE; + break; + case 25: + rendition &= ~REND_BLINK; + break; + case 27: + rendition &= ~REND_RVIDEO; + break; + + case 30: + case 31: /* set fg color */ + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + rendition = (rendition & ~REND_FG_FULLCOLOR_MASK) + | REND_FG_COLOR(code-30); + break; + case 39: /* default fg */ + rendition = rendition & ~REND_FG_FULLCOLOR_MASK; + break; + + case 40: + case 41: /* set bg color */ + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + rendition = (rendition & ~REND_BG_FULLCOLOR_MASK) + | REND_BG_COLOR(code-40); + break; + case 49: /* default bg */ + rendition = rendition & ~REND_BG_FULLCOLOR_MASK; + break; + } + return rendition; +} /* * put @@ -148,44 +275,183 @@ const unsigned char* s = (const unsigned char*) st; while ( (len==-1)?(*s != '\0'):(len-->0) ) { - switch (*s) { - case '\n': - x = 0; - if (io->topdown) { - cs->pos = (cs->pos + ws->nlines - 1) % ws->nlines; - memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); + /* For escape sequence we assume we got only supported commands + ie COLOR only */ + /* really entering : ESC[ ? */ + if (ESC_SEQ_START==cs->escapeseq) { + if (*s == '[') { + /* yes, continue with escape seq */ + cs->escapeseq = ESC_SEQ_CONT; + /* handle ESC[m -> ESC[0m special case */ + cs->tmprend = REND_DEFAULT; } - else if (y == ws->nlines - 1) { - memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); - cs->pos = (cs->pos + 1) % ws->nlines; + else { + /* no fall back to normal string processing */ + cs->escapeseq = False; } - else y++; - break; - - case '\t': - x = (x / 8 + 1) * 8; - if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); - break; + } - default: - if (*s >= ' ' && x < ws->colwidth) { - cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; - if (++x == ws->colwidth && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); + /* inside an escape sequence ? */ + if (cs->escapeseq) { + switch (*s) { + case '[': + break; /* already treated */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + cs->escapeseq = ESC_SEQ_CONT | ((cs->escapeseq & ESC_SEQ_DATA_MASK) * 10 + *s - '0'); + /* at least one char, so not ESC[m, behave like a modif */ + cs->tmprend = cs->currend; + break; + case ';': + cs->tmprend = select_graphic_rendition(cs->tmprend, cs->escapeseq & ESC_SEQ_DATA_MASK); + break; + case 'm': + cs->currend = select_graphic_rendition(cs->tmprend, cs->escapeseq & ESC_SEQ_DATA_MASK); + default: + cs->escapeseq = False; + } + } + else { + switch (*s) { + case '\n': + if (io->topdown) { + cs->pos = (cs->pos + ws->nlines - 1) % ws->nlines; + memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); + if (io->ansi) { + for(x = 0; x < ws->colwidth; x++) { + cs->rend[cs->pos * ws->colwidth + x] = cs->currend; + } + } + } + else if (y == ws->nlines - 1) { + memset(cs->text + cs->pos * ws->colwidth, ' ', ws->colwidth); + if (io->ansi) { + for(x = 0; x < ws->colwidth; x++) { + cs->rend[cs->pos * ws->colwidth + x] = cs->currend; + } + } + cs->pos = (cs->pos + 1) % ws->nlines; + } + else y++; + x = 0; + break; + + case '\t': + x = (x / 8 + 1) * 8; + if (x >= ws->cols && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); + break; + + case '\033': /* ESC */ + /* enter escape sequence start mode */ + if (io->ansi) cs->escapeseq = ESC_SEQ_START; + break; + + default: + if (*s >= ' ' && x < ws->colwidth) { + cs->text[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = *s; + if (io->ansi) { + cs->rend[x + ((y + cs->pos) % ws->nlines) * ws->colwidth] = cs->currend; + } + if (++x == ws->colwidth && io->wrap && *(s+1)!='\n') put("\n",1,io,ws,cs); + } + break; } - break; } s++; } } +void draw_textline(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs, int x, int y, int offset, int length) +{ + XGCValues values; + int len; + short rend = REND_DEFAULT; + + while (length > 0) { + rend = cs->rend[offset]; + len = 1; + /* search longer segment with same color */ + while ((cs->rend[offset+len] == rend) && (len < length)) len ++; + + if (rend & REND_FG_SET_COLOR) { + values.foreground = ws->colortable[REND_FG_COLOR_GET(rend) + ((rend & REND_BOLD)?8:0) ]; + } + else { + values.foreground = ws->fgcolor; + } + + //printf("len:%3d rend: %04x\n",len, rend); + + if (rend & (REND_BG_SET_COLOR | REND_RVIDEO) ) { + if (rend & REND_RVIDEO) { + values.background = values.foreground; + if (rend & REND_BG_SET_COLOR) { + values.foreground = ws->colortable[REND_BG_COLOR_GET(rend) + ((rend & REND_BLINK)?8:0) ]; + } + else { + if (io->solid == True) { + values.foreground = ws->bgcolor; + } + else { + /* transparent mode use AND so it make bg darker + * just make the letters black, could be too dark, + * but probably more readable */ + values.foreground = ws->colortable[0]; + } + } + } + else { + values.background = ws->colortable[REND_BG_COLOR_GET(rend) + ((rend & REND_BLINK)?8:0) ]; + } + XChangeGC(ws->dpy, ws->foregc, GCForeground | GCBackground, &values); + XmbDrawImageString(ws->dpy, ws->buf, ws->fn, ws->foregc, + x, + y, + cs->text + offset, + len); + } + else { + XChangeGC(ws->dpy, ws->foregc, GCForeground, &values); + XmbDrawString(ws->dpy, ws->buf, ws->fn, ws->foregc, + x, + y, + cs->text + offset, + len); + } + if (rend & REND_BOLD) { + XmbDrawString(ws->dpy, ws->buf, ws->fn, ws->foregc, + x+1, + y, + cs->text + offset, + len); + } + length -= len; + offset += len; + x += len * ws->extent->max_logical_extent.width; /* can be error !!!! */ + } + + /* restore rendering options */ + if(rend != REND_DEFAULT) { + values.foreground = ws->fgcolor; + XChangeGC(ws->dpy, ws->foregc, GCForeground, &values); + } +} /* * write the text in the pixmap */ void draw_pixmap(InitOptions *io, WindowSettings *ws, ConsoleSettings *cs) { int rowc = cs->pos + (io->topdown==True); /* row in caracters */ - int rowp = ws->font_ascent; /* row in pixels */ + int rowp = ws->font_ascent; /* row in pixels */ int i,j; /* setup the background */ @@ -195,11 +461,17 @@ /* write the string */ for (i = ws->rows; i>0; --i) { for (j = 0; j < io->tc; ++j) { - XmbDrawString(ws->dpy, ws->buf, ws->fn, ws->foregc, - j * (ws->colwidth * ws->extent->max_logical_extent.width + ws->intercolgap), - rowp, - cs->text + ((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth), - ws->colwidth); + int x, offset; + x=j * (ws->colwidth * ws->extent->max_logical_extent.width + ws->intercolgap); + offset=((rowc + j*(ws->rows)) % ws->nlines)*(ws->colwidth); + if (io->ansi) { + draw_textline(io, ws, cs, + x, rowp, offset, ws->colwidth); + } + else { + XmbDrawString(ws->dpy, ws->buf, ws->fn, ws->foregc, + x, rowp, cs->text + offset, ws->colwidth); + } } rowp += ws->font_ascent + ws->font_descent; ++rowc; @@ -225,6 +497,7 @@ io->wrap = DEFAULT_WRAP; io->topdown = DEFAULT_TOPDOWN; io->solid = DEFAULT_SOLID; + io->ansi = DEFAULT_ANSI; /* Process command-line arguments */ while (*++argv != NULL) { @@ -250,6 +523,8 @@ io->topdown = True; else if (!strcmp(*argv, "--bottomup")) io->topdown = -1234; + else if (!strcmp(*argv, "--ansi-color")) + io->ansi = True; else if (!strcmp(*argv, "--version") || !strcmp(*argv, "-v")) { fprintf(stderr, "xrootconsole %s\n", XROOTCONSOLE_VERSION); exit(EXIT_SUCCESS); @@ -284,10 +559,14 @@ if (cs->console == NULL) exit(EXIT_SUCCESS); close(cs->fd); cs->fd = -1; + cs->escapeseq = False; + cs->currend = REND_DEFAULT; + cs->tmprend = REND_DEFAULT; } void init_console(const char *console, int colwidth, int nlines, + int ansi, ConsoleSettings *cs) { /* we never modify the name through a ConsoleSettings*, @@ -298,9 +577,20 @@ extra one is for the line being read. */ cs->text = (char*)malloc(colwidth * nlines); memset(cs->text, ' ', colwidth * nlines); + /* Create rendering info array */ + if (ansi) { + cs->rend = (short*)malloc(colwidth * nlines * sizeof(short)); + memset(cs->rend, 0, colwidth * nlines * sizeof(short)); + } + else { + cs->rend = NULL; + } cs->pos = 0; if (cs->console == NULL) cs->fd = 0; /* STDIN special case, */ else cs->fd = open_console(cs->console); /* or open normal file */ + cs->escapeseq = False; + cs->currend = REND_DEFAULT; + cs->tmprend = REND_DEFAULT; } @@ -451,8 +741,20 @@ ws->buf = XCreatePixmap(ws->dpy, ws->win, ws->width, ws->height, DefaultDepth(ws->dpy, DefaultScreen(ws->dpy))); + /* build colortable */ + ws->fgcolor = load_color(io->fg, ws->dpy); + ws->bgcolor = load_color(io->bg, ws->dpy); + + if (io->ansi) { + int i; + for(i = 0; i < 16; i ++) + { + ws->colortable[i] = load_color(def_colorName[i], ws->dpy); + } + } + /* Create the foreground GC */ - values.foreground = load_color(io->fg, ws->dpy); + values.foreground = ws->fgcolor; values.graphics_exposures = 0; ws->foregc = XCreateGC(ws->dpy, ws->win, GCForeground | GCGraphicsExposures, @@ -460,7 +762,7 @@ /* initialize the background pixmap */ values.background = values.foreground; - values.foreground = load_color(io->bg, ws->dpy); + values.foreground = ws->bgcolor; if (io->solid == True) { XLowerWindow(ws->dpy, ws->win); @@ -599,7 +901,7 @@ init_options(argv, &io); init_window(&io,&ws); - init_console(io.console_name, ws.colwidth, ws.nlines, &cs); + init_console(io.console_name, ws.colwidth, ws.nlines, io.ansi, &cs); /* Display a message */ put("xrootconsole ",-1,&io,&ws,&cs); Index: xrootconsole/test =================================================================== --- xrootconsole.orig/test 2013-07-14 14:10:04.693116723 +0200 +++ xrootconsole/test 2013-07-14 14:10:04.681116686 +0200 @@ -18,3 +18,6 @@ #transparency test #{ z=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; while [ 1 ] ; do sleep 1; z=x$z; echo $z; done; } |./xrootconsole --bottomup -bw 2 -bd '#000000' -fg '#FF3333' --wrap -geometry +100+260 $@ + +#ansi color test +# echo -ne "\e[mNormal \e[30mBlack \e[31mRed \e[32mGreen \e[33mBrown \e[34mBlue \e[35mMagena \e[36mCyan \e[37mWhite \e[39mNormal\n\e[1mBold \e[30mBlack \e[31mRed \e[32mGreen \e[33mYellow \e[34mBlue \e[35mMagena \e[36mCyan \e[37mWhite \e[39mNormal\n\e[mNormal \e[40mBlack \e[41mRed \e[42mGreen \e[43mBrown \e[44mBlue \e[45mMagena \e[46mCyan \e[47mWhite \e[49mNormal\n\e[5mBlink \e[40mBlack \e[41mRed \e[42mGreen \e[43mYellow \e[44mBlue \e[45mMagena \e[46mCyan \e[47mWhite \e[49mNormal\n\e[7mInvert" |./xrootconsole -fg '#9966FF' Index: xrootconsole/xrootconsole.1 =================================================================== --- xrootconsole.orig/xrootconsole.1 2013-07-14 14:10:04.693116723 +0200 +++ xrootconsole/xrootconsole.1 2013-07-14 14:10:04.681116686 +0200 @@ -45,6 +45,8 @@ .It Fl -wrap Rather than truncating long lines, this option specifies that xrootconsole should wrap excess text to the following line or lines, as necessary. +.It Fl -ansi-color +Enable color support by parsing ANSI escape sequences. .It Fl geometry Ar geometry This option specifies the preferred size and position of the window; see .Xr X 1 . debian/patches/0010-no-sleep-in-event-loop.patch0000644000000000000000000000573212170513030016427 0ustar From: Julien Viard de Galbert Date: Tue, 16 Nov 2010 22:44:18 +0100 Subject: no sleep in event loop This is to close Bug #301137, instead of reducing sleep time, I removed the sleep calls. The idea behind that is to always select of the X file descriptor but optionally select the input file, the when it was sleeping before, now it just ignore this file descriptor. The result is that xrootconsole react fast to all X events while still pool the input file every seconds in case of eof or error. In case of using a pipe it's even better the select will stop only when data arrives! (of X events of course) --- main.c | 27 ++++++++++++++++++--------- 1 files changed, 18 insertions(+), 9 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:10:17.905153117 +0200 +++ xrootconsole/main.c 2013-07-14 14:10:17.893153084 +0200 @@ -57,6 +57,7 @@ #include #include #include +#include #ifndef XROOTCONSOLE_VERSION #define XROOTCONSOLE_VERSION "undefined" @@ -823,8 +824,9 @@ fd_set efds; int Xfd = ConnectionNumber(ws->dpy); int maxfd; - struct timeval select_timeout; + struct timeval select_timeout, *pselect_timeout; XEvent ev; + time_t now=0, nofile_time=0; maxfd = (cs->fd > Xfd ? cs->fd : Xfd) + 1; @@ -853,14 +855,21 @@ FD_ZERO(&rfds); FD_ZERO(&efds); FD_SET(Xfd, &rfds); - FD_SET(cs->fd, &rfds); - FD_SET(cs->fd, &efds); - select_timeout.tv_sec = 5; - select_timeout.tv_usec = 0; - if (select(maxfd, &rfds, NULL, &efds, &select_timeout) == -1) { + if(nofile_time>now) { + select_timeout.tv_sec = nofile_time-now; + select_timeout.tv_usec = 0; + pselect_timeout = &select_timeout; + } + else { + FD_SET(cs->fd, &rfds); + FD_SET(cs->fd, &efds); + pselect_timeout = NULL; + } + if (select(maxfd, &rfds, NULL, &efds, pselect_timeout) == -1) { perror("select error"); exit(EXIT_FAILURE); } + time(&now); if (FD_ISSET(cs->fd, &rfds)) { char buf[1024]; @@ -868,7 +877,7 @@ n = read(cs->fd, buf, sizeof(buf)); if (n == -1) { - sleep(1); + nofile_time = now+1; if (errno != EAGAIN) {reset_console(cs);} } else if (n > 0) { put(buf,n,io,ws,cs); @@ -876,13 +885,13 @@ /* make an exposure event */ XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); } else { /* n == 0 --> EOF */ - sleep(1); + nofile_time = now+1; } } else if (FD_ISSET(cs->fd, &efds)) { reset_console(cs); - sleep(1); + nofile_time = now+1; } } /* end loop */ debian/patches/0011-detect-background-changes.patch0000644000000000000000000001231212170513030017177 0ustar From: Julien Viard de Galbert Date: Sun, 21 Nov 2010 10:59:32 +0100 Subject: detect background changes Implementing pseudo transparency the eterm way, in particular the way to detect background changes. --- main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 74 insertions(+), 7 deletions(-) Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:10:23.021167210 +0200 +++ xrootconsole/main.c 2013-07-14 14:10:22.997167144 +0200 @@ -173,8 +173,10 @@ int geometry; Display* dpy; Window win; + Window root; /* the detected root window */ Pixmap buf; /* the main drawable, copied to win by exposures */ Pixmap bkg; /* the background pixmap, copied to buf before each drawing */ + Pixmap root_pix; /* the pixmap of root window fetched from atom */ XFontSet fn; /* text font */ XFontSetExtents *extent; short font_ascent; @@ -670,6 +672,52 @@ return root; } +int check_update_background(WindowSettings *ws) { + Atom prop_root, type; + int format; + unsigned long length, after; + unsigned char *data_root; + Pixmap p; + + prop_root = XInternAtom(ws->dpy, "_XROOTPMAP_ID", True); + if (prop_root == None) return False; + + /* check on the previously detected root window */ + XGetWindowProperty(ws->dpy, ws->root, prop_root, 0L, 1L, False, + AnyPropertyType, &type, &format, &length, &after, &data_root); + if (type != XA_PIXMAP) { + /* try default root window */ + Window root = DefaultRootWindow (ws->dpy); + XGetWindowProperty(ws->dpy, root, prop_root, 0L, 1L, False, + AnyPropertyType, &type, &format, &length, &after, &data_root); + /* update the detected root window, what's important is where the atom + * is for now! */ + if (type == XA_PIXMAP && data_root) + ws->root = root; + } + /* none found, exit */ + /* maybe ... if it does not work for some users, I should import the + * full searching code from eterm ... at least if eterm works for them ! */ + if (type != XA_PIXMAP || !data_root) return False; + p=*((Pixmap *)data_root); + XFree(data_root); + if (p==None) return False; + /* pixmap not changed ? */ + if (ws->root_pix == p) return False; + ws->root_pix = p; + + /* take a snapshot for the root pixmap */ + XCopyArea(ws->dpy, ws->root_pix, ws->bkg, ws->foregc, + ws->x_root, ws->y_root, + ws->width, ws->height, 0, 0); + + /* AND-shade the background */ + XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, + ws->width, ws->height); + + /* background pixmap was updated */ + return True; +} void init_window(InitOptions *io, WindowSettings *ws) { XGCValues values; @@ -727,7 +775,8 @@ ws->swa.event_mask = ExposureMask; ws->swa.override_redirect = True; - ws->win = XCreateWindow(ws->dpy, root_window(ws->dpy), + ws->root = root_window(ws->dpy); + ws->win = XCreateWindow(ws->dpy, ws->root, ws->x_root, ws->y_root, ws->width, ws->height, io->bw, CopyFromParent, CopyFromParent, DefaultVisual(ws->dpy, DefaultScreen(ws->dpy)), @@ -782,17 +831,25 @@ /* fill the window with root pixmap */ XClearWindow(ws->dpy,ws->win); - /* take a snapshot for the root pixmap */ - XCopyArea(ws->dpy, ws->win, ws->bkg, ws->foregc, 0, 0, - ws->width, ws->height, 0, 0); + if (!check_update_background(ws)) { + /* The background pixmap atom was not detected on the root window, + take a snapshot for the root pixmap */ + XCopyArea(ws->dpy, ws->win, ws->bkg, ws->foregc, 0, 0, + ws->width, ws->height, 0, 0); + + /* AND-shade the background */ + XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, + ws->width, ws->height); + } + + /* register to get informed when background pixmap atom changes, + even if we did not detect it... it might apear later */ + XSelectInput(ws->dpy, ws->root, PropertyChangeMask); /* in order to get the full pixmap we have to wait until the pixmap is copied before lowering the window */ XLowerWindow(ws->dpy, ws->win); - /* AND-shade the background */ - XFillRectangle(ws->dpy, ws->bkg, ws->backgc, 0, 0, - ws->width, ws->height); } /* prevent the server from redrawing the background */ @@ -839,6 +896,16 @@ while (1) { + if ((XPending(ws->dpy) > 0) && + (XCheckMaskEvent(ws->dpy, PropertyChangeMask, &ev) == True)) { + if (check_update_background(ws)) { + /* background changed request full redraw */ + draw_pixmap(io,ws,cs); + /* make an exposure event */ + XClearArea(ws->dpy, ws->win, 0, 0, 0, 0, True); + } + } + while ((XPending(ws->dpy) > 0) && (XCheckMaskEvent(ws->dpy, ExposureMask, &ev) == True)) { handle_expose((XExposeEvent*)&ev.xexpose, ws); debian/patches/0012-fix-segfault-on-empty-bw-parameter.patch0000644000000000000000000000206112170513030020735 0ustar Description: Fix segfault on empty -bw parameter Author: Axel Beckert Debian-Bug: 716584 Index: xrootconsole/main.c =================================================================== --- xrootconsole.orig/main.c 2013-07-14 14:10:27.785180335 +0200 +++ xrootconsole/main.c 2013-07-14 14:10:27.737180203 +0200 @@ -514,8 +514,14 @@ io->bg = *++argv; else if (!strcmp(*argv, "-bordercolor") || !strcmp(*argv, "-bd")) io->bd = *++argv; - else if (!strcmp(*argv, "-borderwidth") || !strcmp(*argv, "-bw")) - io->bw = atoi(*++argv); + else if (!strcmp(*argv, "-borderwidth") || !strcmp(*argv, "-bw")) { + if (*++argv) { + io->bw = atoi(*argv); + } else { + fprintf(stderr, "No parameter to %s given. Exiting.\n", *--argv); + exit(EXIT_FAILURE); + } + } else if (!strcmp(*argv, "-columns") || !strcmp(*argv, "-c")) io->tc = atoi(*++argv); else if (!strcmp(*argv, "--solid")) debian/source/0000755000000000000000000000000011537143770010476 5ustar debian/source/format0000644000000000000000000000001311453663213011677 0ustar 3.0 (quilt)debian/compat0000644000000000000000000000000212170340312010355 0ustar 9 debian/copyright0000644000000000000000000000141212170340325011114 0ustar This package was debianized by Bradley Bell on Fri, 18 Jun 1999 13:14:38 -0700. It was downloaded from: http://sourceforge.net/projects/xrootconsole/files/ Upstream Author: Bob Galloway Copyright (C) 1998, 1999 Eric Youngblut Copyright (C) 1999, 2000, 2002, 2004 Bob Galloway Patch contributors: Copyright (C) 2009 Julien Viard de Galbert (ANSI Color support) Copyright (C) 2010 Axel Beckert (UTF-8 Support) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. On Debian systems, you can find the full text of the GPL in /usr/share/common-licenses/. debian/manpages0000644000000000000000000000001711454450773010714 0ustar xrootconsole.1 debian/watch0000644000000000000000000000010011454452664010221 0ustar version=3 http://sf.net/xrootconsole/xrootconsole-(.+)\.tar\.gz debian/install0000644000000000000000000000002512170344772010563 0ustar xrootconsole usr/bin debian/docs0000644000000000000000000000002512170350026010032 0ustar CREDITS README TODO debian/examples0000644000000000000000000000000512170350027010717 0ustar test debian/rules0000755000000000000000000000030312170350027010237 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ override_dh_installchangelogs: dh_installchangelogs NEWS # Empty target override_dh_auto_install: debian/control0000644000000000000000000000142612170350027010571 0ustar Source: xrootconsole Section: x11 Priority: optional Maintainer: Axel Beckert Uploaders: Julien Viard de Galbert Standards-Version: 3.9.4 Build-Depends: debhelper (>= 9~), libx11-dev Homepage: http://sourceforge.net/projects/xrootconsole/ Vcs-Git: git://anonscm.debian.org/collab-maint/xrootconsole.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/xrootconsole.git Package: xrootconsole Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} Suggests: ccze | logo Description: Fancy X console display Xrootconsole redirects its input to a transparent (and optionally shaded) window on the root window. It supports displaying UTF-8 and ANSI-colors, e.g. those generated with "ccze -A" or "loco". debian/changelog0000644000000000000000000001430512170513030011033 0ustar xrootconsole (1:0.6-3) unstable; urgency=low * Apply wrap-and-sort * Bump Standards-Version to 3.9.4 (no changes) * Bump debhelper compatibility to 9 + Update versioned debhelper build-dependency accordingly * Revamp debian/rules: + Remove commented helpers and obsolete targets + Use dh_install + debian/install instead of dh_installdirs + debian/dirs + manually calling install. + Use dh_auto_{build,clean} + Remove manual DEB_BUILD_OPTIONS handling + Make use dh_clean's implicit removals, no more call rm manually + Use debian/examples instead of dh_installexamples parameter + Finally switch to dh7 style debian/rules file * Update 0003-build-options.patch to work properly with dpkg-buildflags * Remove debian/menu so that it doesn't get installed again (c.f. #79923) * Add patch to fix segfault if -bw has no parameter (Closes: #716584) * Update 0006-utf8.patch to not segfault if given font cannot be found. + Refresh subsequent patches * Fixes the following lintian warnings: + vcs-field-not-canonical + debian-rules-missing-recommended-target + hardening-no-{relro,fortify-functions} + no-upstream-changelog -- Axel Beckert Sun, 14 Jul 2013 01:05:42 +0200 xrootconsole (1:0.6-2) unstable; urgency=low [ Axel Beckert ] * Add Julien Viard de Galbert as co-maintainer. [ Julien Viard de Galbert ] * Renamed patches and formated headers with gbp-pq style (DEP-3 compatible). * Add new patches to - support nautilus - ignore null char in strings read from input it was breaking the display - no sleep in event loop (Closes: #301137) - detect background changes (Closes: #60482) * Improved ANSI color patch. -- Julien Viard de Galbert Fri, 25 Feb 2011 17:16:30 +0100 xrootconsole (1:0.6-1) experimental; urgency=low * New Maintainer (Closes: #554099) * New upstream release (Closes: #301133) * Remove obsolete "local variables:" from changelog * Switch to source format 3.0 and split up patches by functionality * Add new patches to - support 8-bit characters in general (patch by by Miroslav Jezbera . Closes: #260255) - support multibyte character/UTF-8. Patch inspired by patch for #531036. Update package description accordingly. - support displaying ANSI colors. Based on patch from http://silicone.homelinux.org/2009/04/02/ansi-color-support-for-xrootconsole/. Suggest some ANSI log colorizer and update package description accordingly. * Fix several lintian warnings - [debian/control] old-fsf-address-in-copyright-file, copyright-should-refer-to-common-license-file-for-gpl, and copyright-without-copyright-notice (also updated download URL) - [debian/rules] debian-rules-ignores-make-clean-error - [debian/watch] debian-watch-file-is-missing * Fix dh_shlibs warning and don't link uselessly against libutil. * Bump debhelper compatibility to 7 - debian/control: make dependency on debhelper versioned, add ${misc:Depends} - debian/manpages, debian/compat: added - debian/rules: replace dh_clean -k by dh_prep, dh_installmanpages by dh_installman install into debian/xrootconsole instead of debian/tmp. * Bump Standards-Version to 3.9.1: - [debian/control] Add Homepage field - [debian/control] Add Vcs-* fields - [debian/rules, debian/patches/build-options.diff] Add support for DEB_BUILD_OPTIONS (Closes: #438328) -- Axel Beckert Tue, 19 Oct 2010 03:27:46 +0200 xrootconsole (1:0.5-1.1) unstable; urgency=high * Non-maintainer upload. * Split xlibs-dev build-dep (Closes: #346852). -- Luk Claes Fri, 20 Jan 2006 18:36:25 +0100 xrootconsole (1:0.5-1) unstable; urgency=low * New upstream release -- Bradley Bell Tue, 23 Jul 2002 13:49:30 -0700 xrootconsole (1:0.3-5.2) unstable; urgency=high * Redoing the upload with a higher urgency to get it into Woody. Forgot to do that yesterday. :-( -- Wilmer van der Gaast Wed, 24 Apr 2002 11:01:57 +0200 xrootconsole (1:0.3-5.1) unstable; urgency=low * Fixed hang-problem with windows grabbing the mouse * Updated BuildDeps to XFree86 4.0 libs (xlibs-dev instead of xlib6g-dev) -- Wilmer van der Gaast Tue, 23 Apr 2002 20:27:59 +0200 xrootconsole (1:0.3-5) unstable; urgency=low * Patch to fix extra newline with --wrap and line (Closes: #89559) -- Bradley Bell Fri, 16 Mar 2001 01:01:19 -0800 xrootconsole (1:0.3-4) unstable; urgency=low * Removed menu entry (Closes: #79923) * Added -bottomup option -- Bradley Bell Sun, 4 Mar 2001 17:58:29 -0800 xrootconsole (1:0.3-3) unstable; urgency=low * Added Build-Depends: to control -- Bradley Bell Tue, 15 Aug 2000 01:39:04 -0700 xrootconsole (1:0.3-2) unstable; urgency=low * Updated man page -- Bradley Bell Tue, 14 Mar 2000 02:03:17 -0800 xrootconsole (1:0.3-1) unstable; urgency=low * New upstream release -- Bradley Bell Tue, 14 Mar 2000 01:03:17 -0800 xrootconsole (1:0.2-1) unstable; urgency=low * New upstream release and maintainer -- Bradley Bell Wed, 1 Mar 2000 01:23:08 -0800 xrootconsole (990119-6) unstable; urgency=low * fixed incorrect geometry calculation (closes: Bug#54355) -- Bradley Bell Sat, 8 Jan 2000 16:17:48 -0800 xrootconsole (990119-5) unstable; urgency=low * added -f to monitor arbitrary file (closes: Bug#48643) -- Bradley Bell Fri, 29 Oct 1999 19:45:32 -0700 xrootconsole (990119-4) unstable; urgency=low * repackage for FHS compliance -- Bradley Bell Wed, 15 Sep 1999 22:08:43 -0700 xrootconsole (990119-3) unstable; urgency=low * fixed man page -- Bradley Bell Tue, 6 Jul 1999 20:47:09 -0700 xrootconsole (990119-2) unstable; urgency=low * made menu entry XRootConsole instead of xrootconsole -- Bradley Bell Tue, 6 Jul 1999 20:45:42 -0700 xrootconsole (990119-1) unstable; urgency=low * Initial Release. -- Bradley Bell Fri, 18 Jun 1999 13:14:38 -0700