wdvi

network DVI viewer
Log | Files | Refs

commit f90edb2f922e8705b6d58d00f9aa295f66103ad8
parent dffed01fd15bd90f6c74da2145c905222198f88d
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Mon, 23 Aug 2021 21:52:34 +0000

Disable BUTTONS

Diffstat:
Mevents.c | 378-------------------------------------------------------------------------------
Mxdvi.c | 88-------------------------------------------------------------------------------
Mxdvi.h | 20--------------------
3 files changed, 0 insertions(+), 486 deletions(-)

diff --git a/events.c b/events.c @@ -39,11 +39,6 @@ NOTE: #include <X11/Xaw/Viewport.h> -#ifdef BUTTONS -# include <X11/Xaw/Command.h> -#define PANEL_WIDGET_CLASS compositeWidgetClass -#define BUTTON_WIDGET_CLASS commandWidgetClass -#endif /* BUTTONS */ #include <X11/XKBlib.h> #define XBell(dpy, percent) XkbBell(dpy, mane.win, percent, (Atom) None) @@ -136,9 +131,6 @@ static ACTION_DECL(Act_shrink_to_dpi); static ACTION_DECL(Act_set_density); static ACTION_DECL(Act_set_greyscaling); static ACTION_DECL(Act_set_color); -#if BUTTONS -static ACTION_DECL(Act_set_expert_mode); -#endif static ACTION_DECL(Act_reread_dvi_file); static ACTION_DECL(Act_discard_number); @@ -180,9 +172,6 @@ XtActionsRec Actions[] = { {"open-dvi-file", Act_open_dvi_file}, {"set-greyscaling", Act_set_greyscaling}, {"set-color", Act_set_color}, -#if BUTTONS - {"set-expert-mode", Act_set_expert_mode}, -#endif {"reread-dvi-file", Act_reread_dvi_file}, {"discard-number", Act_discard_number}, {"magnifier", Act_magnifier}, @@ -282,10 +271,6 @@ compile_action(str, app) } -#if BUTTONS -static Widget line_widget; -static int destroy_count = 0; -#endif /* BUTTONS */ static Widget x_bar, y_bar; /* horizontal and vertical scroll bars */ @@ -302,275 +287,6 @@ static Arg resize_args[] = { #define width_arg (resize_args[0]) #define height_arg (resize_args[1]) -#if BUTTONS - -static Arg resizable_on[] = { - {XtNresizable, (XtArgVal) True}, -}; - -static Arg resizable_off[] = { - {XtNresizable, (XtArgVal) False}, -}; - -static Arg line_args[] = { - {XtNbackground, (XtArgVal) 0}, - {XtNwidth, (XtArgVal) 1}, - {XtNfromHoriz, (XtArgVal) NULL}, - {XtNborderWidth, (XtArgVal) 0}, - {XtNtop, (XtArgVal) XtChainTop}, - {XtNbottom, (XtArgVal) XtChainBottom}, - {XtNleft, (XtArgVal) XtChainRight}, - {XtNright, (XtArgVal) XtChainRight}, -}; - -static Arg panel_args[] = { - {XtNborderWidth, (XtArgVal) 0}, - {XtNfromHoriz, (XtArgVal) NULL}, - {XtNtranslations, (XtArgVal) NULL}, - {XtNtop, (XtArgVal) XtChainTop}, - {XtNbottom, (XtArgVal) XtChainBottom}, - {XtNleft, (XtArgVal) XtChainRight}, - {XtNright, (XtArgVal) XtChainRight}, -}; - -static void handle_command(); - -static XtCallbackRec command_call[] = { - {handle_command, NULL}, - {NULL, NULL}, -}; - -static Arg command_args[] = { - {XtNlabel, (XtArgVal) NULL}, - {XtNx, (XtArgVal) 0}, - {XtNy, (XtArgVal) 0}, - {XtNborderWidth,(XtArgVal) 0}, - {XtNcallback, (XtArgVal) command_call}, -}; - -struct button_info { - struct button_info *next; - char *label; - struct xdvi_action *action; - Widget widget; -}; - -static struct button_info *b_head; - -const char default_button_config[] = - "Quit:quit()\n\ -Open:open-dvi-file()\n\n\ -Full size:set-shrink-factor(1)\n\ -$%%:shrink-to-dpi(150)\n\ -$%%:shrink-to-dpi(100)\n\ -$%%:shrink-to-dpi(75)\n\n\ -Page-10:back-page(10)\n\ -Page-5:back-page(5)\n\ -Prev:back-page(1)\n\n\ -Next:forward-page(1)\n\ -Page+5:forward-page(5)\n\ -Page+10:forward-page(10)\n\n\ -Print:print()"; - -void -create_buttons() -{ - Dimension max_button_width; - Dimension y_pos; - struct button_info **bipp; - struct button_info *bp; - const char *cspos; - int button_number; - int shrink_button_number; - int shrink_arg; - struct xdvi_action *action; - - line_args[0].value = (XtArgVal) resource._fore_Pixel; - line_args[2].value = (XtArgVal) vport_widget; - line_widget = XtCreateWidget("line", widgetClass, form_widget, - line_args, XtNumber(line_args)); - panel_args[1].value = (XtArgVal) line_widget; - if (panel_args[2].value == (XtArgVal) NULL) - panel_args[2].value = - (XtArgVal) XtParseTranslationTable("<ButtonPress>:"); - panel_widget = XtCreateWidget("panel", PANEL_WIDGET_CLASS, - form_widget, panel_args, XtNumber(panel_args)); - - button_number = shrink_button_number = 0; - b_head = NULL; - bipp = &b_head; - command_args[1].value = resource.btn_side_spacing; - command_args[3].value = resource.btn_border_width; - max_button_width = 0; - y_pos = resource.btn_top_spacing; - - for (cspos = resource.button_translations;; ++cspos) { - Dimension w, h; - const char *p1, *p2; - char *label, *q; - char name[9]; - Widget widget; - size_t len; - - while (*cspos == ' ' || *cspos == '\t') ++cspos; - if (*cspos == '\0') break; - - if (*cspos == '\n') { - y_pos += resource.btn_between_extra; - continue; - } - - len = 0; /* find length of actual label string */ - shrink_arg = 0; - for (p2 = p1 = cspos; *p1 != '\0' && *p1 != ':'; ) { - if (*p1 == '\\' && p1[1] != '\0') { - p1 += 2; - p2 = p1; - --len; - } - else if (*p1 == '$' - && (p1[1] == '#' || p1[1] == '%' || p1[1] == '_')) { - shrink_arg = 1; - ++p1; - if (*p1 == '%') len += 2; - else if (*p1 == '_') len -= 2; - } - else { - ++p1; - if (p1[-1] != ' ' && p1[-1] != '\t') p2 = p1; - } - } - len += p2 - cspos; - - if (*p1 == '\0') break; /* if premature end of string */ - - if (!compile_action(p1 + 1, &action)) break; - - if (shrink_arg) { - for (;; action = action->next) { - if (action == NULL) { - fprintf(stderr, "Warning: label on button number %d \ -refers to non-existent shrink action.\n", button_number + 1); - break; - } - if (action->proc == Act_set_shrink_factor - || action->proc == Act_shrink_to_dpi) { - if (shrink_button_number < 9 - && resource.shrinkbutton[shrink_button_number] != 0) { - shrink_arg - = resource.shrinkbutton[shrink_button_number]; - if (shrink_arg < 1) shrink_arg = 1; - else if (shrink_arg > 99) shrink_arg = 99; - if (action->num_params > 0) free(action->param); - action->proc = Act_set_shrink_factor; - action->num_params = 1; - action->param = xmalloc(4); - sprintf(action->param, "%d", shrink_arg); - } - else { - if (action->num_params > 0) { - shrink_arg = atoi(action->param); - if (action->proc == Act_shrink_to_dpi) - shrink_arg = (double) pixels_per_inch - / shrink_arg + 0.5; - if (shrink_arg < 1) shrink_arg = 1; - else if (shrink_arg > 99) shrink_arg = 99; - } - } - break; - } - } - ++shrink_button_number; - } - - label = xmalloc(len + 1); - for (q = label; cspos < p2; ++cspos) { - if (*cspos == '\\') { - if (++cspos < p2) - *q++ = *cspos; - } - else if (*cspos == '$' - && (cspos[1] == '#' || cspos[1] == '%' || cspos[1] == '_')) { - ++cspos; - if (*cspos == '#') { - sprintf(q, "%d", shrink_arg); - } - else if (*cspos == '%') { - if (shrink_arg <= 15) - sprintf(q, "%d", (int) (100.0 / shrink_arg + .5)); - else - sprintf(q, "%.2f", 100.0 / shrink_arg); - } - q += strlen(q); - } - else - *q++ = *cspos; - } - *q = '\0'; - if (q > label + len) - oops("Internal error computing button labels"); - - command_args[0].value = (XtArgVal) label; - command_args[2].value = (XtArgVal) y_pos; - command_call[0].closure = (XtPointer) action; - if (++button_number > 99) break; /* if too many buttons */ - sprintf(name, "button%d", button_number); - widget = XtCreateWidget(name, BUTTON_WIDGET_CLASS, panel_widget, - command_args, XtNumber(command_args)); - resize_args[0].value = (XtArgVal) &w; - resize_args[1].value = (XtArgVal) &h; - XtGetValues(widget, resize_args, 2); - if (w > max_button_width) max_button_width = w; - y_pos += h + resource.btn_between_spacing - + 2 * resource.btn_border_width; - - bp = xmalloc(sizeof *bp); - bp->label = label; - bp->action = action; - bp->widget = widget; - *bipp = bp; - bipp = &bp->next; - - cspos = index(p1 + 1, '\n'); - if (cspos == NULL) - break; - } - *bipp = NULL; - - xtra_wid = max_button_width - + 2 * (resource.btn_side_spacing + resource.btn_border_width); - - width_arg.value = (XtArgVal) xtra_wid; - XtSetValues(panel_widget, &width_arg, 1); - - ++xtra_wid; - - width_arg.value = (XtArgVal) max_button_width; - for (bp = b_head; bp != NULL; bp = bp->next) { - XtSetValues(bp->widget, &width_arg, 1); - XtManageChild(bp->widget); - } - -} - - -void -set_button_panel_height(h) - XtArgVal h; -{ - height_arg.value = h; - XtSetValues(line_widget, &height_arg, 1); - XtManageChild(line_widget); - XtSetValues(panel_widget, &height_arg, 1); - XtManageChild(panel_widget); - if (panel_cursor == (Cursor) 0) - panel_cursor = XCreateFontCursor(DISP, XC_left_ptr); - if (XtIsRealized(panel_widget)) - XDefineCursor(DISP, XtWindow(panel_widget), panel_cursor); -} - - -#endif /* BUTTONS */ /* @@ -1288,50 +1004,10 @@ handle_resize(widget, junk, event, cont) resized = True; } -#ifdef BUTTONS - /*ARGSUSED*/ -static void -handle_command(widget, client_data, call_data) - Widget widget; - XtPointer client_data; - XtPointer call_data; -{ - struct xdvi_action *actp; - - for (actp = (struct xdvi_action *) client_data; - actp != NULL; - actp = actp->next) - (actp->proc)(widget, NULL, &actp->param, &actp->num_params); -} - - /*ARGSUSED*/ -static void -handle_destroy_buttons(w, client_data, call_data) - Widget w; - XtPointer client_data; - XtPointer call_data; -{ - if (--destroy_count != 0) return; - XtSetValues(vport_widget, resizable_on, XtNumber(resizable_on)); - if (resource.expert) { - /* destroy buttons */ - XtGetValues(form_widget, arg_wh, XtNumber(arg_wh)); - XdviResizeWidget(vport_widget, window_w, window_h); - } - else { - create_buttons(); /* this determines xtra_wid */ - XdviResizeWidget(vport_widget, window_w -= xtra_wid, window_h); - set_button_panel_height((XtArgVal) window_h); - } -} -#endif /* BUTTONS */ void reconfig() { -#if BUTTONS - XtSetValues(vport_widget, resizable_off, XtNumber(resizable_off)); -#endif XdviResizeWidget(draw_widget, page_w, page_h); get_geom(); } @@ -1546,10 +1222,6 @@ ACTION(Act_center) { int x, y; -#if BUTTONS - if (event == NULL) - return; /* button actions do not provide events */ -#endif x = event->xkey.x - clip_w / 2; @@ -1689,10 +1361,6 @@ ACTION(Act_set_margins) { Window ww; -#if BUTTONS - if (event == NULL) - return; /* button actions do not provide events */ -#endif (void) XTranslateCoordinates(DISP, event->xkey.window, mane.win, event->xkey.x, event->xkey.y, &home_x, &home_y, @@ -1862,52 +1530,6 @@ ACTION(Act_set_color) } -#if BUTTONS - -static -ACTION(Act_set_expert_mode) -{ - TOGGLE(resource.expert) - - if (resource.expert) { /* create buttons */ - resource.expert = False; - if (destroy_count != 0) return; - create_buttons(); /* this determines xtra_wid */ - XtSetValues(vport_widget, resizable_on, XtNumber(resizable_on)); - XdviResizeWidget(vport_widget, window_w -= xtra_wid, window_h); - set_button_panel_height((XtArgVal) window_h); - } - else { /* destroy buttons */ - resource.expert = True; - if (destroy_count != 0) return; - destroy_count = 2; - XtAddCallback(panel_widget, XtNdestroyCallback, - handle_destroy_buttons, (XtPointer) 0); - XtAddCallback(line_widget, XtNdestroyCallback, - handle_destroy_buttons, (XtPointer) 0); - XtDestroyWidget(panel_widget); - XtDestroyWidget(line_widget); - window_w += xtra_wid; - while (b_head != NULL) { - struct button_info *bp = b_head; - struct xdvi_action *action; - - b_head = bp->next; - free(bp->label); - /* free bp->action */ - for (action = bp->action; action != NULL; ) { - struct xdvi_action *act2 = action; - - action = act2->next; - if (act2->num_params > 0) free(act2->param); - free(act2); - } - free(bp); - } - } -} - -#endif /* BUTTONS */ static diff --git a/xdvi.c b/xdvi.c @@ -56,7 +56,6 @@ NOTE: * XAW3D compile with Xaw3d variant of Xaw widgets. XAW should be * defined, too. * MOTIF compile with X toolkit and Motif widgets - * BUTTONS compile with buttons on the side of the window (needs toolkit) * WORDS_BIGENDIAN store bitmaps internally with most significant bit first * BMTYPE store bitmaps in unsigned BMTYPE * BMBYTES sizeof(unsigned BMTYPE) @@ -190,9 +189,6 @@ struct WindowRec currwin= {(Window) 0, 1, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0}; #ifdef lint WidgetClass widgetClass; WidgetClass viewportWidgetClass; -#ifdef BUTTONS -WidgetClass formWidgetClass, compositeWidgetClass, commandWidgetClass; -#endif /* BUTTONS */ #endif /* lint */ static char * atom_names[] = {"XDVI WINDOWS", "DVI NAME", "SRC GOTO", @@ -209,9 +205,6 @@ static const char silent[] = " "; /* flag value for usage() */ static const char subst[] = "x"; /* another flag value */ static const char *subst_val[] = { -#ifdef BUTTONS - "-shrinkbutton[1-9] <shrink>", -#endif "-mgs[n] <size>"}; @@ -248,19 +241,6 @@ static XrmOptionDescRec options[] = { {"+l", ".listFonts", XrmoptionNoArg, (XPointer) "off"}, {"-nofreetypefonts", ".freetypeFonts", XrmoptionNoArg, (XPointer) "off"}, {"+nofreetypefonts", ".freetypeFonts", XrmoptionNoArg, (XPointer) "on"}, -#ifdef BUTTONS -{"-expert", ".expert", XrmoptionNoArg, (XPointer) "on"}, -{"+expert", ".expert", XrmoptionNoArg, (XPointer) "off"}, -{"-shrinkbutton1",".shrinkButton1",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton2",".shrinkButton2",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton3",".shrinkButton3",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton4",".shrinkButton4",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton5",".shrinkButton5",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton6",".shrinkButton6",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton7",".shrinkButton7",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton8",".shrinkButton8",XrmoptionSepArg, (XPointer) NULL}, -{"-shrinkbutton9",".shrinkButton9",XrmoptionSepArg, (XPointer) NULL}, -#endif {"-mgs", ".magnifierSize1",XrmoptionSepArg, (XPointer) NULL}, {"-mgs1", ".magnifierSize1",XrmoptionSepArg, (XPointer) NULL}, {"-mgs2", ".magnifierSize2",XrmoptionSepArg, (XPointer) NULL}, @@ -357,9 +337,6 @@ static const char base_translations[] = "" #endif "\"G\":set-greyscaling()\n" "\"C\":set-color()\n" -#if BUTTONS -"\"x\":set-expert-mode()\n" -#endif "<Key>Escape:discard-number()\n" /* Esc */ "s<Btn1Down>:drag(|)\n" "s<Btn2Down>:drag(+)\n" @@ -471,40 +448,6 @@ static XtResource application_resources[] = { #endif {"version", "Version", XtRBoolean, sizeof(Boolean), offset(version_flag), XtRString, "false"}, -#if BUTTONS -{"expert", "Expert", XtRBoolean, sizeof(Boolean), - offset(expert), XtRString, "false"}, -{"buttonTranslations", "ButtonTranslations", XtRString, sizeof(char *), - offset(button_translations), XtRString, (XtPointer) default_button_config}, -{"shrinkButton1", "ShrinkButton1", XtRInt, sizeof(int), - offset(shrinkbutton[0]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton2", "ShrinkButton2", XtRInt, sizeof(int), - offset(shrinkbutton[1]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton3", "ShrinkButton3", XtRInt, sizeof(int), - offset(shrinkbutton[2]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton4", "ShrinkButton4", XtRInt, sizeof(int), - offset(shrinkbutton[3]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton5", "ShrinkButton5", XtRInt, sizeof(int), - offset(shrinkbutton[4]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton6", "ShrinkButton6", XtRInt, sizeof(int), - offset(shrinkbutton[5]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton7", "ShrinkButton7", XtRInt, sizeof(int), - offset(shrinkbutton[6]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton8", "ShrinkButton8", XtRInt, sizeof(int), - offset(shrinkbutton[7]), XtRImmediate, (XtPointer) 0}, -{"shrinkButton9", "ShrinkButton9", XtRInt, sizeof(int), - offset(shrinkbutton[8]), XtRImmediate, (XtPointer) 0}, -{"buttonSideSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), - offset(btn_side_spacing), XtRImmediate, (XtPointer) 6}, -{"buttonTopSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), - offset(btn_top_spacing), XtRImmediate, (XtPointer) 50}, -{"buttonBetweenSpacing", "ButtonSpacing", XtRDimension, sizeof(Dimension), - offset(btn_between_spacing), XtRImmediate, (XtPointer) 20}, -{"buttonBetweenExtra", "ButtonSpacing", XtRDimension, sizeof(Dimension), - offset(btn_between_extra), XtRImmediate, (XtPointer) 50}, -{"buttonBorderWidth", "BorderWidth", XtRDimension, sizeof(Dimension), - offset(btn_border_width), XtRImmediate, (XtPointer) 1}, -#endif {"magnifierSize1", "MagnifierSize", XtRString, sizeof(char *), offset(mg_arg[0]), XtRString, (XtPointer) NULL}, {"magnifierSize2", "MagnifierSize", XtRString, sizeof(char *), @@ -557,17 +500,6 @@ static const char *usagestr[] = { /* editor */ "editor", /* sourceposition */ "\"linenumber filename\"", /* rv */ "^-l", "-rv", -#ifdef BUTTONS - /* shrinkbutton1 */ subst, - /* shrinkbutton2 */ silent, - /* shrinkbutton3 */ silent, - /* shrinkbutton4 */ silent, - /* shrinkbutton5 */ silent, - /* shrinkbutton6 */ silent, - /* shrinkbutton7 */ silent, - /* shrinkbutton8 */ silent, - /* shrinkbutton9 */ silent, -#endif /* mgs */ subst, /* mgs1 */ silent, /* mgs2 */ silent, @@ -586,9 +518,6 @@ static const char *usagestr[] = { /* geometry */ "^-cr", "-geometry <geometry>", /* icongeometry */ "geometry", /* iconic */ "^-icongeometry", "-iconic", -#ifdef BUTTONS - /* font */ "^-icongeometry", "-font <font>", -#endif /* wheelunit */ "pixels", /* dvipspath */ "path", /* debug */ "bitmask", @@ -2045,12 +1974,7 @@ argument is to override any papersize specials in the dvi file.\n\n", stderr); } /* determine default window size */ -#if BUTTONS - if (!resource.expert) - create_buttons(); -#else #define xtra_wid 0 -#endif { XtWidgetGeometry constraints; XtWidgetGeometry reply; @@ -2100,10 +2024,6 @@ argument is to override any papersize specials in the dvi file.\n\n", stderr); set_wh_args[0].value = (XtArgVal) (reply.width + xtra_wid); set_wh_args[1].value = (XtArgVal) reply.height; XtSetValues(top_level, set_wh_args, XtNumber(set_wh_args)); -#ifdef BUTTONS - set_wh_args[0].value -= xtra_wid; - XtSetValues(vport_widget, set_wh_args, XtNumber(set_wh_args)); -#endif /* BUTTONS */ } @@ -2112,10 +2032,6 @@ argument is to override any papersize specials in the dvi file.\n\n", stderr); */ -#if BUTTONS - if (!resource.expert) - set_button_panel_height(set_wh_args[1].value); -#endif XtAddEventHandler(top_level, PropertyChangeMask, False, handle_property_change, (XtPointer) NULL); XtAddEventHandler(vport_widget, StructureNotifyMask, False, @@ -2126,10 +2042,6 @@ argument is to override any papersize specials in the dvi file.\n\n", stderr); XSetWMProtocols(DISP, XtWindow(top_level), &XA_WM_DELETE_WINDOW, 1); XtAddEventHandler(top_level, NoEventMask, True, handle_messages, NULL); -# if BUTTONS - if (!resource.expert) - XDefineCursor(DISP, XtWindow(panel_widget), panel_cursor); -# endif currwin.win = mane.win = XtWindow(draw_widget); diff --git a/xdvi.h b/xdvi.h @@ -412,16 +412,6 @@ extern struct _resource { Boolean prescan; const char *debug_arg; Boolean version_flag; -#if BUTTONS - Boolean expert; - const char *button_translations; - int shrinkbutton[9]; - Dimension btn_side_spacing; - Dimension btn_top_spacing; - Dimension btn_between_spacing; - Dimension btn_between_extra; - Dimension btn_border_width; -#endif const char *mg_arg[5]; Boolean _use_color; Boolean _use_grey; @@ -679,12 +669,6 @@ Boolean drawing_mag = False; Widget top_level = 0; Widget vport_widget, draw_widget, clip_widget; Widget addr_widget, form_widget; -# if BUTTONS -int xtra_wid = 0; -extern const char default_button_config[]; /* defined in events.c */ -Widget panel_widget; -Cursor panel_cursor = 0; -# endif #define WARN(t, s) (void) warning_popup(s, "OK", NULL) #define WARN1(t, s, s1) (void) warning_popup_long(s, "OK", NULL, s1) @@ -811,10 +795,6 @@ _XFUNCPROTOBEGIN extern int atopix(const char *, wide_bool); extern Bool compile_action(const char *, struct xdvi_action **); -#if BUTTONS -extern void create_buttons(void); -extern void set_button_panel_height(XtArgVal); -#endif /* BUTTONS */ extern void init_plane_masks(void); extern Pixel alloc_color(const struct rgb *, Pixel); extern void do_color_change(void);