further source code cleanup

svn path=/trunk/kdegraphics/kdvi/; revision=207204
This commit is contained in:
Stefan Kebekus 2003-02-16 09:01:47 +00:00
parent 3db56840d3
commit 6093647a02
7 changed files with 37 additions and 226 deletions

View file

@ -1,178 +0,0 @@
kdvi 0.4 - Alpha release
~~~~~~~~~~~~~~~~~~~~~~~~
This is a port of xdvik version 18f by many authors (see files AUTHORS)
to the K Desktop Environment. kdvi is used to view TeX DVI files. It is
a replacement of xdvi from tetex-distribution and uses the kpathsea
library to find the needed pk-font files. If you have tetex you should be
able to run kdvi. It requires also Ghostcript to render any postscript
specials in dvi files. kdvi uses the Qt toolkit.
This version is quite useable.
Note. The make step currently runs configure in the kpathsea subdirectory.
I may eliminate this in a later version.
If xdvi from tetex works for you then so should kdvi.
However, it has only been tested on Linux. The support for handling the xdvi
command line arguments and X application defaults is missing (partly replaced
by KConfig, see below and online help).
Postscript special handling only supported with Ghostscript.
CONFIGURATION
~~~~~~~~~~~~~
Version 0.4 can be configured through dialogs.
Before giving kdvi a file to open you should set the following entries in Fonts
page of Preferences:
o Resolution Set this to the base resolution of your printer if you
have already PK-fonts for printer available.
o MetafontMode This you can set to match the definition of your printer or
use the default mode '/'.
It is necessary to set the Resolution as required by your TeX installation.
(tetex stores this usually in /usr/lib/texmf/texmf/xdvi/XDvi). MetafontMode is
needed when you want to enable automatic pk-font generation (menu option).
See online help for more info.
These variables should preferably be set in the system wide configuration file.
The system administrator can set the proper values ( and other settings as
desired ) with kdvi and copy the config file ~/.kde/share/config/kdvirc
to $KDEDIR/share/config/kdvirc.
You can also specify the paths where your pk-fonts are located, if
kdvi does not find them automatically, by setting entry 'PK Font Path' to
the list of directories to be searched:
/var/lib/texmf/fonts/pk/ljfour/:/some/other/place
You can make kdvi search recursively by adding an extra / at the end of
directory name:
/var/lib/texmf/fonts//
This works like xdvi's XDVIFONTS environment variable.
There is also good (gnu info) documentation available for the kpathsea library
that kdvi uses for font searching.
USAGE:
~~~~~~
The dvi viewer may be started using a file name to display a file, e.g:
kdvi somepath/paper.dvi
or without a file name as
kdvi
kdvi will then allow a file to be opened from a dialog or when dropped from
file manager (konqueror).
The usual parameters handled by Qt should also work:
kdvi -style windows -display :0 -geometry 400x400+0+0
CHANGES:
~~~~~~~~
Version 0.4
~~~~~~~~~~~
- Antialiased PostScript specials
- Support session management
- Changes menu accelerators according to KKeyConfig settings.
Shortcuts should follow KDE standard.
- Statusbar shows the coordinates of a clicked point in millimeters.
- Changed build to use automake (not for kpathsea yet)
- Better print dialog + print setup dialog. Support for dvilj4 and dvips.
- Automatic reload when dvi file is updated
- Uses KToolbar, KStatusbar and KTopLevelWidget
- Command line option '-caption'
- Uses KIconLoader and KDebugDialog
- Partial support for translations
- Many bug fixes
- Internal changes
- Miscellanous other changes
Version 0.3
~~~~~~~~~~~
- Preferences dialog
- Paper type selectable
- Configurable key bindings with kkeyconfig (first cut)
- Works with kdisplay
- Uses KMsgBox dialogs
- Sticky popup menus
- Needs Qt 1.2 ( check marks in menus )
- Many bug fixes
- More KDE conforming
Version 0.2
~~~~~~~~~~~
- Configuration file uses different variables
- Status bar and vertical toolbar
- Added a page list for selecting the current page and marking pages
for printing.
- Initial print dialog. Does not support printing of marked pages that
have page numbers different from the sequence number (pages are not
numbered as 1,2,3...). Requires dvips for converting dvi to PostScript,
gv for previewing PS and mpage for printing multiple pages per sheet.
(These should be replaced by kprogs.)
- A scroller widget that can also select the next or previous page.
- Support for new TeX config file format of tetex 4
- File drops accepted (local files only)
- Many bug fixes
- Builds using configure
- Screen updating reduced and scrolling made smoother.
This results in kdvi allocating huge amounts of memory when using large
magnifications.
Version 0.1
~~~~~~~~~~~
First release. Should be quite usable, with some problems on error handling
(bad dvi etc.) and postscript special handling. All enabled menu entries and
toolbar buttons are operational, many keybindings are available (see help)
allthough probably not KDE-conformant (expect changes).

2
TODO
View file

@ -2,7 +2,7 @@ ToDo-List for kdvi
URGENT / URGENT BUGFIXING
o add tip: kdvi can load compressed files!
o add "papersize" which does not display the margin
o get rid of useless README.kdvi
o Proper handling of the base-url
o add "tt.dvi.gz" to the list of recent files, not "/tmp/kviews....."

View file

@ -316,7 +316,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
b = readUINT32();
b = xspell_conv(b);
if (a > 0 && b > 0 && PostScriptOutPutString == NULL)
set_rule( ((int) ROUNDUP(xspell_conv(a), shrink_factor * 65536)), ((int) ROUNDUP(b, shrink_factor * 65536)) );
set_rule( ((int) ROUNDUP(xspell_conv(a), currwin.shrinkfactor * 65536)), ((int) ROUNDUP(b, currwin.shrinkfactor * 65536)) );
DVI_H += b;
break;
@ -330,7 +330,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
a = xspell_conv(a);
b = xspell_conv(b);
if (a > 0 && b > 0 && PostScriptOutPutString == NULL)
set_rule(((int) ROUNDUP(a, shrink_factor * 65536)), ((int) ROUNDUP(b, shrink_factor * 65536)));
set_rule(((int) ROUNDUP(a, currwin.shrinkfactor * 65536)), ((int) ROUNDUP(b, currwin.shrinkfactor * 65536)));
break;
case NOP:
@ -344,7 +344,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
command_pointer += 11 * 4;
DVI_H = basedpi << 16; // Reminder: DVI-coordinates start at (1",1") from top of page
DVI_V = basedpi;
PXL_V = int(DVI_V/shrink_factor);
PXL_V = int(DVI_V/currwin.shrinkfactor);
WW = XX = YY = ZZ = 0;
break;
@ -446,7 +446,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
textLinkList[textLinkList.size()-1].linkText += '\n';
}
DVI_V += xspell_conv(DDtmp)/65536;
PXL_V = int(DVI_V/shrink_factor);
PXL_V = int(DVI_V/currwin.shrinkfactor);
}
break;
@ -467,7 +467,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
textLinkList[textLinkList.size()-1].linkText += '\n';
}
DVI_V += YY/65536;
PXL_V = int(DVI_V/shrink_factor);
PXL_V = int(DVI_V/currwin.shrinkfactor);
break;
case Z1:
@ -487,7 +487,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
textLinkList[textLinkList.size()-1].linkText += '\n';
}
DVI_V += ZZ/65536;
PXL_V = int(DVI_V/shrink_factor);
PXL_V = int(DVI_V/currwin.shrinkfactor);
break;
case FNT1:
@ -609,7 +609,7 @@ void dviWindow::draw_page(void)
// Mark hyperlinks in blue. We draw a blue line under the
// character whose width is equivalent to 0.5 mm, but at least
// one pixel.
int h = (int)(basedpi*0.05/(2.54*shrink_factor) + 0.5);
int h = (int)(basedpi*0.05/(2.54*currwin.shrinkfactor) + 0.5);
h = (h < 1) ? 1 : h;
for(unsigned int i=0; i<hyperLinkList.size(); i++) {
int x = hyperLinkList[i].box.left();

27
pk.cpp
View file

@ -62,8 +62,33 @@
#include "glyph.h"
#include "xdvi.h"
#define BMUNIT Q_UINT32
#define BITS_PER_BMUNIT 32
#define BYTES_PER_BMUNIT 4
#define ADD(a, b) ((BMUNIT *) (((char *) a) + b))
#define SUB(a, b) ((BMUNIT *) (((char *) a) - b))
extern void oops(QString message);
extern void alloc_bitmap(bitmap *bitmap);
/*
* Allocate bitmap for given font and character
*/
void alloc_bitmap(bitmap *bitmap)
{
register unsigned int size;
/* width must be multiple of 16 bits for raster_op */
bitmap->bytes_wide = ROUNDUP((int) bitmap->w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
size = bitmap->bytes_wide * bitmap->h;
bitmap->bits = new char[size != 0 ? size : 1];
}
// This table is used for changing the bit order in a byte. The

View file

@ -223,8 +223,8 @@ void dviWindow::epsf_special(QString cp)
bbox_height = rhi;
}
bbox_width *= 0.1 * 65536.0*fontPixelPerDVIunit() / shrink_factor;
bbox_height *= 0.1 * 65536.0*fontPixelPerDVIunit() / shrink_factor;
bbox_width *= 0.1 * 65536.0*fontPixelPerDVIunit() / currwin.shrinkfactor;
bbox_height *= 0.1 * 65536.0*fontPixelPerDVIunit() / currwin.shrinkfactor;
QRect bbox(PXL_H - currwin.base_x, PXL_V - currwin.base_y - (int)bbox_height, (int)bbox_width, (int)bbox_height);
foreGroundPaint.save();

View file

@ -83,20 +83,6 @@ please report the problem."));
exit(1);
}
/*
* Allocate bitmap for given font and character
*/
void alloc_bitmap(bitmap *bitmap)
{
register unsigned int size;
/* width must be multiple of 16 bits for raster_op */
bitmap->bytes_wide = ROUNDUP((int) bitmap->w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
size = bitmap->bytes_wide * bitmap->h;
bitmap->bits = new char[size != 0 ? size : 1];
}
/*
*
* Read size bytes from the FILE fp, constructing them into a

24
xdvi.h
View file

@ -5,33 +5,13 @@
* Written by Eric C. Cooper, CMU
*/
/*
* pixel_conv is currently used only for converting absolute positions
* to pixel values; although normally it should be
* ((int) ((x) / shrink_factor + (1 << 15) >> 16)),
* the rounding is achieved instead by moving the constant 1 << 15 to
* PAGE_OFFSET in dvi_draw.c.
*/
#define BMUNIT Q_UINT32
#define BITS_PER_BMUNIT 32
#define BYTES_PER_BMUNIT 4
#define ADD(a, b) ((BMUNIT *) (((char *) a) + b))
#define SUB(a, b) ((BMUNIT *) (((char *) a) - b))
extern BMUNIT bit_masks[BITS_PER_BMUNIT + 1];
extern struct drawinf currinf;
/* entries below with the characters 'dvi' in them are actually stored in
scaled pixel units */
#define DVI_H currinf.data.dvi_h
#define PXL_H ((int) ((currinf.data.dvi_h) / (shrink_factor * 65536)))
#define PXL_H ((int) ((currinf.data.dvi_h) / (currwin.shrinkfactor * 65536)))
#define DVI_V currinf.data.dvi_v
#define PXL_V currinf.data.pxl_v
#define WW currinf.data.w
@ -44,8 +24,6 @@ extern unsigned long num (FILE *, int);
extern long snum(FILE *, int);
extern struct WindowRec mane, currwin;
#define shrink_factor currwin.shrinkfactor
#define one(fp) ((unsigned char) getc(fp))
#define sone(fp) ((long) one(fp))
#define two(fp) num (fp, 2)