From 738a6eecdeec006a647964f36e27fd701c42a6f6 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Fri, 13 Feb 2004 18:13:55 +0000 Subject: [PATCH] Indent. SVN revision: 8961 --- dox/dox.c | 969 +++++++++++++++++++++++++++------------------------ dox/dox.h | 111 +++--- dox/file.c | 163 +++++---- dox/format.c | 226 +++++++----- dox/text.c | 18 +- eesh/E.h | 3 - eesh/file.c | 3 +- 7 files changed, 804 insertions(+), 689 deletions(-) diff --git a/dox/dox.c b/dox/dox.c index 538c7620..44a4f0a0 100644 --- a/dox/dox.c +++ b/dox/dox.c @@ -40,7 +40,7 @@ #include #include -#if defined(__alpha__) && defined(__GNUC__) && ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)) /* gets rid of some misalignment in GCC */ +#if defined(__alpha__) && defined(__GNUC__) && ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)) /* gets rid of some misalignment in GCC */ #pragma 2 #endif @@ -67,111 +67,114 @@ #define PROP_MWM_HINTS_ELEMENTS 4 -#define STARTPOS 4 /* to bypass next/prev/exit buttons for key binding positions */ +#define STARTPOS 4 /* to bypass next/prev/exit buttons for key binding positions */ -typedef struct _mwmhints { - CARD32 flags; - CARD32 functions; - CARD32 decorations; - INT32 inputMode; +typedef struct _mwmhints +{ + CARD32 flags; + CARD32 functions; + CARD32 decorations; + INT32 inputMode; } MWMHints; -Display *disp; -Root root; +Display *disp; +Root root; #if !USE_IMLIB2 -ImlibData *pI1Ctx; -ImlibImage *pIcImg; -Drawable vIcDrw; +ImlibData *pI1Ctx; +ImlibImage *pIcImg; +Drawable vIcDrw; #endif #if USE_FNLIB -FnlibData *pFnlibData; +FnlibData *pFnlibData; #endif -Window win_main, win_title, win_exit, win_next, win_prev, win_text, win_cover; -int w, h, t; -Imlib_Image *im_text; -Imlib_Image *im_title; -Imlib_Image *im_prev1, *im_prev2; -Imlib_Image *im_next1, *im_next2; -Imlib_Image *im_exit1, *im_exit2; -char *docdir; +Window win_main, win_title, win_exit, win_next, win_prev, win_text, + win_cover; +int w, h, t; +Imlib_Image *im_text; +Imlib_Image *im_title; +Imlib_Image *im_prev1, *im_prev2; +Imlib_Image *im_next1, *im_next2; +Imlib_Image *im_exit1, *im_exit2; +char *docdir; -Window CreateWindow(Window parent, int x, int y, int ww, int hh); -int ReadHeader(FILE * f); -int ReadPages(FILE * f); +Window CreateWindow(Window parent, int x, int y, int ww, int hh); +int ReadHeader(FILE * f); +int ReadPages(FILE * f); -Window CreateWindow(Window parent, int x, int y, int ww, int hh) +Window +CreateWindow(Window parent, int x, int y, int ww, int hh) { - Window win; - XSetWindowAttributes attr; - MWMHints mwm; + Window win; + XSetWindowAttributes attr; + MWMHints mwm; /* Atom a; */ - XSizeHints hnt; + XSizeHints hnt; - attr.backing_store = NotUseful; - attr.override_redirect = False; - attr.colormap = root.cmap; - attr.border_pixel = 0; - attr.background_pixel = 0; - attr.save_under = False; - mwm.flags = MWM_HINTS_DECORATIONS; - mwm.functions = 0; - mwm.decorations = 0; - mwm.inputMode = 0; + attr.backing_store = NotUseful; + attr.override_redirect = False; + attr.colormap = root.cmap; + attr.border_pixel = 0; + attr.background_pixel = 0; + attr.save_under = False; + mwm.flags = MWM_HINTS_DECORATIONS; + mwm.functions = 0; + mwm.decorations = 0; + mwm.inputMode = 0; /* a = XInternAtom(disp, "_MOTIF_WM_HINTS", False); */ - win = XCreateWindow(disp, parent, x, y, ww, hh, 0, root.depth, - InputOutput, root.vis, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | - CWColormap | CWBackPixel | CWBorderPixel, &attr); - XSetWindowBackground(disp, win, 0); + win = XCreateWindow(disp, parent, x, y, ww, hh, 0, root.depth, + InputOutput, root.vis, + CWOverrideRedirect | CWSaveUnder | CWBackingStore | + CWColormap | CWBackPixel | CWBorderPixel, &attr); + XSetWindowBackground(disp, win, 0); /* XChangeProperty(disp, win, a, a, 32, PropModeReplace, * (unsigned char *)&mwm, sizeof(MWMHints) / 4); */ - XStoreName(disp, win, "DOX: Enlightenment Document Viewer"); - hnt.flags = USPosition | USSize | PPosition | PSize | PMinSize | PMaxSize; - hnt.x = x; - hnt.y = y; - hnt.width = ww; - hnt.height = hh; - hnt.min_width = ww; - hnt.max_width = ww; - hnt.min_height = hh; - hnt.max_height = hh; - XSetWMNormalHints(disp, win, &hnt); - return win; + XStoreName(disp, win, "DOX: Enlightenment Document Viewer"); + hnt.flags = USPosition | USSize | PPosition | PSize | PMinSize | PMaxSize; + hnt.x = x; + hnt.y = y; + hnt.width = ww; + hnt.height = hh; + hnt.min_width = ww; + hnt.max_width = ww; + hnt.min_height = hh; + hnt.max_height = hh; + XSetWMNormalHints(disp, win, &hnt); + return win; } static Imlib_Image * LoadImage(const char *file) { - Imlib_Image *im; - char tmp[4096]; + Imlib_Image *im; + char tmp[4096]; - sprintf(tmp, "%s/E-docs/%s", ENLIGHTENMENT_ROOT, file); - findLocalizedFile(tmp); - im = imlib_load_image(tmp); + sprintf(tmp, "%s/E-docs/%s", ENLIGHTENMENT_ROOT, file); + findLocalizedFile(tmp); + im = imlib_load_image(tmp); - return im; + return im; } static void -ApplyImage1(Window win, Imlib_Image *im) +ApplyImage1(Window win, Imlib_Image * im) { - Pixmap pmap = 0, mask = 0; + Pixmap pmap = 0, mask = 0; - imlib_context_set_image(im); - imlib_context_set_drawable(win); - imlib_render_pixmaps_for_whole_image(&pmap, &mask); - XSetWindowBackgroundPixmap(disp, win, pmap); - IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask); + imlib_context_set_image(im); + imlib_context_set_drawable(win); + imlib_render_pixmaps_for_whole_image(&pmap, &mask); + XSetWindowBackgroundPixmap(disp, win, pmap); + IMLIB_FREE_PIXMAP_AND_MASK(pmap, mask); } static void -ApplyImage2(Window win, Imlib_Image *im) +ApplyImage2(Window win, Imlib_Image * im) { - imlib_context_set_image(im); - imlib_context_set_drawable(win); - imlib_render_image_on_drawable(0, 0); + imlib_context_set_image(im); + imlib_context_set_drawable(win); + imlib_render_image_on_drawable(0, 0); } #if USE_IMLIB2 @@ -213,437 +216,491 @@ XClearWindow(disp, win_text); \ } \ } -int main(int argc, char **argv) +int +main(int argc, char **argv) { - int pagenum; - int i, w, h, x, y; - int wx, wy; - FILE *f; - char *s, *docfile = NULL; - Pixmap draw = 0; - Link *l = NULL, *ll = NULL; - Imlib_Border ibd; + int pagenum; + int i, w, h, x, y; + int wx, wy; + FILE *f; + char *s, *docfile = NULL; + Pixmap draw = 0; + Link *l = NULL, *ll = NULL; + Imlib_Border ibd; + #if !USE_IMLIB2 - ImlibInitParams params; + ImlibInitParams params; #endif - int *page_hist = NULL; - int page_hist_len = 1; - int page_hist_pos = 0; + int *page_hist = NULL; + int page_hist_len = 1; + int page_hist_pos = 0; - w = 512; - h = 400; - x = 0; - y = 0; - pagenum = 0; + w = 512; + h = 400; + x = 0; + y = 0; + pagenum = 0; - if((int)(disp = XOpenDisplay(NULL)) < 1) { - printf("%s: Cannot open X display.\n",argv[0]); - exit(0); - } + if ((int)(disp = XOpenDisplay(NULL)) < 1) + { + printf("%s: Cannot open X display.\n", argv[0]); + exit(0); + } - /* now we'll set the locale */ - setlocale(LC_ALL, ""); - if (!XSupportsLocale()) - setlocale(LC_ALL, "C"); - XSetLocaleModifiers(""); - setlocale(LC_ALL, NULL); + /* now we'll set the locale */ + setlocale(LC_ALL, ""); + if (!XSupportsLocale()) + setlocale(LC_ALL, "C"); + XSetLocaleModifiers(""); + setlocale(LC_ALL, NULL); - /* I dont want any internationalisation of my numeric input & output */ - setlocale(LC_NUMERIC, "C"); + /* I dont want any internationalisation of my numeric input & output */ + setlocale(LC_NUMERIC, "C"); - root.scr = DefaultScreen(disp); + root.scr = DefaultScreen(disp); #if USE_IMLIB2 - root.win = DefaultRootWindow(disp); - root.vis = DefaultVisual(disp, root.scr); - root.depth = DefaultDepth(disp, root.scr); - root.cmap = DefaultColormap(disp, root.scr); + root.win = DefaultRootWindow(disp); + root.vis = DefaultVisual(disp, root.scr); + root.depth = DefaultDepth(disp, root.scr); + root.cmap = DefaultColormap(disp, root.scr); - imlib_set_color_usage(128); + imlib_set_color_usage(128); - imlib_context_set_display(disp); - imlib_context_set_visual(root.vis); - imlib_context_set_colormap(root.cmap); - imlib_context_set_dither(1); - imlib_context_set_dither_mask(0); + imlib_context_set_display(disp); + imlib_context_set_visual(root.vis); + imlib_context_set_colormap(root.cmap); + imlib_context_set_dither(1); + imlib_context_set_dither_mask(0); #else - params.flags = PARAMS_IMAGECACHESIZE | PARAMS_PIXMAPCACHESIZE; - params.imagecachesize = (w * h * 3 * 2); - params.pixmapcachesize = (w * h * 3 * 2 * 8); - pI1Ctx = Imlib_init_with_params(disp, ¶ms); - Imlib_set_render_type(pI1Ctx, RT_DITHER_TRUECOL); - root.win = pI1Ctx->x.root; - root.vis = Imlib_get_visual(pI1Ctx); - root.depth = pI1Ctx->x.depth; - root.cmap = Imlib_get_colormap(pI1Ctx); + params.flags = PARAMS_IMAGECACHESIZE | PARAMS_PIXMAPCACHESIZE; + params.imagecachesize = (w * h * 3 * 2); + params.pixmapcachesize = (w * h * 3 * 2 * 8); + pI1Ctx = Imlib_init_with_params(disp, ¶ms); + Imlib_set_render_type(pI1Ctx, RT_DITHER_TRUECOL); + root.win = pI1Ctx->x.root; + root.vis = Imlib_get_visual(pI1Ctx); + root.depth = pI1Ctx->x.depth; + root.cmap = Imlib_get_colormap(pI1Ctx); #endif #if USE_FNLIB - pFnlibData = Fnlib_init(pI1Ctx); + pFnlibData = Fnlib_init(pI1Ctx); #endif - if (argc < 2) { - printf("usage:\n" - "%s [-page page_number] [-file Edoc_fname] [-size width height] Edoc_dir\n", - argv[0]); - exit(1); - } + if (argc < 2) + { + printf("usage:\n" + "%s [-page page_number] [-file Edoc_fname] [-size width height] Edoc_dir\n", + argv[0]); + exit(1); + } - docdir = "."; - docfile = "MAIN"; - for (i = 1; i < argc; i++) { - if ((!strcmp(argv[i], "-page")) && (i < (argc - 1))) - pagenum = atoi(argv[++i]); - else if ((!strcmp(argv[i], "-file")) && (i < (argc - 1))) - docfile = argv[++i]; - else if ((!strcmp(argv[i], "-size")) && (i < (argc - 2))) { - w = atoi(argv[++i]); - h = atoi(argv[++i]); - } else - docdir = strdup(argv[i]); - } - s = malloc(strlen(docdir) + strlen(docfile) + 2 + 20); - sprintf(s, "%s/%s", docdir, docfile); - findLocalizedFile(s); + docdir = "."; + docfile = "MAIN"; + for (i = 1; i < argc; i++) + { + if ((!strcmp(argv[i], "-page")) && (i < (argc - 1))) + pagenum = atoi(argv[++i]); + else if ((!strcmp(argv[i], "-file")) && (i < (argc - 1))) + docfile = argv[++i]; + else if ((!strcmp(argv[i], "-size")) && (i < (argc - 2))) + { + w = atoi(argv[++i]); + h = atoi(argv[++i]); + } + else + docdir = strdup(argv[i]); + } + s = malloc(strlen(docdir) + strlen(docfile) + 2 + 20); + sprintf(s, "%s/%s", docdir, docfile); + findLocalizedFile(s); - im_title = LoadImage("title.xpm"); - imlib_context_set_image(im_title); - ibd.left = 50; - ibd.right = 2; - ibd.top = 2; - ibd.bottom = 2; - imlib_image_set_border(&ibd); - im_prev1 = LoadImage("prev1.xpm"); - im_prev2 = LoadImage("prev2.xpm"); - im_next1 = LoadImage("next1.xpm"); - im_next2 = LoadImage("next2.xpm"); - im_exit1 = LoadImage("exit1.xpm"); - im_exit2 = LoadImage("exit2.xpm"); + im_title = LoadImage("title.xpm"); + imlib_context_set_image(im_title); + ibd.left = 50; + ibd.right = 2; + ibd.top = 2; + ibd.bottom = 2; + imlib_image_set_border(&ibd); + im_prev1 = LoadImage("prev1.xpm"); + im_prev2 = LoadImage("prev2.xpm"); + im_next1 = LoadImage("next1.xpm"); + im_next2 = LoadImage("next2.xpm"); + im_exit1 = LoadImage("exit1.xpm"); + im_exit2 = LoadImage("exit2.xpm"); +#ifndef __EMX__ + f = fopen(s, "r"); +#else + f = fopen(s, "rt"); +#endif + if (!f) + { + strcpy(s, docdir); + strcat(s, "/"); + strcat(s, docfile); #ifndef __EMX__ f = fopen(s, "r"); #else f = fopen(s, "rt"); #endif - if (!f) { - strcpy(s, docdir); - strcat(s, "/"); - strcat(s, docfile); -#ifndef __EMX__ - f = fopen(s, "r"); -#else - f = fopen(s, "rt"); -#endif - if (!f) { - printf("Edoc_dir %s does not contain a %s file\n", docdir, docfile); - exit(1); - } - } - Esetenv("DISPLAY", DisplayString(disp), 1); - Esetenv("E_DATADIR", ENLIGHTENMENT_ROOT, 1); - Esetenv("E_BINDIR", ENLIGHTENMENT_BIN, 1); + if (!f) + { + printf("Edoc_dir %s does not contain a %s file\n", docdir, + docfile); + exit(1); + } + } + Esetenv("DISPLAY", DisplayString(disp), 1); + Esetenv("E_DATADIR", ENLIGHTENMENT_ROOT, 1); + Esetenv("E_BINDIR", ENLIGHTENMENT_BIN, 1); - t = 16; - GetObjects(f); - fclose(f); + t = 16; + GetObjects(f); + fclose(f); #if USE_FNLIB - Fnlib_add_dir(pFnlibData, docdir); + Fnlib_add_dir(pFnlibData, docdir); #endif - wx = (DisplayWidth(disp, DefaultScreen(disp)) - w) / 2; - wy = (DisplayHeight(disp, DefaultScreen(disp)) - (h + t)) / 2; + wx = (DisplayWidth(disp, DefaultScreen(disp)) - w) / 2; + wy = (DisplayHeight(disp, DefaultScreen(disp)) - (h + t)) / 2; #ifdef HAS_XINERAMA + { + if (XineramaIsActive(disp)) { - if (XineramaIsActive(disp)) { - Window rt, ch; - int d; - unsigned int ud; - int pointer_x, pointer_y; - int num; - XineramaScreenInfo *screens; + Window rt, ch; + int d; + unsigned int ud; + int pointer_x, pointer_y; + int num; + XineramaScreenInfo *screens; - XQueryPointer(disp, root.win, &rt, &ch, &pointer_x, &pointer_y, - &d, &d, &ud); + XQueryPointer(disp, root.win, &rt, &ch, &pointer_x, &pointer_y, + &d, &d, &ud); - screens = XineramaQueryScreens(disp, &num); - for (i = 0; i < num; i++) { - if (pointer_x >= screens[i].x_org) { - if (pointer_x <= (screens[i].width + screens[i].x_org)) { - if (pointer_y >= screens[i].y_org) { - if (pointer_y <= (screens[i].height + - screens[i].y_org)) { - wx = ((screens[i].width - w) / 2) - + screens[i].x_org; - wy = ((screens[i].height - (h + t)) / 2) - + screens[i].y_org; - } - } - } - } - } - - XFree(screens); - } + screens = XineramaQueryScreens(disp, &num); + for (i = 0; i < num; i++) + { + if (pointer_x >= screens[i].x_org) + { + if (pointer_x <= (screens[i].width + screens[i].x_org)) + { + if (pointer_y >= screens[i].y_org) + { + if (pointer_y <= (screens[i].height + + screens[i].y_org)) + { + wx = ((screens[i].width - w) / 2) + + screens[i].x_org; + wy = ((screens[i].height - (h + t)) / 2) + + screens[i].y_org; + } + } + } + } + } + XFree(screens); } + + } #endif - win_main = CreateWindow(root.win, wx, wy, w, h + t); - win_title = XCreateSimpleWindow(disp, win_main, 0, 0, (w - 64 - 64 - t), t, 0, 0, 0); - win_prev = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t), 0, 64, t, 0, 0, 0); - win_next = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64, 0, 64, t, 0, 0, 0); - win_exit = XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t, 0, 0, 0); - win_text = XCreateSimpleWindow(disp, win_main, 0, t, w, h, 0, 0, 0); - XSelectInput(disp, win_prev, ButtonPressMask | ButtonReleaseMask); - XSelectInput(disp, win_next, ButtonPressMask | ButtonReleaseMask); - XSelectInput(disp, win_exit, ButtonPressMask | ButtonReleaseMask); - XSelectInput(disp, win_text, ButtonPressMask | ButtonReleaseMask | - KeyPressMask | KeyReleaseMask | PointerMotionMask); + win_main = CreateWindow(root.win, wx, wy, w, h + t); + win_title = + XCreateSimpleWindow(disp, win_main, 0, 0, (w - 64 - 64 - t), t, 0, 0, 0); + win_prev = + XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t), 0, 64, t, 0, 0, 0); + win_next = + XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64, 0, 64, t, 0, + 0, 0); + win_exit = + XCreateSimpleWindow(disp, win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t, + 0, 0, 0); + win_text = XCreateSimpleWindow(disp, win_main, 0, t, w, h, 0, 0, 0); + XSelectInput(disp, win_prev, ButtonPressMask | ButtonReleaseMask); + XSelectInput(disp, win_next, ButtonPressMask | ButtonReleaseMask); + XSelectInput(disp, win_exit, ButtonPressMask | ButtonReleaseMask); + XSelectInput(disp, win_text, ButtonPressMask | ButtonReleaseMask | + KeyPressMask | KeyReleaseMask | PointerMotionMask); - draw = XCreatePixmap(disp, win_text, w, h, root.depth); + draw = XCreatePixmap(disp, win_text, w, h, root.depth); - ApplyImage1(win_title, im_title); - ApplyImage1(win_prev, im_prev1); - ApplyImage1(win_next, im_next1); - ApplyImage1(win_exit, im_exit1); + ApplyImage1(win_title, im_title); + ApplyImage1(win_prev, im_prev1); + ApplyImage1(win_next, im_next1); + ApplyImage1(win_exit, im_exit1); - l = RenderPage(draw, pagenum, w, h); - UPDATE_NOW; + l = RenderPage(draw, pagenum, w, h); + UPDATE_NOW; - XMapWindow(disp, win_title); - XMapWindow(disp, win_prev); - XMapWindow(disp, win_next); - XMapWindow(disp, win_exit); - XMapWindow(disp, win_text); - XMapWindow(disp, win_main); + XMapWindow(disp, win_title); + XMapWindow(disp, win_prev); + XMapWindow(disp, win_next); + XMapWindow(disp, win_exit); + XMapWindow(disp, win_text); + XMapWindow(disp, win_main); - XSync(disp, False); - page_hist = malloc(sizeof(int)); + XSync(disp, False); + page_hist = malloc(sizeof(int)); - page_hist[0] = 0; + page_hist[0] = 0; - for (;;) { - KeySym key; - XEvent ev; + for (;;) + { + KeySym key; + XEvent ev; - XNextEvent(disp, &ev); - switch (ev.type) { - case KeyPress: - key = XLookupKeysym(&ev.xkey, 0); - switch (key) { - case XK_Escape: - exit(0); - break; - case XK_Down: - case XK_Right: - break; - case XK_Up: - case XK_Left: - break; - case XK_Return: - break; - case XK_Home: - FREE_LINKS; - pagenum = 0; - pagenum = FixPage(pagenum); - l = RenderPage(draw, pagenum, w, h); - UPDATE; - break; - case XK_End: - FREE_LINKS; - pagenum = 99999; - pagenum = FixPage(pagenum); - l = RenderPage(draw, pagenum, w, h); - UPDATE; - break; - case XK_Prior: - FREE_LINKS; - pagenum--; - pagenum = FixPage(pagenum); - l = RenderPage(draw, pagenum, w, h); - UPDATE; - break; - case XK_Next: - FREE_LINKS; - pagenum++; - pagenum = FixPage(pagenum); - l = RenderPage(draw, pagenum, w, h); - UPDATE; - break; - } - break; - case ButtonPress: - if (ev.xbutton.window == win_prev) - ApplyImage2(win_prev, im_prev2); - else if (ev.xbutton.window == win_next) - ApplyImage2(win_next, im_next2); - else if (ev.xbutton.window == win_exit) - ApplyImage2(win_exit, im_exit2); - else { - int x, y; + XNextEvent(disp, &ev); + switch (ev.type) + { + case KeyPress: + key = XLookupKeysym(&ev.xkey, 0); + switch (key) + { + case XK_Escape: + exit(0); + break; + case XK_Down: + case XK_Right: + break; + case XK_Up: + case XK_Left: + break; + case XK_Return: + break; + case XK_Home: + FREE_LINKS; + pagenum = 0; + pagenum = FixPage(pagenum); + l = RenderPage(draw, pagenum, w, h); + UPDATE; + break; + case XK_End: + FREE_LINKS; + pagenum = 99999; + pagenum = FixPage(pagenum); + l = RenderPage(draw, pagenum, w, h); + UPDATE; + break; + case XK_Prior: + FREE_LINKS; + pagenum--; + pagenum = FixPage(pagenum); + l = RenderPage(draw, pagenum, w, h); + UPDATE; + break; + case XK_Next: + FREE_LINKS; + pagenum++; + pagenum = FixPage(pagenum); + l = RenderPage(draw, pagenum, w, h); + UPDATE; + break; + } + break; + case ButtonPress: + if (ev.xbutton.window == win_prev) + ApplyImage2(win_prev, im_prev2); + else if (ev.xbutton.window == win_next) + ApplyImage2(win_next, im_next2); + else if (ev.xbutton.window == win_exit) + ApplyImage2(win_exit, im_exit2); + else + { + int x, y; - x = ev.xbutton.x; - y = ev.xbutton.y; - ll = l; - while (ll) { - if ((x >= ll->x) && (y >= ll->y) && - (x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) { - int pg; + x = ev.xbutton.x; + y = ev.xbutton.y; + ll = l; + while (ll) + { + if ((x >= ll->x) && (y >= ll->y) && + (x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) + { + int pg; - if (!strncmp("EXEC.", ll->name, 5)) { - if (!fork()) { - char *exe; + if (!strncmp("EXEC.", ll->name, 5)) + { + if (!fork()) + { + char *exe; - exe = &(ll->name[5]); - execl("/bin/sh", "/bin/sh", "-c", exe, NULL); - exit(0); - } - } else if (!strncmp("INPUT.", ll->name, 6)) { - FILE *p; - char *exe, tmp[1024]; + exe = &(ll->name[5]); + execl("/bin/sh", "/bin/sh", "-c", exe, + NULL); + exit(0); + } + } + else if (!strncmp("INPUT.", ll->name, 6)) + { + FILE *p; + char *exe, tmp[1024]; - exe = &(ll->name[6]); - if (exe[0] != '/') { - sprintf(tmp, "%s/%s", docdir, exe); - findLocalizedFile(tmp); - exe = tmp; - } - p = popen(exe, "r"); - if (p) { - int dirlen = 0; - char *sp; + exe = &(ll->name[6]); + if (exe[0] != '/') + { + sprintf(tmp, "%s/%s", docdir, exe); + findLocalizedFile(tmp); + exe = tmp; + } + p = popen(exe, "r"); + if (p) + { + int dirlen = 0; + char *sp; - sp = exe; - while ((*sp) && (*sp != ' ')) - sp++; - while ((*sp != '/') && (sp != exe)) - sp--; - dirlen = sp - exe; - if (dirlen > 1) { - free(docdir); - docdir = malloc(dirlen + 1); - memcpy(docdir, exe, dirlen); - docdir[dirlen] = 0; - } - GetObjects(p); - pclose(p); - if (page_hist) - free(page_hist); - page_hist = malloc(sizeof(int)); - - page_hist[0] = 0; - page_hist_len = 1; - pagenum = 0; - page_hist_pos = 0; - FREE_LINKS; - l = RenderPage(draw, pagenum, w, h); - UPDATE; - } - } else { - pg = GetPage(ll->name); - if (pg >= 0) { - FREE_LINKS; - pagenum = pg; - page_hist_pos++; - if (page_hist_pos >= page_hist_len) { - page_hist_len++; - page_hist = - realloc(page_hist, - sizeof(int) * page_hist_len); - } - page_hist[page_hist_pos] = pagenum; - l = RenderPage(draw, pagenum, w, h); - UPDATE; - } - } - break; + sp = exe; + while ((*sp) && (*sp != ' ')) + sp++; + while ((*sp != '/') && (sp != exe)) + sp--; + dirlen = sp - exe; + if (dirlen > 1) + { + free(docdir); + docdir = malloc(dirlen + 1); + memcpy(docdir, exe, dirlen); + docdir[dirlen] = 0; } - ll = ll->next; - } - } - break; - case ButtonRelease: - if (ev.xbutton.window == win_prev) { - ApplyImage3(win_prev, im_prev1); - FREE_LINKS; - page_hist_pos--; - if (page_hist_pos < 0) - page_hist_pos = 0; - pagenum = page_hist[page_hist_pos]; - l = RenderPage(draw, pagenum, w, h); - UPDATE; - } else if (ev.xbutton.window == win_next) { - int prev_pagenum; + GetObjects(p); + pclose(p); + if (page_hist) + free(page_hist); + page_hist = malloc(sizeof(int)); - ApplyImage3(win_next, im_next1); - prev_pagenum = pagenum; - pagenum++; - pagenum = FixPage(pagenum); - if (pagenum != prev_pagenum) { - FREE_LINKS; - page_hist_pos++; - if (page_hist_pos >= page_hist_len) { - page_hist_len++; - page_hist = realloc(page_hist, - sizeof(int) * page_hist_len); - - page_hist[page_hist_pos] = pagenum; - } else - page_hist[page_hist_pos] = pagenum; - l = RenderPage(draw, pagenum, w, h); - UPDATE; - } - } else if (ev.xbutton.window == win_exit) { - ApplyImage3(win_exit, im_exit1); - exit(0); - } - break; - case EnterNotify: - break; - case LeaveNotify: - break; - case MotionNotify: - while (XCheckTypedEvent(disp, ev.type, &ev)); - { - int x, y; - static Link *pl = NULL; - char found = 0; - - x = ev.xmotion.x; - y = ev.xmotion.y; - ll = l; - while (ll) { - if ((x >= ll->x) && (y >= ll->y) && - (x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) { - GC gc; - XGCValues gcv; - int r, g, b; - XColor xclr; - - if (pl != ll) { - if (pl) { - UPDATE_NOW; - } - GetLinkColors(pagenum, &r, &g, &b); - ESetColor(&xclr, r, g, b); - EAllocColor(&xclr); - gc = XCreateGC(disp, win_text, 0, &gcv); - XSetForeground(disp, gc, xclr.pixel); - XDrawRectangle(disp, win_text, gc, ll->x, ll->y, - ll->w, ll->h); - XFreeGC(disp, gc); - pl = ll; - } - found = 1; - ll = NULL; + page_hist[0] = 0; + page_hist_len = 1; + pagenum = 0; + page_hist_pos = 0; + FREE_LINKS; + l = RenderPage(draw, pagenum, w, h); + UPDATE; + } + } + else + { + pg = GetPage(ll->name); + if (pg >= 0) + { + FREE_LINKS; + pagenum = pg; + page_hist_pos++; + if (page_hist_pos >= page_hist_len) + { + page_hist_len++; + page_hist = + realloc(page_hist, + sizeof(int) * + page_hist_len); } - if (ll) - ll = ll->next; - } - if (!found) { - UPDATE_NOW; - pl = NULL; - } - } - break; - default: - break; - } - } + page_hist[page_hist_pos] = pagenum; + l = RenderPage(draw, pagenum, w, h); + UPDATE; + } + } + break; + } + ll = ll->next; + } + } + break; + case ButtonRelease: + if (ev.xbutton.window == win_prev) + { + ApplyImage3(win_prev, im_prev1); + FREE_LINKS; + page_hist_pos--; + if (page_hist_pos < 0) + page_hist_pos = 0; + pagenum = page_hist[page_hist_pos]; + l = RenderPage(draw, pagenum, w, h); + UPDATE; + } + else if (ev.xbutton.window == win_next) + { + int prev_pagenum; + + ApplyImage3(win_next, im_next1); + prev_pagenum = pagenum; + pagenum++; + pagenum = FixPage(pagenum); + if (pagenum != prev_pagenum) + { + FREE_LINKS; + page_hist_pos++; + if (page_hist_pos >= page_hist_len) + { + page_hist_len++; + page_hist = realloc(page_hist, + sizeof(int) * page_hist_len); + + page_hist[page_hist_pos] = pagenum; + } + else + page_hist[page_hist_pos] = pagenum; + l = RenderPage(draw, pagenum, w, h); + UPDATE; + } + } + else if (ev.xbutton.window == win_exit) + { + ApplyImage3(win_exit, im_exit1); + exit(0); + } + break; + case EnterNotify: + break; + case LeaveNotify: + break; + case MotionNotify: + while (XCheckTypedEvent(disp, ev.type, &ev)); + { + int x, y; + static Link *pl = NULL; + char found = 0; + + x = ev.xmotion.x; + y = ev.xmotion.y; + ll = l; + while (ll) + { + if ((x >= ll->x) && (y >= ll->y) && + (x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) + { + GC gc; + XGCValues gcv; + int r, g, b; + XColor xclr; + + if (pl != ll) + { + if (pl) + { + UPDATE_NOW; + } + GetLinkColors(pagenum, &r, &g, &b); + ESetColor(&xclr, r, g, b); + EAllocColor(&xclr); + gc = XCreateGC(disp, win_text, 0, &gcv); + XSetForeground(disp, gc, xclr.pixel); + XDrawRectangle(disp, win_text, gc, ll->x, ll->y, + ll->w, ll->h); + XFreeGC(disp, gc); + pl = ll; + } + found = 1; + ll = NULL; + } + if (ll) + ll = ll->next; + } + if (!found) + { + UPDATE_NOW; + pl = NULL; + } + } + break; + default: + break; + } + } } diff --git a/dox/dox.h b/dox/dox.h index 02884c01..e268f588 100644 --- a/dox/dox.h +++ b/dox/dox.h @@ -164,7 +164,6 @@ extern Drawable vIcDrw; #include #endif - #define FILEPATH_LEN_MAX 4096 #define DEFAULT_LINKCOLOR_R 30 @@ -191,7 +190,6 @@ typedef struct _efont Efont; putenv(envvar);\ } - typedef struct _root { Window win; @@ -204,83 +202,83 @@ typedef struct _root Root; typedef struct _textstate - { - char *fontname; +{ + char *fontname; #if USE_FNLIB - FnlibStyle style; - FnlibFont *font; + FnlibStyle style; + FnlibFont *font; #endif - XColor fg_col; - XColor bg_col; - int effect; - Efont *efont; - XFontStruct *xfont; - XFontSet xfontset; - int xfontset_ascent; - int height; - } + XColor fg_col; + XColor bg_col; + int effect; + Efont *efont; + XFontStruct *xfont; + XFontSet xfontset; + int xfontset_ascent; + int height; +} TextState; typedef enum _type - { - IMG, - BR, - FONT, - P, - TEXT, - PAGE - } +{ + IMG, + BR, + FONT, + P, + TEXT, + PAGE +} Type; typedef struct _img - { - char *src; - char *src2; - char *src3; - int x, y; - char *link; - int w, h; - } +{ + char *src; + char *src2; + char *src3; + int x, y; + char *link; + int w, h; +} Img_; typedef struct _font - { - char *face; - int r, g, b; - } +{ + char *face; + int r, g, b; +} Font_; typedef struct _p - { - float align; - } +{ + float align; +} P_; typedef struct _object - { - Type type; - void *object; - } +{ + Type type; + void *object; +} Object; typedef struct _page - { - char *name; - int count; - Object *obj; - int columns; - int padding; - int linkr, linkg, linkb; - char *background; - } +{ + char *name; + int count; + Object *obj; + int columns; + int padding; + int linkr, linkg, linkb; + char *background; +} Page; typedef struct _link - { - char *name; - int x, y, w, h; - struct _link *next; - } +{ + char *name; + int x, y, w, h; + struct _link *next; +} Link; void Efont_extents(Efont * f, char *text, @@ -353,6 +351,7 @@ Link *RenderPage(Window win, int page_num, int w, int h); extern Display *disp; extern Root root; + #if USE_FNLIB extern FnlibData *pFnlibData; #endif diff --git a/dox/file.c b/dox/file.c index 2d05090f..d5ebd0de 100644 --- a/dox/file.c +++ b/dox/file.c @@ -357,6 +357,7 @@ username(int uid) static int usr_uid = -1; static char *usr_s = NULL; char *s; + #ifndef __EMX__ struct passwd *pwd; @@ -373,8 +374,8 @@ username(int uid) return (s); } #else - if ((s = getenv("USER")) != NULL) - return (s); + if ((s = getenv("USER")) != NULL) + return (s); #endif return (strdup("unknown")); } @@ -385,6 +386,7 @@ homedir(int uid) static int usr_uid = -1; static char *usr_s = NULL; char *s; + #ifndef __EMX__ struct passwd *pwd; @@ -401,10 +403,10 @@ homedir(int uid) return (s); } #else - if ((s = getenv("HOME")) != NULL) - return (s); - else if ((s = getenv("TMP")) != NULL) - return (s); + if ((s = getenv("HOME")) != NULL) + return (s); + else if ((s = getenv("TMP")) != NULL) + return (s); #endif return (strdup("/tmp")); } @@ -415,6 +417,7 @@ usershell(int uid) static int usr_uid = -1; static char *usr_s = NULL; char *s; + #ifndef __EMX__ struct passwd *pwd; @@ -432,7 +435,7 @@ usershell(int uid) } return (strdup("/bin/sh")); #else - return (strdup("sh.exe")); + return (strdup("sh.exe")); #endif } @@ -619,30 +622,49 @@ word_mb(char *s, int num, char *wd, int *spaceflag) char *start, *finish, *ss, *w; int wcflg, mbflg; - struct char_class { - char *name; - wctype_t wt; - } *cc, char_class_tbl[] = { + struct char_class + { + char *name; + wctype_t wt; + } *cc, char_class_tbl[] = + { #ifdef linux - /* Will be supported on glibc 2.1.3 or later */ - {"jspace", 0}, {"jhira", 0}, {"jkata", 0}, {"jkanji", 0}, {"jdigit", 0},/* Japanese */ - {"hangul", 0}, {"hanja", 0}, /* Korean */ - /* {"?????"}, {"?????"},*/ /* Chinese */ + /* Will be supported on glibc 2.1.3 or later */ + { + "jspace", 0}, + { + "jhira", 0}, + { + "jkata", 0}, + { + "jkanji", 0}, + { + "jdigit", 0}, /* Japanese */ + { + "hangul", 0}, + { + "hanja", 0}, /* Korean */ + /* {"?????"}, {"?????"}, *//* Chinese */ #endif #ifdef sgi - /* SGI IRIX (Japanese, Chinese, Korean, etc..) */ - {"special", 0}, {"phonogram", 0}, {"ideogram", 0}, + /* SGI IRIX (Japanese, Chinese, Korean, etc..) */ + { + "special", 0}, + { + "phonogram", 0}, + { + "ideogram", 0}, #endif #ifdef sun - /* {"?????"}, {"?????"},*/ + /* {"?????"}, {"?????"}, */ #endif #ifdef hpux - /* {"?????"}, {"?????"},*/ + /* {"?????"}, {"?????"}, */ #endif - {NULL, 0} + { + NULL, 0} }; - if (!s) return; if (!wd) @@ -655,11 +677,11 @@ word_mb(char *s, int num, char *wd, int *spaceflag) /* Check multibyte character class is available or not */ wcflg = 0; - for ( cc = char_class_tbl; cc->name != NULL; cc++ ) + for (cc = char_class_tbl; cc->name != NULL; cc++) { - cc->wt = wctype( cc->name ); - if ( cc->wt != (wctype_t)0 ) - wcflg = 1; + cc->wt = wctype(cc->name); + if (cc->wt != (wctype_t) 0) + wcflg = 1; } cnt = 0; @@ -672,39 +694,41 @@ word_mb(char *s, int num, char *wd, int *spaceflag) while (s[i]) { - int len, oldflg=1; + int len, oldflg = 1; - - len = mblen( s + i, MB_CUR_MAX ); - if ( len < 0 ) { i++; continue; } + len = mblen(s + i, MB_CUR_MAX); + if (len < 0) + { + i++; + continue; + } /* Check multibyte character class */ - if ( wcflg ) + if (wcflg) { wchar_t wc; mbflg = 1; - if ( (mbtowc( &wc, s + i, strlen(s + i) )) != -1 ) + if ((mbtowc(&wc, s + i, strlen(s + i))) != -1) { - for ( cc = char_class_tbl; cc->name != NULL; cc++ ) - { - if ( cc->wt == (wctype_t)0 ) - continue; + for (cc = char_class_tbl; cc->name != NULL; cc++) + { + if (cc->wt == (wctype_t) 0) + continue; - if ( iswctype( wc, cc->wt ) != 0 ) - { - mbflg = 2; - break; - } - } + if (iswctype(wc, cc->wt) != 0) + { + mbflg = 2; + break; + } + } } } else - mbflg = len; + mbflg = len; - if ((cnt == num) && ( - (s[i] == ' ') || (s[i] == '\t') || - (oldflg != mbflg) || (mbflg > 1) )) + if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t') || + (oldflg != mbflg) || (mbflg > 1))) { finish = &s[i]; break; @@ -712,16 +736,16 @@ word_mb(char *s, int num, char *wd, int *spaceflag) if ((s[i] != ' ') && (s[i] != '\t')) { - if ( (i == 0) || - (s[i - 1] == ' ') || (s[i - 1] == '\t') || - ((oldflg > 1) && (mbflg > 1)) || (oldflg != mbflg) ) + if ((i == 0) || + (s[i - 1] == ' ') || (s[i - 1] == '\t') || + ((oldflg > 1) && (mbflg > 1)) || (oldflg != mbflg)) { cnt++; if (cnt == num) { - start = &s[i]; - if ( (s[i - 1] == ' ') || (s[i - 1] == '\t') ) - *spaceflag = 1; + start = &s[i]; + if ((s[i - 1] == ' ') || (s[i - 1] == '\t')) + *spaceflag = 1; } } } @@ -838,7 +862,7 @@ pathtoexec(char *file) #ifndef __EMX__ if (file[0] == '/') #else - if (_fnisabs(file)) + if (_fnisabs(file)) #endif { if (canexec(file)) @@ -854,7 +878,7 @@ pathtoexec(char *file) #ifndef __EMX__ while ((ep = strchr(cp, ':'))) #else - while ((ep = strchr(cp, ';'))) + while ((ep = strchr(cp, ';'))) #endif { len = ep - cp; @@ -865,9 +889,9 @@ pathtoexec(char *file) s[len] = 0; s = realloc(s, len + 2 + exelen); #ifdef __EMX__ - if (s[len-1] != '/') + if (s[len - 1] != '/') #endif - strcat(s, "/"); + strcat(s, "/"); strcat(s, file); if (canexec(s)) return (s); @@ -883,9 +907,9 @@ pathtoexec(char *file) s[len] = 0; s = realloc(s, len + 2 + exelen); #ifdef __EMX__ - if (s[len-1] != '/') + if (s[len - 1] != '/') #endif - strcat(s, "/"); + strcat(s, "/"); strcat(s, file); if (canexec(s)) return (s); @@ -900,10 +924,11 @@ pathtofile(char *file) char *p, *cp, *ep; char *s; int len, exelen; + #ifndef __EMX__ if (file[0] == '/') #else - if (_fnisabs(file)) + if (_fnisabs(file)) #endif { if (exists(file)) @@ -919,7 +944,7 @@ pathtofile(char *file) #ifndef __EMX__ while ((ep = strchr(cp, ':'))) #else - while ((ep = strchr(cp, ';'))) + while ((ep = strchr(cp, ';'))) #endif { len = ep - cp; @@ -930,9 +955,9 @@ pathtofile(char *file) s[len] = 0; s = realloc(s, len + 2 + exelen); #ifdef __EMX__ - if (s[len-1] != '/') + if (s[len - 1] != '/') #endif - strcat(s, "/"); + strcat(s, "/"); strcat(s, file); if (exists(s)) return (s); @@ -948,9 +973,9 @@ pathtofile(char *file) s[len] = 0; s = realloc(s, len + 2 + exelen); #ifdef __EMX__ - if (s[len-1] != '/') + if (s[len - 1] != '/') #endif - strcat(s, "/"); + strcat(s, "/"); strcat(s, file); if (exists(s)) return (s); @@ -967,10 +992,10 @@ findLocalizedFile(char *fname) int i; if (!(lang = setlocale(LC_MESSAGES, NULL))) - return 0; + return 0; tmp = strdup(fname); - lang = strdup(lang); /* lang may be in static space, thus it must + lang = strdup(lang); /* lang may be in static space, thus it must * be duplicated before we change it below */ p[0] = lang + strlen(lang); p[1] = strchr(lang, '.'); @@ -979,15 +1004,15 @@ findLocalizedFile(char *fname) for (i = 0; i < 3; i++) { if (p[i] == NULL) - continue; + continue; *p[i] = '\0'; sprintf(fname, "%s.%s", tmp, lang); if (exists(fname)) { - free(tmp); - free(lang); - return 1; + free(tmp); + free(lang); + return 1; } } strcpy(fname, tmp); diff --git a/dox/format.c b/dox/format.c index e5af4f51..1868318b 100644 --- a/dox/format.c +++ b/dox/format.c @@ -93,10 +93,8 @@ AddObject(Object * obj) page[num_pages - 1].obj = realloc(page[num_pages - 1].obj, sizeof(Object) * (page[num_pages - 1].count)); - page[num_pages - 1].obj[page[num_pages - 1].count - 1].type = - obj->type; - page[num_pages - 1].obj[page[num_pages - 1].count - 1].object = - obj->object; + page[num_pages - 1].obj[page[num_pages - 1].count - 1].type = obj->type; + page[num_pages - 1].obj[page[num_pages - 1].count - 1].object = obj->object; } void @@ -575,7 +573,7 @@ RenderPage(Window win, int page_num, int w, int h) im = imlib_load_image(tmp); if (im) { - imlib_context_set_image(im); + imlib_context_set_image(im); img->w = imlib_image_get_width(); img->h = imlib_image_get_height(); imlib_context_set_drawable(win); @@ -659,83 +657,93 @@ RenderPage(Window win, int page_num, int w, int h) int sx, sy, ssx, ssy; char link_txt[1024]; char link_link[1024]; - int spaceflag, oldwc=0; + int spaceflag, oldwc = 0; wd[0] = 0; #ifdef HAVE_WCTYPE_H - if ( MB_CUR_MAX > 1 ) /* If multibyte locale,... */ - word_mb(txt, wc, wd, &spaceflag); + if (MB_CUR_MAX > 1) /* If multibyte locale,... */ + word_mb(txt, wc, wd, &spaceflag); else #endif { - word(txt, wc, wd); - spaceflag = 1; + word(txt, wc, wd); + spaceflag = 1; } - if (!wd[0]) eol = 1; + if (!wd[0]) + eol = 1; wc++; eot++; strcpy(ss, s); - if ( (eot != 1) && spaceflag) + if ((eot != 1) && spaceflag) strcat(s, " "); if (wd[0] == '_') - { - link_txt[0] = '\0'; - link_link[0] = '\0'; - link = 1; - oldwc = wc; - TextSize(&ts, s, &lx, &th, 17); - } - - if ( link == 1 ) { - if ( eol || ( (wd[0] != '_') && spaceflag ) ) /* if NO link tag, ... */ - { - link_txt[0] = '\0'; - link_link[0] = '\0'; - link = 0; - wc = oldwc; + link_txt[0] = '\0'; + link_link[0] = '\0'; + link = 1; + oldwc = wc; + TextSize(&ts, s, &lx, &th, 17); + } + + if (link == 1) + { + if (eol || ((wd[0] != '_') && spaceflag)) /* if NO link tag, ... */ + { + link_txt[0] = '\0'; + link_link[0] = '\0'; + link = 0; + wc = oldwc; #ifdef HAVE_WCTYPE_H - if ( MB_CUR_MAX > 1 ) - word_mb(txt, wc - 1, wd, &spaceflag); - else + if (MB_CUR_MAX > 1) + word_mb(txt, wc - 1, wd, &spaceflag); + else #endif - { - word(txt, wc - 1, wd); - spaceflag = 1; - } - } - else - { - int k, linkflg; + { + word(txt, wc - 1, wd); + spaceflag = 1; + } + } + else + { + int k, linkflg; - j = 0; - linkflg = 0; - if ( wd[0] == '_' ) { j++; linkflg++; } + j = 0; + linkflg = 0; + if (wd[0] == '_') + { + j++; + linkflg++; + } - k = strlen( link_txt ); - for ( ; wd[j] != '(' && wd[j] != '\0'; j++, k++) - { - if (wd[j] == '_') link_txt[k] = ' '; - else link_txt[k] = wd[j]; - if ( linkflg ) wd[ j - 1 ] = link_txt[k]; - else wd[j] = link_txt[k]; - } - link_txt[k] = '\0'; - if ( linkflg ) wd[ j - 1 ] = '\0'; + k = strlen(link_txt); + for (; wd[j] != '(' && wd[j] != '\0'; j++, k++) + { + if (wd[j] == '_') + link_txt[k] = ' '; + else + link_txt[k] = wd[j]; + if (linkflg) + wd[j - 1] = link_txt[k]; + else + wd[j] = link_txt[k]; + } + link_txt[k] = '\0'; + if (linkflg) + wd[j - 1] = '\0'; - if ( wd[j] == '(' ) - { - wd[j++] = '\0'; - strcpy( link_link, wd + j); - link_link[ strlen(link_link) - 1 ] = '\0'; - strcpy( wd, link_txt ); - link = 2; - } - else - continue; - } + if (wd[j] == '(') + { + wd[j++] = '\0'; + strcpy(link_link, wd + j); + link_link[strlen(link_link) - 1] = '\0'; + strcpy(wd, link_txt); + link = 2; + } + else + continue; + } } strcat(s, wd); @@ -765,7 +773,8 @@ RenderPage(Window win, int page_num, int w, int h) { if ((iix >= sx) && (iix <= ssx)) { - if (((ix + iix) / 2) > ((sx + ssx) / 2)) + if (((ix + iix) / 2) > + ((sx + ssx) / 2)) ssx = ix - 1; else sx = iix + 1; @@ -793,8 +802,8 @@ RenderPage(Window win, int page_num, int w, int h) txt_disp = s; if (((tw > xspace) || (eol)) && (strlen(txt_disp) > 0)) { - if ( txt_disp[strlen(txt_disp) - 1] == ' ' ) - txt_disp[strlen(txt_disp) - 1] = 0; + if (txt_disp[strlen(txt_disp) - 1] == ' ') + txt_disp[strlen(txt_disp) - 1] = 0; if ((eot == 1) && (tw > xspace)) { @@ -803,18 +812,20 @@ RenderPage(Window win, int page_num, int w, int h) while (txt_disp[(point + cnt)]) { - len = mblen( txt_disp + point + cnt, MB_CUR_MAX); - if ( len < 0 ) - { - cnt++; - continue; - } - else - for ( i = 0; i < len; i++, cnt++ ) - p1[cnt] = txt_disp[point + cnt]; + len = + mblen(txt_disp + point + cnt, MB_CUR_MAX); + if (len < 0) + { + cnt++; + continue; + } + else + for (i = 0; i < len; i++, cnt++) + p1[cnt] = txt_disp[point + cnt]; p1[cnt] = 0; TextSize(&ts, p1, &tw, &th, 17); - if ((tw > xspace) || (!txt_disp[(point + cnt)])) + if ((tw > xspace) + || (!txt_disp[(point + cnt)])) { if (txt_disp[(point + cnt)]) { @@ -830,9 +841,13 @@ RenderPage(Window win, int page_num, int w, int h) } wastext = 1; TextDraw(&ts, win, p1, x + off, y, - xspace, 99999, 17, justification); + xspace, 99999, 17, + justification); y += ts.height; - if (y >= (h - (pg->padding + ts.height - (ts.height - ts.xfontset_ascent)))) + if (y >= + (h - + (pg->padding + ts.height - + (ts.height - ts.xfontset_ascent)))) { y = pg->padding; x += col_w + pg->padding; @@ -848,35 +863,50 @@ RenderPage(Window win, int page_num, int w, int h) if (pg->obj[j].type == IMG) { img = pg->obj[j].object; - if ((img->w > 0) && (img->h > 0)) + if ((img->w > 0) + && (img->h > 0)) { int ix, - iy, - iix, - iiy; + iy, iix, iiy; ix = img->x; iy = img->y; iix = img->x + img->w - 1; iiy = img->y + img->h - 1; - if ((iy <= ssy) && (iiy >= sy)) + if ((iy <= ssy) + && (iiy >= sy)) { - if ((ix >= sx) && (ix <= ssx)) + if ((ix >= sx) + && (ix <= ssx)) { - if ((iix >= sx) && (iix <= ssx)) + if ((iix >= sx) + && (iix <= + ssx)) { - if (((ix + iix) / 2) > ((sx + ssx) / 2)) - ssx = ix - 1; + if (((ix + + iix) / + 2) > + ((sx + + ssx) / + 2)) + ssx = + ix - + 1; else - sx = iix + 1; + sx = + iix + + 1; } else { - ssx = ix - 1; + ssx = + ix - 1; } } - else if ((iix >= sx) && (iix <= ssx)) + else if ((iix >= sx) + && (iix <= + ssx)) { sx = iix + 1; } @@ -898,7 +928,7 @@ RenderPage(Window win, int page_num, int w, int h) wastext = 1; TextDraw(&ts, win, txt_disp, x + off, y, xspace, 99999, 17, justification); - if ( link > 1 && !strcmp( wd, link_txt) ) + if (link > 1 && !strcmp(wd, link_txt)) { link = 0; link_link[0] = '\0'; @@ -915,13 +945,15 @@ RenderPage(Window win, int page_num, int w, int h) gc = XCreateGC(disp, win, 0, &gcv); EGetColor(&ts.fg_col, &rr, &gg, &bb); - ESetColor(&ts.fg_col, pg->linkr, pg->linkg, pg->linkb); + ESetColor(&ts.fg_col, pg->linkr, pg->linkg, + pg->linkb); EAllocColor(&ts.fg_col); XSetForeground(disp, gc, ts.fg_col.pixel); TextSize(&ts, txt_disp, &tw, &th, 17); extra = ((xspace - tw) * justification) >> 10; - TextDraw(&ts, win, link_txt, x + off + lx + extra, y, - 99999, 99999, 17, 0); + TextDraw(&ts, win, link_txt, + x + off + lx + extra, y, 99999, 99999, + 17, 0); TextSize(&ts, link_txt, &lw, &th, 17); XDrawLine(disp, win, gc, x + off + lx + extra, @@ -947,7 +979,10 @@ RenderPage(Window win, int page_num, int w, int h) link_txt[0] = '\0'; } y += ts.height; - if (y >= (h - (pg->padding + ts.height - (ts.height - ts.xfontset_ascent)))) + if (y >= + (h - + (pg->padding + ts.height - + (ts.height - ts.xfontset_ascent)))) { y = pg->padding; x += col_w + pg->padding; @@ -964,7 +999,8 @@ RenderPage(Window win, int page_num, int w, int h) default: break; } - if (y >= (h - (pg->padding + ts.height - (ts.height - ts.xfontset_ascent)))) + if (y >= + (h - (pg->padding + ts.height - (ts.height - ts.xfontset_ascent)))) { y = pg->padding; x += col_w + pg->padding; diff --git a/dox/text.c b/dox/text.c index 3edd0f49..e467350f 100644 --- a/dox/text.c +++ b/dox/text.c @@ -92,7 +92,8 @@ TextStateLoadFont(TextState * ts) { int as, ds; - Efont_extents(ts->efont, " ", &as, &ds, NULL, NULL, NULL, NULL, NULL); + Efont_extents(ts->efont, " ", &as, &ds, NULL, NULL, NULL, + NULL, NULL); ts->xfontset_ascent = as; ts->height = as + ds; } @@ -145,8 +146,7 @@ TextStateLoadFont(TextState * ts) } void -TextSize(TextState * ts, char *text, - int *width, int *height, int fsize) +TextSize(TextState * ts, char *text, int *width, int *height, int fsize) { char **lines; int i, num_lines; @@ -196,7 +196,8 @@ TextSize(TextState * ts, char *text, { XRectangle ret1, ret2; - XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1, &ret2); + XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1, + &ret2); *height += ret2.height; if (ret2.width > *width) *width = ret2.width; @@ -234,8 +235,7 @@ TextSize(TextState * ts, char *text, void TextDraw(TextState * ts, Window win, char *text, - int x, int y, int w, int h, int fsize, - int justification) + int x, int y, int w, int h, int fsize, int justification) { char **lines; int i, num_lines; @@ -319,7 +319,8 @@ TextDraw(TextState * ts, Window win, char *text, { XRectangle ret1, ret2; - XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1, &ret2); + XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1, + &ret2); if (i == 0) yy += ts->xfontset_ascent; xx = x + (((w - ret2.width) * justification) >> 10); @@ -384,8 +385,7 @@ TextDraw(TextState * ts, Window win, char *text, } EAllocColor(&ts->fg_col); XSetForeground(disp, gc, ts->fg_col.pixel); - XDrawString(disp, win, gc, xx, yy, - lines[i], strlen(lines[i])); + XDrawString(disp, win, gc, xx, yy, lines[i], strlen(lines[i])); yy += ts->xfont->ascent + ts->xfont->descent; } } diff --git a/eesh/E.h b/eesh/E.h index b9499eeb..2d980e3b 100644 --- a/eesh/E.h +++ b/eesh/E.h @@ -213,13 +213,10 @@ extern int debug_level; void Alert(char *fmt, ...); void InitStringList(void); void AssignIgnoreFunction(int (*FunctionToAssign) (void *), - void *params); void AssignRestartFunction(int (*FunctionToAssign) (void *), - void *params); void AssignExitFunction(int (*FunctionToAssign) (void *), - void *params); void AssignTitleText(char *text); void AssignIgnoreText(char *text); diff --git a/eesh/file.c b/eesh/file.c index ad19f13d..a118805d 100644 --- a/eesh/file.c +++ b/eesh/file.c @@ -230,7 +230,8 @@ cp(char *s, char *ss) EDBUG_RETURN_; } -time_t moddate(char *s) +time_t +moddate(char *s) { struct stat st;