Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.53 diff -u -2 -0 -r1.53 ChangeLog --- a/xc/ChangeLog 30 May 2004 00:52:30 -0000 1.53 +++ b/xc/ChangeLog 30 May 2004 22:09:11 -0000 @@ -1,21 +1,35 @@ 2004-05-30 Roland Mainz + * xc/programs/xedit/Imakefile + * xc/programs/xedit/Xedit.ad + * xc/programs/xedit/commands.c + * xc/programs/xedit/hook.c + * xc/programs/xedit/ispell.c + * xc/programs/xedit/xedit.c + * xc/programs/xedit/xedit.h + * xc/programs/xmore/XMore.ad + * xc/programs/xmore/print.c + * xc/programs/xmore/print.h + * xc/programs/xmore/xmore.c + Bugzilla #695: Add print support to Xedit + +2004-05-30 Roland Mainz * xc/programs/xmore/XMore.ad * xc/programs/xmore/print.c * xc/programs/xmore/print.h * xc/programs/xmore/printdialog.c * xc/programs/xmore/printdialog.h * xc/programs/xmore/xmore.c * xc/programs/xmore/xmore.h Bugzilla #693: XMore and XawPrintDialog work-in-progress, fixing various problems and adding framework for i18n. 2004-05-29 Alan Coopersmith * programs/xkbcomp/rules/Imakefile: Bugzilla #531: missing xfree86.lst (Grzegorz DÄ…browski ) 2004-05-29 Eric Anholt * config/cf/FreeBSD.cf: * config/cf/OpenBSD.cf: * config/cf/OpenBSDLib.tmpl: * config/cf/X11.tmpl: Index: xc/programs/xedit/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/Imakefile,v retrieving revision 1.2 diff -u -2 -0 -r1.2 Imakefile --- a/xc/programs/xedit/Imakefile 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/Imakefile 30 May 2004 22:09:21 -0000 @@ -1,51 +1,57 @@ XCOMM $XConsortium: Imakefile,v 1.17 93/08/17 20:49:32 rws Exp $ XCOMM $XFree86: xc/programs/xedit/Imakefile,v 1.25 2003/03/25 04:18:26 dawes Exp $ #include "lisp/lisp.cf" #if BuildSharedLispModules CCOPTIONS = -fpic DLLIB = DlLibrary LOCAL_LDFLAGS = -Xlinker -E #endif #define IHaveSubdirs #define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" SUBDIRS = lisp LISPLIBS = -Llisp -llisp -Llisp/mp -lmp -Llisp/re -lre LISP_SRC = lisp.c LISP_OBJ = lisp.o DEPLIBS = XawClientDepLibs $(SUBDIRS) -LOCAL_LIBRARIES = $(LISPLIBS) XawClientLibs $(DLLIB) +LOCAL_LIBRARIES = $(LISPLIBS) XawClientLibs -lXprintUtil $(DLLIB) SYS_LIBRARIES = MathLibrary #if defined(LynxOSArchitecture) || defined(SVR3Architecture) || defined(LinuxArchitecture) RP_SRCS = realpath.c RP_OBJS = realpath.o RP_DEFINES = -DNEED_REALPATH #endif #if !HasStrcasecmp STRCCMP_SRCS = strcasecmp.c STRCCMP_OBJS = strcasecmp.o STRCCMP_DEFINES = -DNEED_STRCASECMP #endif SYS_SRCS = $(RP_SRCS) $(STRCCMP_SRCS) SYS_OBJS = $(RP_OBJS) $(STRCCMP_OBJS) SYS_DEFINES = $(RP_DEFINES) $(STRCCMP_DEFINES) DEFINES = $(SIGNAL_DEFINES) $(SYS_DEFINES) INCLUDES = -I. -Ilisp/re $(MISC_INCLUDES) SRCS = xedit.c commands.c util.c $(SYS_SRCS) ispell.c options.c \ - hook.c $(LISP_SRC) + hook.c printdialog.c print.c $(LISP_SRC) OBJS = xedit.o commands.o util.o $(SYS_OBJS) ispell.o options.o \ - hook.o $(LISP_OBJ) + hook.o printdialog.o print.o $(LISP_OBJ) + +LinkSourceFile(printdialog.c,../xmore) +LinkSourceFile(printdialog.h,../xmore) +LinkSourceFile(printdialogprivates.h,../xmore) +LinkSourceFile(print.c,../xmore) +LinkSourceFile(print.h,../xmore) #ifdef IHaveSubdirs ForceSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) #endif ComplexProgramTarget(xedit) InstallAppDefaults(Xedit) InstallAppDefaultsLong(Xedit-color,Xedit-color) Index: xc/programs/xedit/Xedit.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/Xedit.ad,v retrieving revision 1.2 diff -u -2 -0 -r1.2 Xedit.ad --- a/xc/programs/xedit/Xedit.ad 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/Xedit.ad 30 May 2004 22:09:21 -0000 @@ -1,27 +1,28 @@ ! $XFree86: xc/programs/xedit/Xedit.ad,v 1.23 2002/09/22 07:09:05 paulo Exp $ *geometry: 590x440 *input: TRUE *enableBackups: True *backupNameSuffix: ~ *changedBitmap: xlogo11 +*international: True *hints:\ Use Control-S and Control-R to Search.\n\ Use Control-Shift-_ to Undo. Control-G to switch between Undo and Redo.\n\ Use Control-A to jump to the beginning of the line.\n\ Use Control-E to jump to the end of the line.\n\ Use Control-T to transpose characters.\n\ Use Control-K to cut to the end of the line. Control-Y to paste.\n\ Use Control-Q to escape control characters.\n\ Use Control-U[,] to multiply actions. Control-G to cancel.\n\ Use Control-Z to scroll one line up. Meta-Z to scroll one line down.\n\ Use Meta-Q to format a paragraph.\n\ Use Right-Button to extend selections.\n\ Use Meta-I to insert a file.\n\ Use Control-W to delete a selection, and/or jump to the selection mark.\n\ Use Control-X,Control-F to find a file. Tab for filename completion.\n\ Use Control-X,Control-S to save.\n\ Use Control-X,Control-C to exit.\n\ Use Control-C to paste the selection at CUT_BUFFER0.\n\ Use Control Left-Button to popup the File Menu.\n\ @@ -46,40 +47,42 @@ *formWindow.max: 18 *formWindow.showGrip: False *positionWindow.fromHoriz: labelWindow *positionWindow.horizDistance: 0 *positionWindow.left: chainRight *positionWindow.right: chainRight *positionWindow.width: 90 *positionWindow.label: error *positionWindow.justify: left *labelWindow*justify: center *labelWindow*label: no file yet *labelWindow.left: chainLeft *labelWindow.right: chainRight *quit.label: Quit *quit.tip: Close xedit window *save.label: Save *save.tip: Save current file *load.label: Load *load.tip: Load a new file +*print.label: Print +*print.tip: Print current file *buttons*orientation: horizontal *buttons*showGrip: False *buttons.min: 18 *messageWindow.height: 50 *messageWindow.min: 18 *Paned*Text*allowResize: True *messageWindow.autoFill: False *messageWindow.scrollVertical: Never *editWindow.autoFill: False *editWindow.scrollVertical: Always *editWindow.showGrip: True xedit.textSource*enableUndo: True *bc_label*label: Use Control-S and Control-R to Search. *bc_label*showGrip: False *bc_label.min: 18 @@ -226,40 +229,41 @@ c @Num_Lock:xedit-focus() popup-menu(fileMenu)\n\ c l: xedit-focus() popup-menu(fileMenu)\n\ c: xedit-focus() popup-menu(fileMenu)\n\ c l @Num_Lock:xedit-focus() popup-menu(editMenu)\n\ c @Num_Lock:xedit-focus() popup-menu(editMenu)\n\ c l: xedit-focus() popup-menu(editMenu)\n\ c: xedit-focus() popup-menu(editMenu)\n\ c l @Num_Lock:xedit-focus() popup-menu(optionsMenu)\n\ c @Num_Lock:xedit-focus() popup-menu(optionsMenu)\n\ c l:xedit-focus() popup-menu(optionsMenu)\n\ c: xedit-focus() popup-menu(optionsMenu)\n\ : xedit-focus() select-start() *filename.?.pieceSize: 256 *filename.translations: #override \ cS: no-op(r)\n\ cR: no-op(r)\n\ mI: no-op(r)\n\ cG: cancel-find-file()\n\ Return: load-file()\n\ +P: print-file()\n\ Tab: file-completion(h)\n\ Escape: cancel-find-file()\n\ : no-op()\n\ : no-op()\n\ : set-keyboard-focus() select-start() *ispell.translations: #override \ WM_PROTOCOLS: ispell(end) ! Sample dictionary, word chars and text mode resources setup !*ispell.dictionary: br !*ispell.dictionaries: br american americanmed+ english !*ispell*br.wordChars: áéíóúçÁÉÍÓÚÇàÀâêôÂÊÔüÜãõÃÕ- !*ispell.ispellCommand: /usr/local/bin/ispell -B -m !*ispell*text.skipLines: .# *ispell.geometry: 0x0 *ispell.minWidth: 320 *ispell.minHeight: 245 *ispell*Label.borderWidth: 0 @@ -440,20 +444,55 @@ *columns*ok.fromVert: rightLabel *columns*cancel.fromHoriz: ok *columns*cancel.fromVert: rightLabel *columns*cancel.horizDistance: 12 *columns*Text.?.pieceSize: 8 *columns*Text.translations: #override \ cS: no-op(r)\n\ cR: no-op(r)\n\ mI: no-op(r)\n\ Return: set-columns(ok)\n\ Tab: change-field()\n\ cG: set-columns(cancel)\n\ Escape: set-columns(cancel)\n\ : no-op()\n\ : no-op()\n\ : set-keyboard-focus() select-start() *columns.translations: #override \ WM_PROTOCOLS: set-columns(cancel) + +! Use "white" as background for printing +*printshell*background: white + +! Print dialog +*printdialogshell*geometry: 600x120 +*printdialogshell*setup*geometry: 600x400 +*printdialogshell*printerselection*geometry: 400x150 +*printdialog*main*ok.tip: Print +*printdialog*main*cancel.tip: Cancel printing +*printdialog*main*setup.tip: Configure printer options (page size, orientation, etc.) +*printdialog*main*desclabel.tip: Short description of printer +*printdialog*main*desc.tip: Short description of printer +*printdialog*main*info.tip: Display additional information about this printer +*printdialog*main*namelabel.tip: Name of selected printer +*printdialog*main*name.tip: Name of selected printer +*printdialog*main*selectprinter.tip: Select a different printer +*printdialog*main*filenamelabel.tip: File where the output should be stored +*printdialog*main*filename.tip: File where the output should be stored +*printdialog*main*selectfile.tip: Select file where the output should be stored +*printdialog*main*printtoprinter.tip: Send print job to printer +*printdialog*main*printtofile.tip: Save print job in a file +*printdialog*setup*ok.tip: Commit changes +*printdialog*setup*cancel.tip: Cancel and reset to defaults +*printdialog*setup*paperlist.tip: Select paper size +*printdialog*setup*resolutionlist.tip: Select page resolution +*printdialog*setup*orientationlist.tip: Select page orientation +*printdialog*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialog*setup*jobcopieslabel.tip: Set number of job copies +*printdialog*setup*jobcopies.tip: Set number of job copies +*printdialog*printerselection*ok.tip: Switch printer +*printdialog*printerselection*cancel.tip: Cancel printer selection +*printdialog*printerselection*list.tip: Select printer name from list + +! EOF. Index: xc/programs/xedit/commands.c =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/commands.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 commands.c --- a/xc/programs/xedit/commands.c 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/commands.c 30 May 2004 22:09:21 -0000 @@ -12,52 +12,67 @@ * ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. * * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS, * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT * SET FORTH ABOVE. * * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Digital Equipment Corporation not be * used in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. */ /* $XFree86: xc/programs/xedit/commands.c,v 1.29tsi Exp $ */ #include #include #include "xedit.h" +#include "printdialog.h" +#include "print.h" #ifdef CRAY #include #endif #include +#include +#include #include #include #include #include #include #include #include +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Assertion(expr, msg) { if (!(expr)) { Error msg } } +#define Log(x) { if (True) printf x; } + +static Widget printdialog_shell = NULL; +static Widget printdialog = NULL; +static char printJobNameBuffer[PATH_MAX+256]; + void ResetSourceChanged(xedit_flist_item*); static void ResetDC(Widget, XtPointer, XtPointer); static void AddDoubleClickCallback(Widget, Bool); static Bool ReallyDoLoad(char*, char*); static char *makeBackupName(String, String, unsigned); extern Widget scratch, texts[3], labels[3]; static Boolean double_click = FALSE; #define DC_UNSAVED 1 #define DC_LOADED 2 #define DC_CLOBBER 3 #define DC_KILL 4 #define DC_SAVE 5 static int dc_state; /* Function Name: AddDoubleClickCallback(w) * Description: Adds a callback that will reset the double_click flag * to false when the text is changed. @@ -321,42 +336,42 @@ XmuSnprintf(buf, sizeof(buf), "Saved file: %s\n", name); if (item && item->source != scratch) { XtSetArg(args[0], XtNlabel, filename); XtSetValues(item->sme, args, 1); XtSetArg(args[0], XtNeditType, XawtextEdit); XtSetValues(item->source, args, 1); XtFree(item->name); XtFree(item->filename); item->name = XtNewString(name); item->filename = XtNewString(filename); item->flags = EXISTS_BIT; } else { item = flist.itens[0]; XtRemoveCallback(scratch, XtNcallback, SourceChanged, (XtPointer)item); item->source = scratch = - XtVaCreateWidget("textSource", international ? - multiSrcObjectClass : asciiSrcObjectClass, + XtVaCreateWidget("textSource", + multiSrcObjectClass, topwindow, XtNtype, XawAsciiFile, XtNeditType, XawtextEdit, NULL, NULL); ResetSourceChanged(item); XtAddCallback(scratch, XtNcallback, SourceChanged, (XtPointer)item); item = AddTextSource(source, name, filename, EXISTS_BIT, file_access); XtAddCallback(item->source, XtNcallback, SourceChanged, (XtPointer)item); } item->flags |= EXISTS_BIT; ResetSourceChanged(item); } else { XmuSnprintf(buf, sizeof(buf), "Error saving file: %s\n", name); Feep(); } @@ -459,64 +474,165 @@ default: XmuSnprintf(buf, sizeof(buf), "%s %s", "Internal function MaybeCreateFile()", "returned unexpected value.\n"); XeditPrintf(buf); Feep(); return (False); } XeditPrintf(buf); if (exists) { flags = EXISTS_BIT; XtSetArg(args[num_args], XtNstring, filename); num_args++; } else { flags = 0; XtSetArg(args[num_args], XtNstring, NULL); num_args++; } - source = XtVaCreateWidget("textSource", international ? - multiSrcObjectClass : asciiSrcObjectClass, + source = XtVaCreateWidget("textSource", + multiSrcObjectClass, topwindow, XtNtype, XawAsciiFile, XtNeditType, XawtextEdit, NULL, NULL); XtSetValues(source, args, num_args); item = AddTextSource(source, name, filename, flags, file_access); XtAddCallback(item->source, XtNcallback, SourceChanged, (XtPointer)item); if (exists && file_access == WRITE_OK) { struct stat st; if (stat(filename, &st) == 0) item->mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } SwitchTextSource(item); ResetSourceChanged(item); } return (True); } +static void +printshellDestroyXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + XawPrintDialogClosePrinterConnection(printdialog, False); +} + +static void +printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; + Cardinal n; + Arg args[2]; + Widget textsource; + + Log(("printOKXtProc: OK.\n")); + + /* Get TextSource object */ + n = 0; + XtSetArg(args[n], XtNtextSource, &textsource); n++; + XtGetValues(textwindow, args, n); + + Assertion(textsource != NULL, (("printOKXtProc: textsource == NULL.\n"))); + + /* ||printJobNameBuffer| must live as long the print job prints + * because it is used for the job title AND the page headers... */ + sprintf(printJobNameBuffer, "Xedit print job"); + + DoPrintTextSource("Xedit", + textsource, topwindow, + pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + printJobNameBuffer, + pdcs->printToFile?pdcs->printToFileName:NULL); + + XtPopdown(printdialog_shell); +} + +static void +printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) +{ + Log(("printCancelXtProc: cancel.\n")); + XtPopdown(printdialog_shell); + + Log(("destroying print dialog shell...\n")); + XtDestroyWidget(printdialog_shell); + printdialog_shell = NULL; + printdialog = NULL; + Log(("... done\n")); +} + + +/*ARGSUSED*/ +void +PrintFile(Widget w, XEvent *event, String *params, Cardinal *num_params) +{ + DoPrint(w, NULL, NULL); +} + +/*ARGSUSED*/ +void +DoPrint(Widget w, XtPointer client_data, XtPointer call_data) +{ + Dimension width, height; + Position x, y; + Widget parent = topwindow; + Log(("print!\n")); + + if (!printdialog) { + int n; + Arg args[20]; + + n = 0; + XtSetArg(args[n], XtNallowShellResize, True); n++; + printdialog_shell = XtCreatePopupShell("printdialogshell", + transientShellWidgetClass, + topwindow, args, n); + n = 0; + printdialog = XtCreateManagedWidget("printdialog", printDialogWidgetClass, + printdialog_shell, args, n); + XtAddCallback(printdialog, XawNOkCallback, printOKXtProc, NULL); + XtAddCallback(printdialog, XawNCancelCallback, printCancelXtProc, NULL); + + XtRealizeWidget(printdialog_shell); + } + + /* Center dialog */ + XtVaGetValues(printdialog_shell, + XtNwidth, &width, + XtNheight, &height, + NULL); + + x = (Position)(XWidthOfScreen( XtScreen(parent)) - width) / 2; + y = (Position)(XHeightOfScreen(XtScreen(parent)) - height) / 3; + + XtVaSetValues(printdialog_shell, + XtNx, x, + XtNy, y, + NULL); + + XtPopup(printdialog_shell, XtGrabNonexclusive); +} + /* Function Name: SourceChanged * Description: A callback routine called when the source has changed. * Arguments: w - the text source that has changed. * client_data - xedit_flist_item associated with text buffer. * call_data - NULL is unchanged * Returns: none. */ /*ARGSUSED*/ void SourceChanged(Widget w, XtPointer client_data, XtPointer call_data) { xedit_flist_item *item = (xedit_flist_item*)client_data; Bool changed = (Bool)(long)call_data; if (changed) { if (item->flags & CHANGED_BIT) return; item->flags |= CHANGED_BIT; } else { Index: xc/programs/xedit/hook.c =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/hook.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 hook.c --- a/xc/programs/xedit/hook.c 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/hook.c 30 May 2004 22:09:31 -0000 @@ -371,43 +371,45 @@ } } block.firstPos = 0; block.format = FMT8BIT; if (XawTextReplace(w, auto_replace.left, auto_replace.right + inc, &block) == XawEditDone) XawTextSetInsertionPoint(w, auto_replace.left + block.length); if (block.ptr != buffer) XtFree(block.ptr); } /*ARGUSED*/ void LineEditAction(Widget w, XEvent *event, String *params, Cardinal *num_params) { XawTextBlock block; - if (international) + if (True) { /* XXX FIXME */ + fprintf(stderr, "LineEditAction: Not working in international mode.\n"); return; + } block.firstPos = 0; block.format = FMT8BIT; block.ptr = einfo.command; block.length = strlen(einfo.command); XawTextReplace(filenamewindow, 0, XawTextLastPosition(filenamewindow), &block); XtSetKeyboardFocus(topwindow, filenamewindow); line_edit = True; } #define LSCAN(from, count, include) \ XawTextSourceScan(source, from, XawstEOL, XawsdLeft, count, include) #define RSCAN(from, count, include) \ XawTextSourceScan(source, from, XawstEOL, XawsdRight, count, include) void LineEdit(Widget w) { /* Global usage variables */ Index: xc/programs/xedit/ispell.c =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/ispell.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 ispell.c --- a/xc/programs/xedit/ispell.c 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/ispell.c 30 May 2004 22:09:31 -0000 @@ -921,44 +921,41 @@ /* skip non word characters */ pos = position = ispell.right; nl = False; while (1) { Bool done = False; char mb[sizeof(wchar_t)]; retry_html_space: position = XawTextSourceRead(ispell.source, position, &block, BUFSIZ); if (block.length == 0) { /* end of file */ ispell.stat = 0; ispell.lock = True; XawTextSetInsertionPoint(ispell.ascii, ispell.right); XawTextUnsetSelection(ispell.ascii); IspellSetSensitive(False); IspellSetStatus(ispell.eof_label); return (-1); } for (i = 0; i < block.length; i++) { - if (international) - wctomb(mb, ((wchar_t*)block.ptr)[i]); - else - *mb = block.ptr[i]; + wctomb(mb, ((wchar_t*)block.ptr)[i]); if (amplen) { if (amplen + 2 >= sizeof(ampbuf)) { if (!ispell.terse_mode) fprintf(stderr, "Warning: error interpreting '&' mark.\n"); amplen = 0; position = pos + 1; goto retry_html_space; } else if ((ampbuf[amplen++] = *mb) == ';') { int ch; ampbuf[amplen] = '\0'; ch = IspellConvertHtmlAmp(ampbuf); amplen = 0; if (isalpha(ch) || (ch && strchr(ispell.wchars, ch))) { /* interpret it again */ ispell.right = pos; i = 0; done = True; @@ -1022,44 +1019,41 @@ /* read a word */ position = ispell.left = ispell.right; while (1) { Bool done = False; char mb[sizeof(wchar_t)]; retry_html_word: position = XawTextSourceRead(ispell.source, position, &block, BUFSIZ); if (block.length == 0 && len == 1) { /* end of file */ ispell.stat = 0; ispell.lock = True; XawTextSetInsertionPoint(ispell.ascii, ispell.right); XawTextUnsetSelection(ispell.ascii); IspellSetSensitive(False); IspellSetStatus(ispell.eof_label); return (-1); } for (i = 0; i < block.length; i++) { - if (international) - wctomb(mb, ((wchar_t*)block.ptr)[i]); - else - *mb = block.ptr[i]; + wctomb(mb, ((wchar_t*)block.ptr)[i]); if (amplen) { if (amplen + 2 >= sizeof(ampbuf)) { if (!ispell.terse_mode) fprintf(stderr, "Warning: error interpreting '&' mark.\n"); amplen = 0; position = pos + 1; if (strchr(ispell.wchars, '&')) { if (len + 1 >= sizeof(ispell.sendbuf) - 1) { done = True; fprintf(stderr, "Warning: word is too large!\n"); break; } ispell.sendbuf[len++] = '&'; goto retry_html_word; } else { ispell.right = position; i = 0; done = True; break; @@ -1549,52 +1543,46 @@ ispell.right += replace.length - search.length; IspellCheckUndo(); ispell.undo_head->undo_str = NULL; ispell.undo_head->undo_pos = pos; ispell.undo_head->undo_count = 1; if (ispell.repeat) { ispell.undo_head->repeat = 2; /* To recognize later it was replaced */ ispell.undo_head->undo_count = ispell.right; ispell.undo_head->undo_str = XtNewString(search.ptr); } if (client_data && !ispell.repeat) { XawTextDisableRedisplay(ispell.ascii); pos = ispell.right; while ((pos = XawTextSourceSearch(ispell.source, pos, XawsdRight, &search)) != XawTextSearchError) { Bool do_replace = True; char mb[sizeof(wchar_t)]; if (XawTextSourceRead(ispell.source, pos - 1, &check, 1) > 0) { - if (international) - wctomb(mb, *(wchar_t*)check.ptr); - else - *mb = *check.ptr; + wctomb(mb, *(wchar_t*)check.ptr); do_replace = !isalpha(*mb) && *mb && !strchr(ispell.wchars, *mb); } if (do_replace && XawTextSourceRead(ispell.source, pos + search.length, &check, 1) > 0) { - if (international) - wctomb(mb, *(wchar_t*)check.ptr); - else - *mb = *check.ptr; + wctomb(mb, *(wchar_t*)check.ptr); do_replace = !isalpha(*mb) && *mb && !strchr(ispell.wchars, *mb); } if (do_replace) { XawTextReplace(ispell.ascii, pos, pos + search.length, &replace); ++ispell.undo_head->undo_count; } pos += search.length; } XawTextEnableRedisplay(ispell.ascii); } (void)IspellReplacedWord(search.ptr, replace.ptr); strncpy(&ispell.sentbuf[1], replace.ptr, sizeof(ispell.sentbuf) - 2); ispell.sentbuf[sizeof(ispell.sentbuf) - 1] = '\0'; } else Feep(); if (ispell.repeat) ispell.right = ispell.left = XawTextGetInsertionPoint(ispell.ascii); Index: xc/programs/xedit/xedit.c =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/xedit.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xedit.c --- a/xc/programs/xedit/xedit.c 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/xedit.c 30 May 2004 22:09:31 -0000 @@ -24,118 +24,123 @@ * used in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. */ /* $XFree86: xc/programs/xedit/xedit.c,v 1.17 2002/09/22 07:09:05 paulo Exp $ */ #include #include "xedit.h" #include #include #include #include #include #define randomize() srand((unsigned)time((time_t*)NULL)) static XtActionsRec actions[] = { {"quit", QuitAction}, {"save-file", SaveFile}, {"load-file", LoadFile}, +{"print-file", PrintFile}, {"find-file", FindFile}, {"cancel-find-file", CancelFindFile}, {"file-completion", FileCompletion}, {"popup-menu", PopupMenu}, {"kill-file", KillFile}, {"split-window", SplitWindow}, {"dir-window", DirWindow}, {"delete-window", DeleteWindow}, {"xedit-focus", XeditFocus}, {"other-window", OtherWindow}, {"switch-source", SwitchSource}, #ifndef __UNIXOS2__ {"lisp-eval", XeditLispEval}, {"xedit-print-lisp-eval", XeditPrintLispEval}, {"xedit-keyboard-reset",XeditKeyboardReset}, #endif {"ispell", IspellAction}, {"line-edit", LineEditAction} }; #define DEF_HINT_INTERVAL 300 /* in seconds, 5 minutes */ static Atom wm_delete_window; static Widget hintswindow; static int position_format_mask; static XawTextPositionInfo infos[3]; Widget topwindow, textwindow, messwidget, labelwindow, filenamewindow; Widget scratch, hpane, vpanes[2], labels[3], texts[3], forms[3], positions[3]; Widget options_popup, dirlabel, dirwindow; -Boolean international; Boolean line_edit; XawTextWrapMode wrapmodes[3]; extern void ResetSourceChanged(xedit_flist_item*); static void makeButtonsAndBoxes(Widget); static void HintsTimer(XtPointer, XtIntervalId*); static void PositionChanged(Widget, XtPointer, XtPointer); static void StartFormatPosition(void); static void StartHints(void); Display *CurDpy; struct _app_resources app_resources; struct _xedit_flist flist; #define Offset(field) XtOffsetOf(struct _app_resources, field) static XtResource resources[] = { {"enableBackups", "EnableBackups", XtRBoolean, sizeof(Boolean), Offset(enableBackups), XtRImmediate, FALSE}, {"backupNamePrefix", "BackupNamePrefix", XtRString, sizeof(char *), Offset(backupNamePrefix),XtRString, ""}, {"backupNameSuffix", "BackupNameSuffix", XtRString, sizeof(char *), Offset(backupNameSuffix),XtRString, ".BAK"}, {"hints", "Hint", XtRString, sizeof(char *), Offset(hints.resource), XtRImmediate, NULL}, {"hintsInterval", XtCInterval, XtRInt, sizeof(long), Offset(hints.interval), XtRImmediate, (XtPointer)DEF_HINT_INTERVAL}, {"changedBitmap", XtRBitmap, XtRString, sizeof(char*), Offset(changed_pixmap_name), XtRString, "dot"}, {"positionFormat", "Format", XtRString, sizeof(char*), Offset(position_format), XtRString, "L%l"}, {"autoReplace", "Replace", XtRString, sizeof(char*), Offset(auto_replace), XtRImmediate, NULL}, }; #undef Offset +String fallback_resources[] = { + "*international: True", /* set this globally for ALL widgets to avoid wiered crashes */ + NULL +}; + int main(int argc, char *argv[]) { XtAppContext appcon; unsigned num_loaded = 0; XtSetLanguageProc(NULL, NULL, NULL); - topwindow = XtAppInitialize(&appcon, "Xedit", NULL, 0, &argc, argv, NULL, NULL, 0); + topwindow = XtAppInitialize(&appcon, "Xedit", NULL, 0, &argc, argv, fallback_resources, NULL, 0); XtAppAddActions(appcon, actions, XtNumber(actions)); XtOverrideTranslations (topwindow, XtParseTranslationTable ("WM_PROTOCOLS: quit()")); XtGetApplicationResources(topwindow, (XtPointer) &app_resources, resources, XtNumber(resources), NULL, 0); CurDpy = XtDisplay(topwindow); XawSimpleMenuAddGlobalActions(appcon); XtRegisterGrabAction(PopupMenu, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync); makeButtonsAndBoxes(topwindow); StartHints(); StartFormatPosition(); (void)StartHooks(appcon); if (position_format_mask == 0) { @@ -223,43 +228,42 @@ XmuSnprintf(buf, sizeof(buf), "File %s opened READ ONLY.\n", argv[i]); break; case WRITE_OK: XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XmuSnprintf(buf, sizeof(buf), "File %s opened read - write.\n", argv[i]); break; } if (file_access != NO_READ) { int flags; if (exists) { flags = EXISTS_BIT; XtSetArg(args[num_args], XtNstring, filename);num_args++; } else { flags = 0; XtSetArg(args[num_args], XtNstring, NULL); num_args++; } - source = XtVaCreateWidget("textSource", international ? - multiSrcObjectClass - : asciiSrcObjectClass, topwindow, + source = XtVaCreateWidget("textSource", + multiSrcObjectClass, topwindow, XtNtype, XawAsciiFile, XtNeditType, XawtextEdit, NULL, NULL); XtSetValues(source, args, num_args); item = AddTextSource(source, argv[i], filename, flags, file_access); XtAddCallback(item->source, XtNcallback, SourceChanged, (XtPointer)item); if (exists && file_access == WRITE_OK) item->mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); if (!num_loaded) SwitchTextSource(item); ++num_loaded; ResetSourceChanged(item); } XeditPrintf(buf); } } if (!flist.pixmap && strlen(app_resources.changed_pixmap_name)) { @@ -285,40 +289,41 @@ } static void makeButtonsAndBoxes(Widget parent) { Widget outer, b_row, viewport; Arg arglist[10]; Cardinal num_args; xedit_flist_item *item; static char *labelWindow = "labelWindow", *editWindow = "editWindow"; static char *formWindow = "formWindow", *positionWindow = "positionWindow"; outer = XtCreateManagedWidget("paned", panedWidgetClass, parent, NULL, ZERO); b_row = XtCreateManagedWidget("buttons", panedWidgetClass, outer, NULL, ZERO); { MakeCommandButton(b_row, "quit", DoQuit); MakeCommandButton(b_row, "save", DoSave); MakeCommandButton(b_row, "load", DoLoad); + MakeCommandButton(b_row, "print", DoPrint); filenamewindow = MakeStringBox(b_row, "filename", NULL); } hintswindow = XtCreateManagedWidget("bc_label", labelWidgetClass, outer, NULL, ZERO); num_args = 0; XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); ++num_args; messwidget = XtCreateManagedWidget("messageWindow", asciiTextWidgetClass, outer, arglist, num_args); num_args = 0; XtSetArg(arglist[num_args], XtNorientation, XtorientHorizontal); ++num_args; hpane = XtCreateManagedWidget("hpane", panedWidgetClass, outer, arglist, num_args); num_args = 0; XtSetArg(arglist[num_args], XtNorientation, XtorientVertical); ++num_args; vpanes[0] = XtCreateManagedWidget("vpane", panedWidgetClass, hpane, arglist, num_args); XtSetArg(arglist[num_args], XtNheight, 1); ++num_args; @@ -330,49 +335,44 @@ vpanes[0], NULL, 0); labelwindow = XtCreateManagedWidget(labelWindow,labelWidgetClass, forms[0], NULL, 0); labels[0] = labelwindow; positions[0] = XtCreateManagedWidget(positionWindow,labelWidgetClass, forms[0], NULL, 0); forms[2] = XtCreateWidget(formWindow, formWidgetClass, vpanes[1], NULL, 0); labels[2] = XtCreateManagedWidget(labelWindow,labelWidgetClass, forms[2], NULL, 0); positions[2] = XtCreateManagedWidget(positionWindow,labelWidgetClass, forms[2], NULL, 0); num_args = 0; XtSetArg(arglist[num_args], XtNtype, XawAsciiFile); ++num_args; XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); ++num_args; textwindow = XtCreateManagedWidget(editWindow, asciiTextWidgetClass, vpanes[0], arglist, num_args); num_args = 0; - XtSetArg(arglist[num_args], XtNinternational, &international); ++num_args; - XtGetValues(textwindow, arglist, num_args); - - num_args = 0; XtSetArg(arglist[num_args], XtNtype, XawAsciiFile); ++num_args; XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); ++num_args; - scratch = XtVaCreateWidget("textSource", international ? - multiSrcObjectClass - : asciiSrcObjectClass, topwindow, + scratch = XtVaCreateWidget("textSource", + multiSrcObjectClass, topwindow, XtNtype, XawAsciiFile, XtNeditType, XawtextEdit, NULL, NULL); XtSetValues(scratch, arglist, num_args); num_args = 0; XtSetArg(arglist[num_args], XtNtextSource, scratch); ++num_args; XtSetValues(textwindow, arglist, num_args); texts[0] = textwindow; num_args = 0; XtSetArg(arglist[num_args], XtNtextSource, scratch); ++num_args; XtSetArg(arglist[num_args], XtNdisplayCaret, False); ++num_args; texts[2] = XtCreateWidget(editWindow, asciiTextWidgetClass, vpanes[1], arglist, num_args); forms[1] = XtCreateWidget(formWindow, formWidgetClass, vpanes[0], NULL, 0); labels[1] = XtCreateManagedWidget(labelWindow,labelWidgetClass, forms[1], NULL, 0); Index: xc/programs/xedit/xedit.h =================================================================== RCS file: /cvs/xorg/xc/programs/xedit/xedit.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xedit.h --- a/xc/programs/xedit/xedit.h 23 Apr 2004 19:54:43 -0000 1.2 +++ b/xc/programs/xedit/xedit.h 30 May 2004 22:09:31 -0000 @@ -83,75 +83,76 @@ Pixmap pixmap; xedit_flist_item **itens; xedit_flist_item *current, *other; Cardinal num_itens; } flist; extern Widget options_popup; extern struct _app_resources { Boolean enableBackups; char *backupNamePrefix; char *backupNameSuffix; xedit_hints hints; char *changed_pixmap_name; char *position_format; char *auto_replace; } app_resources; extern Widget topwindow, textwindow, labelwindow, filenamewindow, messwidget; extern Widget dirlabel, dirwindow; -extern Boolean international; extern Boolean line_edit; /* externals in xedit.c */ void Feep(void); /* externals in util.c */ void XeditPrintf(char*); Widget MakeCommandButton(Widget, char*, XtCallbackProc); Widget MakeStringBox(Widget, String, String); String GetString(Widget); FileAccess MaybeCreateFile(char*), CheckFilePermissions(char*, Boolean*); xedit_flist_item *AddTextSource(Widget, String, String, int, FileAccess); xedit_flist_item *FindTextSource(Widget, char*); Bool KillTextSource(xedit_flist_item*); char *ResolveName(char*); void DeleteWindow(Widget, XEvent*, String*, Cardinal*); void SplitWindow(Widget, XEvent*, String*, Cardinal*); void SwitchTextSource(xedit_flist_item*); void PopupMenu(Widget, XEvent*, String*, Cardinal*); void OtherWindow(Widget, XEvent*, String*, Cardinal*); void SwitchSource(Widget, XEvent*, String*, Cardinal*); void XeditFocus(Widget, XEvent*, String*, Cardinal*); void SwitchDirWindow(Bool); void DirWindow(Widget, XEvent*, String*, Cardinal*); /* externs in commands.c */ void DoQuit(Widget, XtPointer, XtPointer); void QuitAction(Widget, XEvent*, String*, Cardinal*); void DoSave(Widget, XtPointer, XtPointer); void SaveFile(Widget, XEvent*, String*, Cardinal*); void DoLoad(Widget, XtPointer, XtPointer); +void DoPrint(Widget, XtPointer, XtPointer); void CancelFindFile(Widget, XEvent*, String*, Cardinal*); void FindFile(Widget, XEvent*, String*, Cardinal*); void LoadFile(Widget, XEvent*, String*, Cardinal*); +void PrintFile(Widget, XEvent*, String*, Cardinal*); void FileCompletion(Widget, XEvent*, String*, Cardinal*); void KillFile(Widget, XEvent*, String*, Cardinal*); void DirWindowCB(Widget, XtPointer, XtPointer); void SourceChanged(Widget, XtPointer, XtPointer); /* externs in ispell.c */ void IspellAction(Widget, XEvent*, String*, Cardinal*); void IspellCallback(Widget, XtPointer, XtPointer); /* externs in options.c */ void CreateEditPopup(void); void SetEditMenu(void); void UpdateTextProperties(int); /* externs in hook.c */ Bool StartHooks(XtAppContext); void LineEditAction(Widget, XEvent*, String*, Cardinal*); void LineEdit(Widget); /* externs in lisp.c */ Index: xc/programs/xmore/XMore.ad =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/XMore.ad,v retrieving revision 1.1 diff -u -2 -0 -r1.1 XMore.ad --- a/xc/programs/xmore/XMore.ad 30 May 2004 00:52:30 -0000 1.1 +++ b/xc/programs/xmore/XMore.ad 30 May 2004 22:09:31 -0000 @@ -14,47 +14,53 @@ J: scroll-one-line-up()\n\ E: scroll-one-line-up()\n\ p: print()\n\ q: quit()\n *text.baseTranslations: #override\n\ space: next-page()\n\ F: next-page()\n\ CtrlB: previous-page()\n\ K: scroll-one-line-down()\n\ Y: scroll-one-line-down()\n\ Return: scroll-one-line-up()\n\ J: scroll-one-line-up()\n\ E: scroll-one-line-up()\n\ p: print()\n\ q: quit()\n ! tip messages *quit.tip: Quit application *print.tip: Print file -! tip messages for print dialog -*printdialog*main*ok.tip: Print -*printdialog*main*cancel.tip: Cancel printing -*printdialog*main*setup.tip: Configure printer options (page size, orientation, etc.) -*printdialog*main*desclabel.tip: Short description of printer -*printdialog*main*desc.tip: Short description of printer -*printdialog*main*info.tip: Display additional information about this printer -*printdialog*main*namelabel.tip: Name of selected printer -*printdialog*main*name.tip: Name of selected printer -*printdialog*main*selectprinter.tip: Select a different printer -*printdialog*main*filenamelabel.tip: File where the output should be stored -*printdialog*main*filename.tip: File where the output should be stored -*printdialog*main*selectfile.tip: Select file where the output should be stored -*printdialog*main*printtoprinter.tip: Send print job to printer -*printdialog*main*printtofile.tip: Save print job in a file -*printdialog*setup*ok.tip: Commit changes -*printdialog*setup*cancel.tip: Cancel and reset to defaults -*printdialog*setup*paperlist.tip: Select paper size -*printdialog*setup*resolutionlist.tip: Select page resolution -*printdialog*setup*orientationlist.tip: Select page orientation -*printdialog*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) -*printdialog*setup*jobcopieslabel.tip: Set number of job copies -*printdialog*setup*jobcopies.tip: Set number of job copies -*printdialog*printerselection*ok.tip: Switch printer -*printdialog*printerselection*cancel.tip: Cancel printer selection -*printdialog*printerselection*list.tip: Select printer name from list +! Use "white" as background for printing +*printshell*background: white + +! Print dialog +*printdialogshell*geometry: 600x120 +*printdialogshell*setup*geometry: 600x400 +*printdialogshell*printerselection*geometry: 400x150 +*printdialog*main*ok.tip: Print +*printdialog*main*cancel.tip: Cancel printing +*printdialog*main*setup.tip: Configure printer options (page size, orientation, etc.) +*printdialog*main*desclabel.tip: Short description of printer +*printdialog*main*desc.tip: Short description of printer +*printdialog*main*info.tip: Display additional information about this printer +*printdialog*main*namelabel.tip: Name of selected printer +*printdialog*main*name.tip: Name of selected printer +*printdialog*main*selectprinter.tip: Select a different printer +*printdialog*main*filenamelabel.tip: File where the output should be stored +*printdialog*main*filename.tip: File where the output should be stored +*printdialog*main*selectfile.tip: Select file where the output should be stored +*printdialog*main*printtoprinter.tip: Send print job to printer +*printdialog*main*printtofile.tip: Save print job in a file +*printdialog*setup*ok.tip: Commit changes +*printdialog*setup*cancel.tip: Cancel and reset to defaults +*printdialog*setup*paperlist.tip: Select paper size +*printdialog*setup*resolutionlist.tip: Select page resolution +*printdialog*setup*orientationlist.tip: Select page orientation +*printdialog*setup*plexlist.tip: Select page plex mode (simplex, duplex, etc.) +*printdialog*setup*jobcopieslabel.tip: Set number of job copies +*printdialog*setup*jobcopies.tip: Set number of job copies +*printdialog*printerselection*ok.tip: Switch printer +*printdialog*printerselection*cancel.tip: Cancel printer selection +*printdialog*printerselection*list.tip: Select printer name from list ! EOF. Index: xc/programs/xmore/print.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/print.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 print.c --- a/xc/programs/xmore/print.c 30 May 2004 00:52:30 -0000 1.2 +++ b/xc/programs/xmore/print.c 30 May 2004 22:09:31 -0000 @@ -248,133 +248,136 @@ long font_size; /* Scale font size with DPI */ font_size = (40L * dpi) / 300L; sprintf(fontname, "-adobe-courier-medium-r-normal--%ld-*-%ld-%ld-*-*," "-*-*-*-*-*-*-%ld-*-%ld-%ld-*-*", font_size, dpi, dpi, font_size, dpi, dpi); fontset = XCreateFontSet(pdpy, fontname, &missing_charset_list_return, &missing_charset_count_return, &def_string_return); for( i=0 ; i < missing_charset_count_return ; i++ ) { fprintf(stderr, "%s: warning: font for charset %s is lacking.\n", appname, missing_charset_list_return[i]); } if (!fontset) - Error(("XCreateFontSet() failure.\n")); + Error(("GetPrintTextFontSet: XCreateFontSet() failure.\n")); return fontset; } -void DoPrint(const char *programname, - Widget textsource, Widget toplevel, - Display *pdpy, XPContext pcontext, - XtCallbackProc pdpyDestroyCB, - const char *jobtitle, const char *toFile) +void DoPrintTextSource(const char *programname, + Widget textsource, Widget toplevel, + Display *pdpy, XPContext pcontext, + XtCallbackProc pdpyDestroyCB, + const char *jobtitle, const char *toFile) { long dpi = 0; int n; Arg args[20]; XFontSet textfontset = NULL; XFontSetExtents *font_extents; apd->programname = programname; apd->pdpyDestroyCallback = pdpyDestroyCB; if (apd->isPrinting) { fprintf(stderr, "%s: Already busy with printing.\n", apd->programname); return; } /* Configure the print context (paper size, title etc.) * We must do this before creating any Xt widgets - otherwise they will * make wrong assuptions about fonts, resultions etc. ... */ XpuSetJobTitle(pdpy, pcontext, jobtitle); /* Configuration done, set the context */ XpSetContext(pdpy, pcontext); /* Get default printer resolution */ if (XpuGetResolution(pdpy, pcontext, &dpi) != 1) { fprintf(stderr, "%s: No default resolution for printer.\n", apd->programname); XpuClosePrinterDisplay(pdpy, pcontext); return; } apd->toplevel = toplevel; apd->pdpy = pdpy; apd->pcontext = pcontext; apd->pscreen = XpGetScreenOfContext(pdpy, pcontext); apd->jobtitle = jobtitle; n = 0; XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; - apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "print", args, n); + apd->printshell = CreatePrintShell(toplevel, apd->pscreen, "printshell", args, n); n = 0; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; apd->content.form = XtCreateManagedWidget("form", formWidgetClass, apd->printshell, args, n); textfontset = GetPrintTextFontSet(apd->programname, pdpy, dpi); #ifdef PRINT_PAGEHEADER n = 0; + XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNfromHoriz, NULL); n++; XtSetArg(args[n], XtNfromVert, NULL); n++; XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNresizable, True); n++; XtSetArg(args[n], XtNfontSet, textfontset); n++; XtSetArg(args[n], XtNlabel, "Page: n/n"); n++; XtSetArg(args[n], XtNjustify, XtJustifyRight); n++; apd->content.pageheaderlabel = XtCreateManagedWidget("pageinfo", labelWidgetClass, apd->content.form, args, n); #endif /* PRINT_PAGEHEADER */ + font_extents = XExtentsOfFontSet(textfontset); + n = 0; + XtSetArg(args[n], XtNinternational, True); n++; XtSetArg(args[n], XtNtextSource, textsource); n++; XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollNever); n++; XtSetArg(args[n], XtNscrollVertical, XawtextScrollNever); n++; - font_extents = XExtentsOfFontSet(textfontset); - /* Usually I would expect that using |XtNfromVert, apd->content.pageheaderlabel| * would be the correct way to place the text widget with the main content below * the page header widget - but for an unknown reason this doesn not work: The * text widget squishes itself into the bottom half of the page and only occupies * 1/2 of the page's with... ;-(( */ #define WORKAROUND_FOR_SOMETHING_IS_WRONG 1 #ifdef WORKAROUND_FOR_SOMETHING_IS_WRONG XtSetArg(args[n], XtNtop, XtChainTop); n++; XtSetArg(args[n], XtNright, XtChainRight); n++; XtSetArg(args[n], XtNvertDistance, (font_extents->max_logical_extent.height+2)*2); n++; #else XtSetArg(args[n], XtNfromHoriz, NULL); n++; XtSetArg(args[n], XtNfromVert, apd->content.pageheaderlabel); n++; #endif XtSetArg(args[n], XtNfontSet, textfontset); n++; apd->content.text = XtCreateManagedWidget("text", asciiTextWidgetClass, apd->content.form, args, n); + /* Disable the caret - that is not needed for printing */ XawTextDisplayCaret(apd->content.text, False); XtAddCallback(apd->printshell, XawNpageSetupCallback, PageSetupCB, (XtPointer)apd); XtAddCallback(apd->printshell, XawNendJobCallback, PrintEndJobCB, (XtPointer)apd); /* Realise print shell (which will set position+size of the child * widgets based on the current page size) */ XtRealizeWidget(apd->printshell); /* Count number of pages in the text widget */ apd->numpages = CountPages(apd->content.text); /* Make sure that the Xt machinery is really using the right screen (assertion) */ if (XpGetScreenOfContext(XtDisplay(apd->printshell), apd->pcontext) != XtScreen(apd->printshell)) Error(("Widget's screen != print screen. BAD.\n")); apd->isPrinting = True; if (toFile) { Index: xc/programs/xmore/print.h =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/print.h,v retrieving revision 1.2 diff -u -2 -0 -r1.2 print.h --- a/xc/programs/xmore/print.h 30 May 2004 00:52:30 -0000 1.2 +++ b/xc/programs/xmore/print.h 30 May 2004 22:09:31 -0000 @@ -19,29 +19,29 @@ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ #ifndef XMORE_PRINT_H #define XMORE_PRINT_H 1 #include #include #include #include #include #include /* Prototypes */ -void DoPrint(const char *programname, - Widget textsource, - Widget toplevel, - Display *pdpy, XPContext pcontext, - XtCallbackProc printDisplayDestroyCallback, - const char *jobTitle, - const char *toFile); +void DoPrintTextSource(const char *programname, + Widget textsource, + Widget toplevel, + Display *pdpy, XPContext pcontext, + XtCallbackProc printDisplayDestroyCallback, + const char *jobTitle, + const char *toFile); #endif /* !XMORE_PRINT_H */ Index: xc/programs/xmore/xmore.c =================================================================== RCS file: /cvs/xorg/xc/programs/xmore/xmore.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 xmore.c --- a/xc/programs/xmore/xmore.c 30 May 2004 00:52:30 -0000 1.2 +++ b/xc/programs/xmore/xmore.c 30 May 2004 22:09:31 -0000 @@ -147,45 +147,45 @@ printOKXtProc(Widget w, XtPointer client_data, XtPointer callData) { XawPrintDialogCallbackStruct *pdcs = (XawPrintDialogCallbackStruct *)callData; Cardinal n; Arg args[2]; Widget textsource; Log(("printOKXtProc: OK.\n")); /* Get TextSource object */ n = 0; XtSetArg(args[n], XtNtextSource, &textsource); n++; XtGetValues(text, args, n); Assertion(textsource != NULL, (("printOKXtProc: textsource == NULL.\n"))); /* ||printJobNameBuffer| must live as long the print job prints * because it is used for the job title AND the page headers... */ sprintf(printJobNameBuffer, "XMore print job %s", viewFileName); - DoPrint(ProgramName, - textsource, toplevel, - pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, - printJobNameBuffer, - pdcs->printToFile?pdcs->printToFileName:NULL); + DoPrintTextSource(ProgramName, + textsource, toplevel, + pdcs->pdpy, pdcs->pcontext, printshellDestroyXtProc, + printJobNameBuffer, + pdcs->printToFile?pdcs->printToFileName:NULL); XtPopdown(printdialog_shell); } static void printCancelXtProc(Widget w, XtPointer client_data, XtPointer callData) { Log(("printCancelXtProc: cancel.\n")); XtPopdown(printdialog_shell); Log(("destroying print dialog shell...\n")); XtDestroyWidget(printdialog_shell); printdialog_shell = NULL; printdialog = NULL; Log(("... done\n")); } static void printXtProc(Widget w, XtPointer client_data, XtPointer callData) { @@ -230,40 +230,41 @@ XtVaSetValues(printdialog_shell, XtNx, x, XtNy, y, NULL); XtPopup(printdialog_shell, XtGrabNonexclusive); } int main( int argc, char *argv[] ) { XtAppContext app; Widget form; Widget printbutton; Widget quitbutton; int n; Arg args[8]; ProgramName = argv[0]; + XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtOpenApplication(&app, "XMore", options, XtNumber(options), &argc, argv, fallback_resources, sessionShellWidgetClass, NULL, ZERO); if (argc != 2) { printf("usage: %s [ x options ] filename\n", argv[0]); exit(EXIT_FAILURE); } XtGetApplicationResources(toplevel, (XtPointer)&userOptions, resources, XtNumber(resources), NULL, 0); XtAppAddActions(app, actions, XtNumber(actions)); viewFileName = argv[1]; form = XtCreateManagedWidget("form", formWidgetClass, toplevel, NULL, 0);