[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#247785: tetex-bin: xdvi: patch to add zoom in/out



Package: tetex-bin
Version: 2.0.2-10
Severity: wishlist
Tags: patch

Attached is a patch that defines two new flag values for the
set-shrink-factor() action, two new default keys (`[' and `]') that
use them, and two new default buttons "Zoom in" and "Zoom out", that
use them.  I also define and use a constant MAXSHRINK (in case anyone
is so silly as to see what happens if you try to set a shrink factor
of 9999).

I think this patch provides useful features, and I recommend including
it in future releases of xdvi.  If it matters, I want to license my
modifications with the same license(s) that are used by the files I
have modified.  (I intend for this to be the most convenient choice;
please let me know if there is any problem; this issue is always a big
deal if you send a patch to GNU.)

I include a changelog entry if it is helpful.  There does not seem to
be an xdvi changelog distributed with the Debian sources.

2004-05-06  Matt Swift  <swift@alum.mit.edu>

	* xdvi/xdvi.h, xdvi/events.c: Define and use MAXSHRINK.

	* xdvi/events.c [Act_set_shrink_factor()]: Add flag values 0 and
	-1 to set-shrink-factor().

	* xdvi/app-defaults-xdvik, xdvi/xdvi.c: Add default keystrokes
	`[' and `]' and zoom in/out buttons.

	* xdvi/xdvi.man, xdvi/help-window.c, xdvi/xdvi.c, xdvi/README.VMS, xdvi/XDVI.RNH:
	Document the new arguments to set-shrink-factor() and the new
	keystrokes.


Here are the diffs:

diff -r -u tetex-bin-2.0.2/texk/xdvik/app-defaults-xdvik /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/app-defaults-xdvik
--- tetex-bin-2.0.2/texk/xdvik/app-defaults-xdvik	2002-08-30 19:49:40.000000000 -0400
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/app-defaults-xdvik	2004-05-06 21:21:21.000000000 -0400
@@ -26,6 +26,8 @@
 !Page+5:forward-page(5)\n\
 !Page+10:forward-page(10)\n\
 !Last:goto-page()\n\n\
+!Zoom in:set-shrink-factor(-1)\n\
+!Zoom out:set-shrink-factor(0)\n\
 !Full size:set-shrink-factor(1)\n\
 !$%%:shrink-to-dpi(150)\n\
 !$%%:shrink-to-dpi(100)\n\
@@ -124,7 +126,15 @@
 s    Changes the shrink factor to the given number.  If no\n\
      number is given, the smallest factor that makes the\n\
      entire page fit in the window will be used.  (Margins\n\
-     are ignored in this computation.)\n\
+     are ignored in this computation.)  An argument of `0' means\n\
+     increment the current shrink factor by 1 (zoom out) and an\n\
+     argument of -1 means decrement it (zoom in).\n\
+\n\
+[    Increments the shrink factor (zooms out).  Equivalent to the\n
+     key sequence `0s'.\n\
+\n\
+]    Decrements the shrink factor (zooms in).  Equivalent to the\n
+     key sequence `-1s'.\n\
 \n\
 S    Sets the density factor to be used when shrinking\n\
      bitmaps.  This should be a number between 0 and 100;\n\
diff -r -u tetex-bin-2.0.2/texk/xdvik/events.c /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/events.c
--- tetex-bin-2.0.2/texk/xdvik/events.c	2003-01-16 18:39:07.000000000 -0500
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/events.c	2004-05-06 21:05:13.000000000 -0400
@@ -2690,18 +2690,47 @@
     UNUSED(event);
 
     GET_ARG6(arg, arg = atoi(*params), 'a', arg = shrink_to_fit(),
-	     number, arg = shrink_to_fit());
+	     sign * number, arg = shrink_to_fit());
 
-    if (arg <= 0) {
+    if (arg < -1) {
 	XBell(DISP, 10);
 	print_statusline(STATUS_SHORT,
-			 "set-shrink-factor requires a positive argument");
+                         "set-shrink-factor(): invalid argument: `a', nothing, and integers i > -2 are valid");
 	return;
     }
 
-    print_statusline(STATUS_SHORT, "shrink factor: %d", arg);
     if (arg == mane.shrinkfactor)
 	return;
+
+    /* flag value of -1 means decrement by 1 (zoom in) */
+    if (arg == -1 ) {
+      if (mane.shrinkfactor == 1) {
+	XBell(DISP, 10);
+        print_statusline(STATUS_SHORT, "shrink factor is already 1 (minimal)");
+	return;
+      }
+      arg = mane.shrinkfactor - 1;
+    }
+    /* flag value of 0 means increment by 1 (zoom out) */
+    if (arg == 0) {
+      if (arg == MAXSHRINK) {
+	XBell(DISP, 10);
+        print_statusline(STATUS_SHORT, "shrink factor is already %d (maximal)", MAXSHRINK);
+	return;
+      }
+      arg = mane.shrinkfactor + 1;
+    }
+
+    if (arg > MAXSHRINK) {
+      XBell(DISP, 10);
+      print_statusline(STATUS_SHORT, "shrink factor: %d (requested value %d is out of range)",
+                       MAXSHRINK, arg);
+      arg = MAXSHRINK;
+    }
+    else {
+      print_statusline(STATUS_SHORT, "shrink factor: %d", arg);
+    }
+    
 #if !MOTIF
     mane.shrinkfactor = arg;
 #else
diff -r -u tetex-bin-2.0.2/texk/xdvik/help-window.c /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/help-window.c
--- tetex-bin-2.0.2/texk/xdvik/help-window.c	2003-01-15 19:05:40.000000000 -0500
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/help-window.c	2004-05-06 21:19:31.000000000 -0400
@@ -352,8 +352,16 @@
 	"s    Changes the shrink factor to the given number.  If no\n",
 	"     number is given, the smallest factor that makes the\n",
 	"     entire page fit in the window will be used.  (Margins\n",
-	"     are ignored in this computation.)\n",
-	"\n",
+	"     are ignored in this computation.)  An argument of `0' means\n",
+        "     increment the current shrink factor (zoom out) and an\n",
+        "     argument of -1 means decrement it (zoom in).\n",
+	"\n",
+        "[    Increments the shrink factor (zooms out).  Equivalent to the\n",
+        "     key sequence `0s'.\n",
+        "\n",
+        "]    Decrements the shrink factor (zooms in).  Equivalent to the\n",
+        "     key sequence `-1s'.\n",
+        "\n",
 	"S    Sets the density factor to be used when shrinking\n",
 	"     bitmaps.  This should be a number between 0 and 100;\n",
 	"     higher numbers produce lighter characters.\n",
diff -r -u tetex-bin-2.0.2/texk/xdvik/README.VMS /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/README.VMS
--- tetex-bin-2.0.2/texk/xdvik/README.VMS	2001-04-18 10:24:39.000000000 -0400
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/README.VMS	2004-05-06 21:22:16.000000000 -0400
@@ -275,8 +275,16 @@
         are used, see the -margins option.
 
    s    Changes the shrink factor to the given number.  If no number is given,
-        the smallest factor that makes the entire page fit in the window will be
-        used.  (Margins are ignored in this computation.)
+        the smallest factor that makes the entire page fit in the window will
+        be used.  (Margins are ignored in this computation.)  An argument of `0'
+        means increment the current shrink factor by 1 (zoom out) and an
+        argument of -1 means decrement it (zoom in).
+
+   [    Increments the shrink factor (zooms out).  Equivalent to the key
+        sequence `0s'.
+
+   ]    Decrements the shrink factor (zoom in).  Equivalent to the key
+        sequence `-1s'.
 
    S    Sets the density factor to be used when shrinking bitmaps.  This should
         be a number between 0 and 100; higher numbers produce lighter
@@ -297,11 +305,11 @@
 MOUSE ACTIONS
 -------------
 
-   If the shrink factor is set to any number other than one, then clicking any
-   mouse button will pop up a "magnifying glass" which shows the unshrunk image
-   in the vicinity of the mouse click.  This subwindow disappears when the mouse
-   button is released.  Different mouse buttons produce different sized windows,
-   as indicated by the -mgs option.  Moving the cursor while holding the button
+   If the shrink factor is greater than one, clicking any mouse button will pop
+   up a "magnifying glass" which shows the unshrunk image in the vicinity of
+   the mouse click.  This subwindow disappears when the mouse button is
+   released.  Different mouse buttons produce different sized windows, as
+   indicated by the -mgs option.  Moving the cursor while holding the button
    down will move the magnifying glass.
 
    Also, the scrollbars (if present) behave in the standard X Window way:
diff -r -u tetex-bin-2.0.2/texk/xdvik/xdvi.c /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.c
--- tetex-bin-2.0.2/texk/xdvik/xdvi.c	2003-01-25 12:21:56.000000000 -0500
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.c	2004-05-06 20:17:21.000000000 -0400
@@ -579,6 +579,8 @@
     "\"u\":up()\n"
     "\"M\":set-margins()\n"
     "\"s\":set-shrink-factor()\n"
+    "\"]\":set-shrink-factor(-1)\n"
+    "\"[\":set-shrink-factor(0)\n"
     "\"S\":set-density()\n"
     "<Key>Home:home()\n"
     "<Key>Left:left(0.015)\n"
@@ -631,6 +633,8 @@
 #endif
     "Reread:reread-dvi-file()\n"
     "Help:help()\n\n"
+    "Zoom in:set-shrink-factor(-1)\n"
+    "Zoom out:set-shrink-factor(0)\n"
     "Full size:set-shrink-factor(1)\n"
     "$%%:shrink-to-dpi(150)\n"
     "$%%:shrink-to-dpi(100)\n"
diff -r -u tetex-bin-2.0.2/texk/xdvik/xdvi.h /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.h
--- tetex-bin-2.0.2/texk/xdvik/xdvi.h	2002-12-26 17:35:27.000000000 -0500
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.h	2004-05-06 21:06:04.000000000 -0400
@@ -357,6 +357,12 @@
  */
 #define MAGNIFIER_ACTIVE (mane.shrinkfactor != currwin.shrinkfactor)
 
+/*
+ * Upper bound on the argument to set-shrink-factor().  Inadvertently giving a
+ * very high number will make xdvi freeze for a very long time.
+ */
+#define	MAXSHRINK	999
+
 struct frame {
   	/* dvi_h and dvi_v is the horizontal and vertical baseline position;
 	   it is the responsability of the set_char procedure to update
diff -r -u tetex-bin-2.0.2/texk/xdvik/xdvi.man /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.man
--- tetex-bin-2.0.2/texk/xdvik/xdvi.man	2003-02-01 14:06:23.000000000 -0500
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/xdvi.man	2004-05-06 21:27:03.000000000 -0400
@@ -994,9 +994,10 @@
 .RB ( .shrinkFactor )
 Defines the initial shrink factor.  The default value is @SHRINK@.  If
 .I shrink
-is given as 0, then the initial shrink factor is computed so that the
-page fits within the window (as if the `s' keystroke were given without
-a number).
+is the flag value
+.RB ` 0 ',
+then the initial shrink factor is computed so that the page fits within the
+window (as if the `s' keystroke were given without a number).
 .TP
 .BI \-S " density"
 .RB ( .densityPercent )
@@ -1279,11 +1280,21 @@
 .B \-margins
 option.
 .TP
-.B s
+.B s [ ]
 #tool.RB [ set-shrink-factor() ]
-Changes the shrink factor to the given number.  If no number is given, the
-smallest factor that makes the entire page fit in the window will be used.
-(Margins are ignored in this computation.)
+Changes the shrink factor to the given number.  If no argument or the letter
+#tool.RB ` a '
+is given, the smallest factor that makes the entire page fit in the window
+will be used.  (Margins are ignored in this computation.)  The argument
+#tool.RB ` 0 '
+means increment the current shrink factor (zoom out) and the argument
+#tool.RB ` -1 '
+means decrement it (zoom in).  All other values are rejected.
+The keystroke
+#tool.RB ` [ '
+is equivalent to set-shrink-factor(0) and the keystroke
+#tool.RB ` ] '
+is equivalent to set-shrink-factor(-1).
 .TP
 .B S
 #tool.RB [ set-density() ]
@@ -1475,7 +1486,7 @@
 .B helpSourcespecials
 .IR <text> .
 .SH MOUSE ACTIONS
-If the shrink factor is set to any number other than one, then clicking
+If the shrink factor is greater than one, clicking
 #ifkpathsea
 mouse button 3 
 #endif
@@ -1633,10 +1644,15 @@
 indicating the action of going to the end of the document.
 The argument of
 .B set-shrink-factor
-may be the letter
+may be empty or the letter
 .RB ` a ',
 indicating that the shrink factor should be set to the smallest value such that
-the page will fit in the window.
+the page will fit in the window.  Or it may be the flag value
+.RB ` 0 '
+or
+.RB ` -1 ',
+indicating that the shrink factor should be incremented or decremented,
+respectively.
 Finally, actions that would perform a toggle, such as
 .BR set-keep-flag ,
 may be the letter
@@ -1740,6 +1756,8 @@
 Page+5:forward-page(5)\\n\\
 Page+10:forward-page(10)\\n\\
 Last:goto-page()\\n\\n\\
+Zoom in:set-shrink-factor(-1)\\n\\
+Zoom out:set-shrink-factor(0)\\n\\
 Full size:set-shrink-factor(1)\\n\\
 $%%:shrink-to-dpi(150)\\n\\
 $%%:shrink-to-dpi(100)\\n\\
diff -r -u tetex-bin-2.0.2/texk/xdvik/XDVI.RNH /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/XDVI.RNH
--- tetex-bin-2.0.2/texk/xdvik/XDVI.RNH	2001-04-18 10:24:39.000000000 -0400
+++ /usr/local/src/debian/tetex-bin-2.0.2/texk/xdvik/XDVI.RNH	2004-05-06 21:20:01.000000000 -0400
@@ -522,7 +522,17 @@
 .BREAK
 Changes the shrink factor to the given number.  If no number is given, the
 smallest factor that makes the entire page fit in the window will be used.
-(Margins are ignored in this computation.)
+(Margins are ignored in this computation.)  An argument of `0' means
+increment the current shrink factor by 1 (zoom out) and an argument of -1
+means decrement it (zoom in).
+.INDENT -1
+3 [
+.BREAK
+Increments the shrink factor (zooms out).  Equivalent to the key sequence `0s'.
+.INDENT -1
+3 ]
+.BREAK
+Decrements the shrink factor (zooms in).  Equivalent to the key sequence `-1s'.
 .INDENT -1
 3 S
 .BREAK
@@ -553,12 +563,11 @@
 .INDENT -1
 2 Mouse_Actions
 .BREAK
-If the shrink factor is set to any number other than one, then
-clicking any mouse button will pop up a "magnifying glass" which shows
-the unshrunk image in the vicinity of the mouse click.  This subwindow
-disappears when the mouse button is released.  Different mouse buttons
-produce different sized windows, as indicated by the -mgs option.
-Moving the cursor while holding the button down will move the
+If the shrink factor is greater than one, clicking any mouse button will pop up
+a "magnifying glass" which shows the unshrunk image in the vicinity of the
+mouse click.  This subwindow disappears when the mouse button is released.
+Different mouse buttons produce different sized windows, as indicated by the
+-mgs option.  Moving the cursor while holding the button down will move the
 magnifying glass.
 .SKIP
 Also, the scrollbars (if present) behave in the standard X Window way: pushing





-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.5-beth.4
Locale: LANG=en_US, LC_CTYPE=en_US

Versions of packages tetex-bin depends on:
ii  debconf                     1.4.22       Debian configuration management sy
ii  debianutils                 2.8.1        Miscellaneous utilities specific t
ii  dpkg                        1.10.20      Package maintenance system for Deb
ii  ed                          0.2-20       The classic unix line editor
ii  libc6                       2.3.2.ds1-12 GNU C Library: Shared libraries an
ii  libgcc1                     1:3.3.3-6    GCC support library
ii  libice6                     4.3.0-7      Inter-Client Exchange library
ii  libkpathsea3                2.0.2-10     path search library for teTeX (run
ii  libpaper1                   1.1.14       Library for handling paper charact
ii  libpng12-0                  1.2.5.0-6    PNG library - runtime
ii  libsm6                      4.3.0-7      X Window System Session Management
ii  libstdc++5                  1:3.3.3-6    The GNU Standard C++ Library v3
ii  libt1-5                     5.0.2-0pre1  Type 1 font rasterizer library - r
ii  libwww0                     5.4.0-9      The W3C WWW library
ii  libx11-6                    4.3.0-7      X Window System protocol client li
ii  libxaw7                     4.3.0-7      X Athena widget set library
ii  libxext6                    4.3.0-7      X Window System miscellaneous exte
ii  libxmu6                     4.3.0-7      X Window System miscellaneous util
ii  libxt6                      4.3.0-7      X Toolkit Intrinsics
ii  mime-support                3.26-1       MIME files 'mime.types' & 'mailcap
ii  perl                        5.8.3-3      Larry Wall's Practical Extraction 
ii  sed                         4.0.9-2      The GNU sed stream editor
ii  tetex-base                  2.0.2-6      Basic library files of teTeX
ii  xlibs                       4.3.0-7      X Window System client libraries m
ii  zlib1g                      1:1.2.1-5    compression library - runtime

-- debconf information:
* tetex-bin/hyphen: 
  tetex-bin/oldcfg: true
* tetex-bin/upd_map: true
  tetex-bin/cnf_name: 
* tetex-bin/fmtutil: true
* tetex-bin/use_debconf: true
* tetex-bin/groupname: users
* tetex-bin/userperm: false
* tetex-bin/groupperm: true
* tetex-bin/lsr-perms: true
* tetex-bin/texmf: true



Reply to: