2 * New (WinBoard-style) Move history for XBoard
4 * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
5 * ------------------------------------------------------------------------
7 * GNU XBoard is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
12 * GNU XBoard is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/.
20 * ------------------------------------------------------------------------
21 ** See the file ChangeLog for a revision history. */
28 #include <X11/Intrinsic.h>
29 #include <X11/StringDefs.h>
30 #include <X11/Shell.h>
31 #include <X11/Xaw/Dialog.h>
32 #include <X11/Xaw/Form.h>
33 #include <X11/Xaw/List.h>
34 #include <X11/Xaw/Label.h>
35 #include <X11/Xaw/SimpleMenu.h>
36 #include <X11/Xaw/SmeBSB.h>
37 #include <X11/Xaw/SmeLine.h>
38 #include <X11/Xaw/Box.h>
39 #include <X11/Xaw/Paned.h>
40 #include <X11/Xaw/MenuButton.h>
41 #include <X11/cursorfont.h>
42 #include <X11/Xaw/Text.h>
43 #include <X11/Xaw/AsciiText.h>
44 #include <X11/Xaw/Viewport.h>
45 #include <X11/Xatom.h>
46 #include <X11/Xmu/Atoms.h>
57 # define _(s) gettext (s)
58 # define N_(s) gettext_noop (s)
64 // templates for calls into back-end (= history.c; should be moved to history.h header shared with it!)
65 void RefreshMemoContent P((void));
66 void MemoContentUpdated P((void));
67 void FindMoveByCharIndex P(( int char_index ));
69 // variables in xoptions.c
70 extern Option historyOptions[];
72 // ------------- low-level front-end actions called by MoveHistory back-end -----------------
74 // the bold argument says 0 = normal, 1 = bold typeface
75 // the colorNr argument says 0 = font-default, 1 = gray
77 ScrollToCursor (Option *opt, int caretPos)
82 GetWidgetText(opt, &s);
84 if(caretPos < 0 || caretPos > len) caretPos = len;
85 if(caretPos > len-30) { // scroll to end, which causes no flicker
87 XtCallActionProc(opt->handle, "end-of-file", &event, NULL, 0);
90 // the following leads to a very annoying flicker, even when no scrolling is done at all.
91 XtSetArg(args[0], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw
92 XtSetArg(args[1], XtNdisplayCaret, False);
93 XtSetValues(opt->handle, args, 2);
97 // ------------------------------ callbacks --------------------------
100 char historyTranslations[] =
101 "<Btn3Down>: select-start() \n \
102 <Btn3Up>: extend-end(PRIMARY) SelectMove() \n";
105 SelectMoveX (Widget w, XEvent * event, String * params, Cardinal * nParams)
107 XawTextPosition index, dummy;
109 XawTextGetSelectionPos(w, &index, &dummy);
110 FindMoveByCharIndex( index ); // [HGM] also does the actual moving to it, now