patch 8.2.4677: the Athena GUI support is outdated
Problem: The Athena GUI support is outdated.
Solution: Remove the Athena GUI code.
diff --git a/src/Makefile b/src/Makefile
index 1b143b9..3a713d7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -182,10 +182,7 @@
#Irix 6.5 cc ? 6.0 (S) David Harrison
#Irix 64 bit 4.5 (K) Jon Wright
#Linux 2.0 gcc-2.7.2 Infomagic Motif 4.3 (3) Ronald Rietman
-#Linux 2.0.31 gcc +X11 +GUI Athena 5.0w (U) Darren Hiebert
-#LynxOS 3.0.1 2.9-gnupro-98r2 +X11 +GUI Athena 5.7.1(O) Lorenz Hahn
-#LynxOS 3.1.0 2.9-gnupro-98r2 +X11 +GUI Athena 5.7.1(O) Lorenz Hahn
-#NEC UP4800 UNIX_SV 4.2MP cc +X11R6 Motif,Athena4.6b (Q) Lennart Schultz
+#NEC UP4800 UNIX_SV 4.2MP cc +X11R6 Motif 4.6b (Q) Lennart Schultz
#NetBSD 1.0A gcc-2.4.5 -X11 -GUI 3.21 (X) Juergen Weigert
#QNX 4.2 wcc386-10.6 -X11 4.2 (D) G.F. Desrochers
#QNX 4.23 Watcom -X11 4.2 (F) John Oleynick
@@ -199,14 +196,12 @@
#Solaris 2.4 (Sparc) cc +X11 +GUI 3.29 (9) Glauber
#Solaris 2.4/2.5 clcc +X11 -GUI openwin 3.20 (7) Robert Colon
#Solaris 2.5 (sun4m) cc (SC4.0) +X11R6 +GUI (CDE) 4.6b (E) Andrew Large
-#Solaris 2.5 cc +X11 +GUI Athena 4.2 (9) Sonia Heimann
#Solaris 2.5 gcc 2.5.6 +X11 Motif 5.0m (R) Ant. Colombo
#Solaris 2.6 gcc 2.8.1 ncurses 5.3 (G) Larry W. Virden
#Solaris with -lthread 5.5 (W) K. Nagano
#Solaris gcc (b) Riccardo
#SunOS 4.1.x +X11 -GUI 5.1b (J) Bram Moolenaar
-#SunOS 4.1.3_U1 (sun4c) gcc +X11 +GUI Athena 5.0w (J) Darren Hiebert
-#SUPER-UX 6.2 (NEC SX-4) cc +X11R6 Motif,Athena4.6b (P) Lennart Schultz
+#SUPER-UX 6.2 (NEC SX-4) cc +X11R6 Motif 4.6b (P) Lennart Schultz
#Tandem/NSK (c) Matthew Woehlke
#Unisys 6035 cc +X11 Motif 5.3 (8) Glauber Ribeiro
#ESIX V4.2 cc +X11 6.0 (a) Reinhard Wobst
@@ -1342,8 +1337,8 @@
HAIKUGUI_BUNDLE =
# All GUI files
-ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_xmdlg.c gui_xmebw.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c gui_haiku.cc
-ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_xmdlg.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w32.pro gui_photon.pro gui_haiku.pro
+ALL_GUI_SRC = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_xmdlg.c gui_xmebw.c gui_gtk_x11.c gui_x11.c gui_haiku.cc
+ALL_GUI_PRO = gui.pro gui_gtk.pro gui_motif.pro gui_xmdlg.pro gui_gtk_x11.pro gui_x11.pro gui_w32.pro gui_photon.pro gui_haiku.pro
# }}}
@@ -3245,15 +3240,6 @@
objects/gui.o: gui.c
$(CCC) -o $@ gui.c
-objects/gui_at_fs.o: gui_at_fs.c
- $(CCC) -o $@ gui_at_fs.c
-
-objects/gui_at_sb.o: gui_at_sb.c
- $(CCC) -o $@ gui_at_sb.c
-
-objects/gui_athena.o: gui_athena.c
- $(CCC) -o $@ gui_athena.c
-
objects/beval.o: beval.c
$(CCC) -o $@ beval.c
@@ -4182,25 +4168,6 @@
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h errors.h gui_xmebwp.h gui_xmebw.h
-objects/gui_athena.o: gui_athena.c vim.h protodef.h auto/config.h feature.h \
- os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
- proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
- proto.h globals.h errors.h gui_at_sb.h gui_x11_pm.h \
- ../pixmaps/tb_new.xpm ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm \
- ../pixmaps/tb_save.xpm ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm \
- ../pixmaps/tb_copy.xpm ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \
- ../pixmaps/tb_find_next.xpm ../pixmaps/tb_find_prev.xpm \
- ../pixmaps/tb_find_help.xpm ../pixmaps/tb_exit.xpm \
- ../pixmaps/tb_undo.xpm ../pixmaps/tb_redo.xpm ../pixmaps/tb_help.xpm \
- ../pixmaps/tb_macro.xpm ../pixmaps/tb_make.xpm \
- ../pixmaps/tb_save_all.xpm ../pixmaps/tb_jump.xpm \
- ../pixmaps/tb_ctags.xpm ../pixmaps/tb_load_session.xpm \
- ../pixmaps/tb_save_session.xpm ../pixmaps/tb_new_session.xpm \
- ../pixmaps/tb_blank.xpm ../pixmaps/tb_maximize.xpm \
- ../pixmaps/tb_split.xpm ../pixmaps/tb_minimize.xpm \
- ../pixmaps/tb_shell.xpm ../pixmaps/tb_replace.xpm \
- ../pixmaps/tb_vsplit.xpm ../pixmaps/tb_maxwidth.xpm \
- ../pixmaps/tb_minwidth.xpm
objects/gui_gtk_x11.o: gui_gtk_x11.c vim.h protodef.h auto/config.h feature.h \
os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
@@ -4211,14 +4178,6 @@
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h errors.h ../runtime/vim32x32.xpm \
../runtime/vim16x16.xpm ../runtime/vim48x48.xpm
-objects/gui_at_sb.o: gui_at_sb.c vim.h protodef.h auto/config.h feature.h \
- os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
- proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
- proto.h globals.h errors.h gui_at_sb.h
-objects/gui_at_fs.o: gui_at_fs.c vim.h protodef.h auto/config.h feature.h \
- os_unix.h auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
- proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
- proto.h globals.h errors.h gui_at_sb.h
objects/gui_haiku.o: gui_haiku.cc vim.h protodef.h auto/config.h feature.h \
os_unix.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
diff --git a/src/clipboard.c b/src/clipboard.c
index 9eace3d..fbeee72 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -1354,7 +1354,7 @@
/*
* Open the application context (if it hasn't been opened yet).
- * Used for Motif and Athena GUI and the xterm clipboard.
+ * Used for Motif GUI and the xterm clipboard.
*/
void
open_app_context(void)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 768b27f..5a0428e 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5619,20 +5619,8 @@
0
#endif
},
- {"gui_neXtaw",
-#if defined(FEAT_GUI_ATHENA) && defined(FEAT_GUI_NEXTAW)
- 1
-#else
- 0
-#endif
- },
- {"gui_athena",
-#if defined(FEAT_GUI_ATHENA) && !defined(FEAT_GUI_NEXTAW)
- 1
-#else
- 0
-#endif
- },
+ {"gui_neXtaw", 0 },
+ {"gui_athena", 0 },
{"gui_gtk",
#ifdef FEAT_GUI_GTK
1
diff --git a/src/feature.h b/src/feature.h
index 0f5bf1e..1a24879 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -583,8 +583,7 @@
#if defined(FEAT_NORMAL) && defined(FEAT_MENU) \
&& (defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_MSWIN) \
- || ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \
- && defined(HAVE_XPM)) \
+ || (defined(FEAT_GUI_MOTIF) && defined(HAVE_XPM)) \
|| defined(FEAT_GUI_PHOTON) \
|| defined(FEAT_GUI_HAIKU))
@@ -620,7 +619,7 @@
*/
#if defined(FEAT_NORMAL)
# define FEAT_BROWSE_CMD
-# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
+# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_GTK) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_PHOTON)
# define FEAT_BROWSE
# endif
@@ -641,8 +640,7 @@
* When none of these defined there is no dialog support.
*/
#ifdef FEAT_NORMAL
-# if ((defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF)) \
- && defined(HAVE_X11_XPM_H)) \
+# if (defined(FEAT_GUI_MOTIF) && defined(HAVE_X11_XPM_H)) \
|| defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_PHOTON) \
|| defined(FEAT_GUI_HAIKU) \
@@ -654,13 +652,13 @@
# endif
#endif
#if !defined(FEAT_GUI_DIALOG) && (defined(FEAT_GUI_MOTIF) \
- || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \
+ || defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_MSWIN))
// need a dialog to show error messages when starting from the desktop
# define FEAT_GUI_DIALOG
#endif
#if defined(FEAT_GUI_DIALOG) && \
- (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
+ (defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_PHOTON) \
|| defined(FEAT_GUI_HAIKU))
@@ -881,7 +879,7 @@
* +X11 Unix only. Include code for xterm title saving and X
* clipboard. Only works if HAVE_X11 is also defined.
*/
-#if (defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA))
+#if defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF)
# define WANT_X11
#endif
@@ -1047,7 +1045,7 @@
# define MCH_CURSOR_SHAPE
# endif
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) \
- || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \
+ || defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_PHOTON)
# define FEAT_MOUSESHAPE
# endif
@@ -1064,7 +1062,7 @@
#endif
#if defined(FEAT_MZSCHEME) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
- || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA))
+ || defined(FEAT_GUI_MOTIF))
# define MZSCHEME_GUI_THREADS
#endif
@@ -1090,7 +1088,6 @@
* +tcl TCL interface: "--enable-tclinterp"
* +netbeans_intg Netbeans integration
* +channel Inter process communication
- * +GUI_Athena Athena GUI
* +GUI_Motif Motif GUI
*/
@@ -1154,8 +1151,7 @@
*/
#if defined(FEAT_BIG) || defined(FEAT_NETBEANS_INTG) || defined(FEAT_PROP_POPUP)
# define FEAT_SIGNS
-# if ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \
- && defined(HAVE_X11_XPM_H)) \
+# if (defined(FEAT_GUI_MOTIF) && defined(HAVE_X11_XPM_H)) \
|| defined(FEAT_GUI_GTK) \
|| (defined(MSWIN) && defined(FEAT_GUI))
# define FEAT_SIGN_ICONS
@@ -1167,7 +1163,7 @@
* debugger and for tooltips.
* Only for GUIs where it was implemented.
*/
-#if (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
+#if (defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN)) \
&& ( ((defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)) \
&& !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MSWIN)) \
@@ -1179,7 +1175,7 @@
# endif
#endif
-#if defined(FEAT_BEVAL_GUI) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA))
+#if defined(FEAT_BEVAL_GUI) && defined(FEAT_GUI_MOTIF)
# define FEAT_BEVAL_TIP // balloon eval used for toolbar tooltip
#endif
@@ -1196,8 +1192,8 @@
# define FEAT_BEVAL
#endif
-// both Motif and Athena are X11 and share some code
-#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+// Motif is X11
+#if defined(FEAT_GUI_MOTIF)
# define FEAT_GUI_X11
#endif
diff --git a/src/gui.c b/src/gui.c
index 3b8c0d0..68ac9d8 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -53,15 +53,6 @@
static int disable_flush = 0; // If > 0, gui_mch_flush() is disabled.
/*
- * The Athena scrollbars can move the thumb to after the end of the scrollbar,
- * this makes the thumb indicate the part of the text that is shown. Motif
- * can't do this.
- */
-#if defined(FEAT_GUI_ATHENA)
-# define SCROLL_PAST_END
-#endif
-
-/*
* gui_start -- Called when user wants to start the GUI.
*
* Careful: This function can be called recursively when there is a ":gui"
@@ -445,8 +436,7 @@
gui.menu_width = 0;
# endif
#endif
-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
- || defined(FEAT_GUI_HAIKU))
+#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU))
gui.toolbar_height = 0;
#endif
#if defined(FEAT_FOOTER) && defined(FEAT_GUI_MOTIF)
@@ -789,7 +779,7 @@
balloonEval = gui_mch_create_beval_area(gui.drawarea, NULL,
&general_beval_cb, NULL);
# else
-# if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+# if defined(FEAT_GUI_MOTIF)
{
extern Widget textArea;
balloonEval = gui_mch_create_beval_area(textArea, NULL,
@@ -1441,11 +1431,11 @@
text_area_y += gui.tabline_height;
#endif
-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
+#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_MSWIN))
if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
{
-# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_HAIKU)
+# if defined(FEAT_GUI_HAIKU)
gui_mch_set_toolbar_pos(0, text_area_y,
gui.menu_width, gui.toolbar_height);
# endif
@@ -2043,10 +2033,10 @@
old_curwin = curwin;
/*
- * We need to make sure this is cleared since Athena doesn't tell us when
- * he is done dragging. Do the same for GTK.
+ * We need to make sure this is cleared since GTK doesn't tell us when
+ * the user is done dragging.
*/
-#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_GTK)
gui.dragged_sb = SBAR_NONE;
#endif
@@ -3410,10 +3400,10 @@
prev_col = col;
/*
- * We need to make sure this is cleared since Athena doesn't tell us when
- * he is done dragging. Neither does GTK+ 2 -- at least for now.
+ * We need to make sure this is cleared since GTK doesn't tell us when
+ * the user is done dragging.
*/
-#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_GTK)
gui.dragged_sb = SBAR_NONE;
#endif
}
@@ -3952,9 +3942,6 @@
sb->wp = wp;
sb->type = type;
sb->value = 0;
-#ifdef FEAT_GUI_ATHENA
- sb->pixval = 0;
-#endif
sb->size = 1;
sb->max = 1;
sb->top = 0;
@@ -4336,7 +4323,7 @@
y += gui.menu_height;
#endif
-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_ATHENA) \
+#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_HAIKU))
if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
y += gui.toolbar_height;
@@ -4369,25 +4356,10 @@
}
}
- // Reduce the number of calls to gui_mch_set_scrollbar_thumb() by
- // checking if the thumb moved at least a pixel. Only do this for
- // Athena, most other GUIs require the update anyway to make the
- // arrows work.
-#ifdef FEAT_GUI_ATHENA
- if (max == 0)
- y = 0;
- else
- y = (val * (sb->height + 2) * gui.char_height + max / 2) / max;
- if (force || sb->pixval != y || sb->size != size || sb->max != max)
-#else
if (force || sb->value != val || sb->size != size || sb->max != max)
-#endif
{
// Thumb of scrollbar has moved
sb->value = val;
-#ifdef FEAT_GUI_ATHENA
- sb->pixval = y;
-#endif
sb->size = size;
sb->max = max;
if (gui.which_scrollbars[SBAR_LEFT]
@@ -5122,7 +5094,7 @@
|| defined(FEAT_GUI_HAIKU)) \
&& defined(FEAT_TOOLBAR)) || defined(PROTO)
/*
- * This is shared between Athena, Haiku, Motif, and GTK.
+ * This is shared between Haiku, Motif, and GTK.
*/
/*
diff --git a/src/gui.h b/src/gui.h
index 0d503ae..0036093 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -11,11 +11,6 @@
# include <Xm/Xm.h>
#endif
-#ifdef FEAT_GUI_ATHENA
-# include <X11/Intrinsic.h>
-# include <X11/StringDefs.h>
-#endif
-
#ifdef FEAT_GUI_GTK
# ifdef VMS // undef MIN and MAX because Intrinsic.h redefines them anyway
# ifdef MAX
@@ -36,7 +31,7 @@
// Needed when generating prototypes, since FEAT_GUI is always defined then.
#if defined(FEAT_XCLIPBOARD) && !defined(FEAT_GUI_MOTIF) \
- && !defined(FEAT_GUI_ATHENA) && !defined(FEAT_GUI_GTK)
+ && !defined(FEAT_GUI_GTK)
# include <X11/Intrinsic.h>
#endif
@@ -160,9 +155,6 @@
win_T *wp; // Scrollbar's window, NULL for bottom
int type; // one of SBAR_{LEFT,RIGHT,BOTTOM}
long value; // Represents top line number visible
-#ifdef FEAT_GUI_ATHENA
- int pixval; // pixel count of value
-#endif
long size; // Size of scrollbar thumb
long max; // Number of lines in buffer
@@ -277,9 +269,6 @@
int menu_width; // Width of the menu bar
# endif
char menu_is_active; // TRUE if menu is present
-# ifdef FEAT_GUI_ATHENA
- char menu_height_fixed; // TRUE if menu height fixed
-# endif
#endif
scrollbar_T bottom_sbar; // Bottom scrollbar
@@ -418,7 +407,7 @@
#endif
#if defined(FEAT_TOOLBAR) \
- && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_MSWIN))
+ && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_MSWIN))
int toolbar_height; // height of the toolbar
#endif
diff --git a/src/gui_at_fs.c b/src/gui_at_fs.c
deleted file mode 100644
index 739d309..0000000
--- a/src/gui_at_fs.c
+++ /dev/null
@@ -1,2753 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4 noet: */
-
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * 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 Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- * Software Research Associates, Inc., Tokyo, Japan
- * erik@sra.co.jp
- */
-/*
- * Author's addresses:
- * erik@sra.co.jp
- * erik%sra.co.jp@uunet.uu.net
- * erik%sra.co.jp@mcvax.uucp
- * try junet instead of co.jp
- * Erik M. van der Poel
- * Software Research Associates, Inc.
- * 1-1-1 Hirakawa-cho, Chiyoda-ku
- * Tokyo 102 Japan. TEL +81-3-234-2692
- */
-
-/*
- * Heavely modified for Vim by Bram Moolenaar
- */
-
-#include "vim.h"
-
-// Only include this when using the file browser
-
-#ifdef FEAT_BROWSE
-
-// Weird complication: for "make lint" Text.h doesn't combine with Xm.h
-#if defined(FEAT_GUI_MOTIF) && defined(FMT8BIT)
-# undef FMT8BIT
-#endif
-
-#ifndef FEAT_GUI_NEXTAW
-# include "gui_at_sb.h"
-#endif
-
-////////////////// SFinternal.h
-
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Xos.h>
-#ifdef FEAT_GUI_NEXTAW
-# include <X11/neXtaw/Text.h>
-# include <X11/neXtaw/AsciiText.h>
-# include <X11/neXtaw/Scrollbar.h>
-#else
-# include <X11/Xaw/Text.h>
-# include <X11/Xaw/AsciiText.h>
-#endif
-
-#define SEL_FILE_CANCEL -1
-#define SEL_FILE_OK 0
-#define SEL_FILE_NULL 1
-#define SEL_FILE_TEXT 2
-
-#define SF_DO_SCROLL 1
-#define SF_DO_NOT_SCROLL 0
-
-typedef struct
-{
- int statDone;
- char *real;
- char *shown;
-} SFEntry;
-
-typedef struct
-{
- char *dir;
- char *path;
- SFEntry *entries;
- int nEntries;
- int vOrigin;
- int nChars;
- int hOrigin;
- int changed;
- int beginSelection;
- int endSelection;
- time_t mtime;
-} SFDir;
-
-static char SFstartDir[MAXPATHL],
- SFcurrentPath[MAXPATHL],
- SFcurrentDir[MAXPATHL];
-
-static Widget selFile,
- selFileField,
- selFileForm,
- selFileHScroll,
- selFileHScrolls[3],
- selFileLists[3],
- selFileOK,
- selFileCancel,
- selFilePrompt,
- selFileVScrolls[3];
-
-static Display *SFdisplay;
-
-static int SFcharWidth, SFcharAscent, SFcharHeight;
-
-static SFDir *SFdirs = NULL;
-
-static int SFdirEnd;
-static int SFdirPtr;
-
-static Pixel SFfore, SFback;
-
-static Atom SFwmDeleteWindow;
-
-static XSegment SFsegs[2], SFcompletionSegs[2];
-
-static XawTextPosition SFtextPos;
-
-static int SFupperX, SFlowerY, SFupperY;
-
-static int SFtextX, SFtextYoffset;
-
-static int SFentryWidth, SFentryHeight;
-
-static int SFlineToTextH = 3;
-static int SFlineToTextV = 3;
-
-static int SFbesideText = 3;
-static int SFaboveAndBelowText = 2;
-
-static int SFcharsPerEntry = 15;
-
-static int SFlistSize = 10;
-
-static int SFcurrentInvert[3] = { -1, -1, -1 };
-
-static int SFworkProcAdded = 0;
-
-static XtAppContext SFapp;
-
-static int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
-
-#ifdef FEAT_XFONTSET
-static char SFtextBuffer[MAXPATHL*sizeof(wchar_t)];
-#else
-static char SFtextBuffer[MAXPATHL];
-#endif
-
-static int SFbuttonPressed = 0;
-
-static XtIntervalId SFdirModTimerId;
-
-static int (*SFfunc)();
-
-static int SFstatus = SEL_FILE_NULL;
-
-///////////////// forward declare static functions
-
-static void SFsetText(char *path);
-static void SFtextChanged(void);
-static int SFgetDir(SFDir *dir);
-static void SFdrawLists(int doScroll);
-static void SFdrawList(int n, int doScroll);
-static void SFclearList(int n, int doScroll);
-static char SFstatChar(stat_T *statBuf);
-static void SFmotionList(Widget w, XtPointer np, XMotionEvent *event, Boolean *cont);
-static void SFvSliderMovedCallback(Widget w, int n, int nw);
-static Boolean SFworkProc(void *);
-static int SFcompareEntries(const void *p, const void *q);
-
-////////////////// xstat.h
-
-#ifndef S_IXUSR
-# define S_IXUSR 0100
-#endif
-#ifndef S_IXGRP
-# define S_IXGRP 0010
-#endif
-#ifndef S_IXOTH
-# define S_IXOTH 0001
-#endif
-
-#define S_ISXXX(m) ((m) & (S_IXUSR | S_IXGRP | S_IXOTH))
-
-////////////////// Path.c
-
-#include <pwd.h>
-
-typedef struct
-{
- char *name;
- char *dir;
-} SFLogin;
-
-static int SFdoNotTouchDirPtr = 0;
-
-static int SFdoNotTouchVorigin = 0;
-
-static SFDir SFrootDir, SFhomeDir;
-
-static SFLogin *SFlogins;
-
-static int SFtwiddle = 0;
-
- static int
-SFchdir(char *path)
-{
- int result;
-
- result = 0;
-
- if (strcmp(path, SFcurrentDir))
- {
- result = mch_chdir(path);
- if (!result)
- (void) strcpy(SFcurrentDir, path);
- }
-
- return result;
-}
-
- static void
-SFfree(int i)
-{
- SFDir *dir;
- int j;
-
- dir = &(SFdirs[i]);
-
- for (j = dir->nEntries - 1; j >= 0; j--)
- {
- if (dir->entries[j].shown != dir->entries[j].real)
- XtFree(dir->entries[j].shown);
- XtFree(dir->entries[j].real);
- }
-
- XtFree((char *)dir->entries);
- XtFree(dir->dir);
-
- dir->dir = NULL;
-}
-
- static void
-SFstrdup(char **s1, char *s2)
-{
- *s1 = strcpy(XtMalloc((unsigned)(strlen(s2) + 1)), s2);
-}
-
- static void
-SFunreadableDir(SFDir *dir)
-{
- char *cannotOpen = _("<cannot open> ");
-
- dir->entries = (SFEntry *) XtMalloc(sizeof(SFEntry));
- dir->entries[0].statDone = 1;
- SFstrdup(&dir->entries[0].real, cannotOpen);
- dir->entries[0].shown = dir->entries[0].real;
- dir->nEntries = 1;
- dir->nChars = strlen(cannotOpen);
-}
-
- static void
-SFreplaceText(SFDir *dir, char *str)
-{
- int len;
-
- *(dir->path) = 0;
- len = strlen(str);
- if (str[len - 1] == '/')
- (void) strcat(SFcurrentPath, str);
- else
- (void) strncat(SFcurrentPath, str, len - 1);
- if (strncmp(SFcurrentPath, SFstartDir, strlen(SFstartDir)))
- SFsetText(SFcurrentPath);
- else
- SFsetText(&(SFcurrentPath[strlen(SFstartDir)]));
-
- SFtextChanged();
-}
-
- static void
-SFexpand(char *str)
-{
- int len;
- int cmp;
- char *name, *growing;
- SFDir *dir;
- SFEntry *entry, *max;
-
- len = strlen(str);
-
- dir = &(SFdirs[SFdirEnd - 1]);
-
- if (dir->beginSelection == -1)
- {
- SFstrdup(&str, str);
- SFreplaceText(dir, str);
- XtFree(str);
- return;
- }
- else if (dir->beginSelection == dir->endSelection)
- {
- SFreplaceText(dir, dir->entries[dir->beginSelection].shown);
- return;
- }
-
- max = &(dir->entries[dir->endSelection + 1]);
-
- name = dir->entries[dir->beginSelection].shown;
- SFstrdup(&growing, name);
-
- cmp = 0;
- while (!cmp)
- {
- entry = &(dir->entries[dir->beginSelection]);
- while (entry < max)
- {
- if ((cmp = strncmp(growing, entry->shown, len)))
- break;
- entry++;
- }
- len++;
- }
-
- /*
- * SFreplaceText() expects filename
- */
- growing[len - 2] = ' ';
-
- growing[len - 1] = 0;
- SFreplaceText(dir, growing);
- XtFree(growing);
-}
-
- static int
-SFfindFile(SFDir *dir, char *str)
-{
- int i, last, max;
- char *name, save;
- SFEntry *entries;
- int len;
- int begin, end;
- int result;
-
- len = strlen(str);
-
- if (str[len - 1] == ' ')
- {
- SFexpand(str);
- return 1;
- }
- else if (str[len - 1] == '/')
- len--;
-
- max = dir->nEntries;
-
- entries = dir->entries;
-
- i = 0;
- while (i < max)
- {
- name = entries[i].shown;
- last = strlen(name) - 1;
- save = name[last];
- name[last] = 0;
-
- result = strncmp(str, name, len);
-
- name[last] = save;
- if (result <= 0)
- break;
- i++;
- }
- begin = i;
- while (i < max)
- {
- name = entries[i].shown;
- last = strlen(name) - 1;
- save = name[last];
- name[last] = 0;
-
- result = strncmp(str, name, len);
-
- name[last] = save;
- if (result)
- break;
- i++;
- }
- end = i;
-
- if (begin != end)
- {
- if ((dir->beginSelection != begin) || (dir->endSelection != end - 1))
- {
- dir->changed = 1;
- dir->beginSelection = begin;
- if (str[strlen(str) - 1] == '/')
- dir->endSelection = begin;
- else
- dir->endSelection = end - 1;
- }
- }
- else if (dir->beginSelection != -1)
- {
- dir->changed = 1;
- dir->beginSelection = -1;
- dir->endSelection = -1;
- }
-
- if (SFdoNotTouchVorigin
- || ((begin > dir->vOrigin) && (end < dir->vOrigin + SFlistSize)))
- {
- SFdoNotTouchVorigin = 0;
- return 0;
- }
-
- i = begin - 1;
- if (i > max - SFlistSize)
- i = max - SFlistSize;
- if (i < 0)
- i = 0;
-
- if (dir->vOrigin != i)
- {
- dir->vOrigin = i;
- dir->changed = 1;
- }
-
- return 0;
-}
-
- static void
-SFunselect(void)
-{
- SFDir *dir;
-
- dir = &(SFdirs[SFdirEnd - 1]);
- if (dir->beginSelection != -1)
- dir->changed = 1;
- dir->beginSelection = -1;
- dir->endSelection = -1;
-}
-
- static int
-SFcompareLogins(const void *p, const void *q)
-{
- return strcmp(((SFLogin *)p)->name, ((SFLogin *)q)->name);
-}
-
- static void
-SFgetHomeDirs(void)
-{
- struct passwd *pw;
- int Alloc;
- int i;
- SFEntry *entries = NULL;
- int len;
- int maxChars;
-
- Alloc = 1;
- i = 1;
- entries = (SFEntry *)XtMalloc(sizeof(SFEntry));
- SFlogins = (SFLogin *)XtMalloc(sizeof(SFLogin));
- entries[0].real = XtMalloc(3);
- (void) strcpy(entries[0].real, "~");
- entries[0].shown = entries[0].real;
- entries[0].statDone = 1;
- SFlogins[0].name = "";
- pw = getpwuid((int) getuid());
- SFstrdup(&SFlogins[0].dir, pw ? pw->pw_dir : "/");
- maxChars = 0;
-
- (void) setpwent();
-
- while ((pw = getpwent()) && (*(pw->pw_name)))
- {
- if (i >= Alloc)
- {
- Alloc *= 2;
- entries = (SFEntry *) XtRealloc((char *)entries,
- (unsigned)(Alloc * sizeof(SFEntry)));
- SFlogins = (SFLogin *) XtRealloc((char *)SFlogins,
- (unsigned)(Alloc * sizeof(SFLogin)));
- }
- len = strlen(pw->pw_name);
- entries[i].real = XtMalloc((unsigned)(len + 3));
- (void) strcat(strcpy(entries[i].real, "~"), pw->pw_name);
- entries[i].shown = entries[i].real;
- entries[i].statDone = 1;
- if (len > maxChars)
- maxChars = len;
- SFstrdup(&SFlogins[i].name, pw->pw_name);
- SFstrdup(&SFlogins[i].dir, pw->pw_dir);
- i++;
- }
-
- SFhomeDir.dir = XtMalloc(1);
- SFhomeDir.dir[0] = 0;
- SFhomeDir.path = SFcurrentPath;
- SFhomeDir.entries = entries;
- SFhomeDir.nEntries = i;
- SFhomeDir.vOrigin = 0; // :-)
- SFhomeDir.nChars = maxChars + 2;
- SFhomeDir.hOrigin = 0;
- SFhomeDir.changed = 1;
- SFhomeDir.beginSelection = -1;
- SFhomeDir.endSelection = -1;
-
- qsort((char *)entries, (size_t)i, sizeof(SFEntry), SFcompareEntries);
- qsort((char *)SFlogins, (size_t)i, sizeof(SFLogin), SFcompareLogins);
-
- for (i--; i >= 0; i--)
- (void)strcat(entries[i].real, "/");
-}
-
- static int
-SFfindHomeDir(char *begin, char *end)
-{
- char save;
- char *theRest;
- int i;
-
- save = *end;
- *end = 0;
-
- for (i = SFhomeDir.nEntries - 1; i >= 0; i--)
- {
- if (!strcmp(SFhomeDir.entries[i].real, begin))
- {
- *end = save;
- SFstrdup(&theRest, end);
- (void) strcat(strcat(strcpy(SFcurrentPath,
- SFlogins[i].dir), "/"), theRest);
- XtFree(theRest);
- SFsetText(SFcurrentPath);
- SFtextChanged();
- return 1;
- }
- }
-
- *end = save;
-
- return 0;
-}
-
- static void
-SFupdatePath(void)
-{
- static int Alloc;
- static int wasTwiddle = 0;
- char *begin, *end;
- int i, j;
- int prevChange;
- int SFdirPtrSave, SFdirEndSave;
- SFDir *dir;
-
- if (!SFdirs)
- {
- SFdirs = (SFDir *) XtMalloc((Alloc = 10) * sizeof(SFDir));
- dir = &(SFdirs[0]);
- SFstrdup(&dir->dir, "/");
- (void) SFchdir("/");
- (void) SFgetDir(dir);
- for (j = 1; j < Alloc; j++)
- SFdirs[j].dir = NULL;
- dir->path = SFcurrentPath + 1;
- dir->vOrigin = 0;
- dir->hOrigin = 0;
- dir->changed = 1;
- dir->beginSelection = -1;
- dir->endSelection = -1;
- SFhomeDir.dir = NULL;
- }
-
- SFdirEndSave = SFdirEnd;
- SFdirEnd = 1;
-
- SFdirPtrSave = SFdirPtr;
- SFdirPtr = 0;
-
- begin = NULL;
-
- if (SFcurrentPath[0] == '~')
- {
- if (!SFtwiddle)
- {
- SFtwiddle = 1;
- dir = &(SFdirs[0]);
- SFrootDir = *dir;
- if (!SFhomeDir.dir)
- SFgetHomeDirs();
- *dir = SFhomeDir;
- dir->changed = 1;
- }
- end = SFcurrentPath;
- SFdoNotTouchDirPtr = 1;
- wasTwiddle = 1;
- }
- else
- {
- if (SFtwiddle)
- {
- SFtwiddle = 0;
- dir = &(SFdirs[0]);
- *dir = SFrootDir;
- dir->changed = 1;
- }
- end = SFcurrentPath + 1;
- }
-
- i = 0;
-
- prevChange = 0;
-
- while (*end)
- {
- while (*end++ == '/')
- ;
- end--;
- begin = end;
- while ((*end) && (*end++ != '/'))
- ;
- if ((end - SFcurrentPath <= SFtextPos) && (*(end - 1) == '/'))
- {
- SFdirPtr = i - 1;
- if (SFdirPtr < 0)
- SFdirPtr = 0;
- }
- if (*begin)
- {
- if (*(end - 1) == '/')
- {
- char save = *end;
-
- if (SFtwiddle)
- {
- if (SFfindHomeDir(begin, end))
- return;
- }
- *end = 0;
- i++;
- SFdirEnd++;
- if (i >= Alloc)
- {
- SFdirs = (SFDir *) XtRealloc((char *) SFdirs,
- (unsigned)((Alloc *= 2) * sizeof(SFDir)));
- for (j = Alloc / 2; j < Alloc; j++)
- SFdirs[j].dir = NULL;
- }
- dir = &(SFdirs[i]);
- if ((!(dir->dir)) || prevChange || strcmp(dir->dir, begin))
- {
- if (dir->dir)
- SFfree(i);
- prevChange = 1;
- SFstrdup(&dir->dir, begin);
- dir->path = end;
- dir->vOrigin = 0;
- dir->hOrigin = 0;
- dir->changed = 1;
- dir->beginSelection = -1;
- dir->endSelection = -1;
- (void)SFfindFile(dir - 1, begin);
- if (SFchdir(SFcurrentPath) || SFgetDir(dir))
- {
- SFunreadableDir(dir);
- break;
- }
- }
- *end = save;
- if (!save)
- SFunselect();
- }
- else
- {
- if (SFfindFile(&(SFdirs[SFdirEnd-1]), begin))
- return;
- }
- }
- else
- SFunselect();
- }
-
- if ((end == SFcurrentPath + 1) && (!SFtwiddle))
- SFunselect();
-
- for (i = SFdirEnd; i < Alloc; i++)
- if (SFdirs[i].dir)
- SFfree(i);
-
- if (SFdoNotTouchDirPtr)
- {
- if (wasTwiddle)
- {
- wasTwiddle = 0;
- SFdirPtr = SFdirEnd - 2;
- if (SFdirPtr < 0)
- SFdirPtr = 0;
- }
- else
- SFdirPtr = SFdirPtrSave;
- SFdoNotTouchDirPtr = 0;
- }
-
- if ((SFdirPtr != SFdirPtrSave) || (SFdirEnd != SFdirEndSave))
- {
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb( selFileHScroll,
- (float) (((double) SFdirPtr) / SFdirEnd),
- (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) /
- SFdirEnd));
-#else
- vim_XawScrollbarSetThumb( selFileHScroll,
- (float) (((double) SFdirPtr) / SFdirEnd),
- (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) /
- SFdirEnd),
- (double)SFdirEnd);
-#endif
- }
-
- if (SFdirPtr != SFdirPtrSave)
- SFdrawLists(SF_DO_SCROLL);
- else
- for (i = 0; i < 3; i++)
- {
- if (SFdirPtr + i < SFdirEnd)
- {
- if (SFdirs[SFdirPtr + i].changed)
- {
- SFdirs[SFdirPtr + i].changed = 0;
- SFdrawList(i, SF_DO_SCROLL);
- }
- }
- else
- SFclearList(i, SF_DO_SCROLL);
- }
-}
-
-#ifdef XtNinternational
- static int
-WcsLen(wchar_t *p)
-{
- int i = 0;
- while (*p++ != 0)
- i++;
- return i;
-}
-#endif
-
- static void
-SFsetText(char *path)
-{
- XawTextBlock text;
-
- text.firstPos = 0;
- text.length = strlen(path);
- text.ptr = path;
- text.format = FMT8BIT;
-
-#ifdef XtNinternational
- if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
- {
- XawTextReplace(selFileField, (XawTextPosition)0,
- (XawTextPosition)WcsLen((wchar_t *)&SFtextBuffer[0]), &text);
- XawTextSetInsertionPoint(selFileField,
- (XawTextPosition)WcsLen((wchar_t *)&SFtextBuffer[0]));
- }
- else
- {
- XawTextReplace(selFileField, (XawTextPosition)0,
- (XawTextPosition)strlen(SFtextBuffer), &text);
- XawTextSetInsertionPoint(selFileField,
- (XawTextPosition)strlen(SFtextBuffer));
- }
-#else
- XawTextReplace(selFileField, (XawTextPosition)0,
- (XawTextPosition)strlen(SFtextBuffer), &text);
- XawTextSetInsertionPoint(selFileField,
- (XawTextPosition)strlen(SFtextBuffer));
-#endif
-}
-
- static void
-SFbuttonPressList(
- Widget w UNUSED,
- XtPointer np UNUSED,
- XEvent *event UNUSED,
- Boolean *cont UNUSED)
-{
- SFbuttonPressed = 1;
-}
-
- static void
-SFbuttonReleaseList(
- Widget w UNUSED,
- XtPointer np,
- XEvent *event UNUSED,
- Boolean *cont UNUSED)
-{
- long n = (long)np;
- SFDir *dir;
-
- SFbuttonPressed = 0;
-
- if (SFcurrentInvert[n] != -1)
- {
- if (n < 2)
- SFdoNotTouchDirPtr = 1;
- SFdoNotTouchVorigin = 1;
- dir = &(SFdirs[SFdirPtr + n]);
- SFreplaceText(dir,
- dir->entries[dir->vOrigin + SFcurrentInvert[n]].shown);
- SFmotionList(w, (XtPointer)(long)n, (XMotionEvent *)event, 0);
- }
-}
-
- static int
-SFcheckDir(int n, SFDir *dir)
-{
- stat_T statBuf;
- int i;
-
- if ((!mch_stat(".", &statBuf)) && (statBuf.st_mtime != dir->mtime))
- {
- /*
- * If the pointer is currently in the window that we are about
- * to update, we must warp it to prevent the user from
- * accidentally selecting the wrong file.
- */
- if (SFcurrentInvert[n] != -1)
- {
- XWarpPointer(
- SFdisplay,
- None,
- XtWindow(selFileLists[n]),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0);
- }
-
- for (i = dir->nEntries - 1; i >= 0; i--)
- {
- if (dir->entries[i].shown != dir->entries[i].real)
- XtFree(dir->entries[i].shown);
- XtFree(dir->entries[i].real);
- }
- XtFree((char *) dir->entries);
- if (SFgetDir(dir))
- SFunreadableDir(dir);
- if (dir->vOrigin > dir->nEntries - SFlistSize)
- dir->vOrigin = dir->nEntries - SFlistSize;
- if (dir->vOrigin < 0)
- dir->vOrigin = 0;
- if (dir->hOrigin > dir->nChars - SFcharsPerEntry)
- dir->hOrigin = dir->nChars - SFcharsPerEntry;
- if (dir->hOrigin < 0)
- dir->hOrigin = 0;
- dir->beginSelection = -1;
- dir->endSelection = -1;
- SFdoNotTouchVorigin = 1;
- if ((dir + 1)->dir)
- (void) SFfindFile(dir, (dir + 1)->dir);
- else
- (void) SFfindFile(dir, dir->path);
-
- if (!SFworkProcAdded)
- {
- (void) XtAppAddWorkProc(SFapp, (XtWorkProc)SFworkProc, NULL);
- SFworkProcAdded = 1;
- }
- return 1;
- }
- return 0;
-}
-
- static int
-SFcheckFiles(SFDir *dir)
-{
- int from, to;
- int result;
- char oldc, newc;
- int i;
- char *str;
- int last;
- stat_T statBuf;
-
- result = 0;
-
- from = dir->vOrigin;
- to = dir->vOrigin + SFlistSize;
- if (to > dir->nEntries)
- to = dir->nEntries;
-
- for (i = from; i < to; i++)
- {
- str = dir->entries[i].real;
- last = strlen(str) - 1;
- oldc = str[last];
- str[last] = 0;
- if (mch_stat(str, &statBuf))
- newc = ' ';
- else
- newc = SFstatChar(&statBuf);
- str[last] = newc;
- if (newc != oldc)
- result = 1;
- }
-
- return result;
-}
-
- static void
-SFdirModTimer(XtPointer cl UNUSED, XtIntervalId *id UNUSED)
-{
- static int n = -1;
- static int f = 0;
- char save;
- SFDir *dir;
-
- if ((!SFtwiddle) && (SFdirPtr < SFdirEnd))
- {
- n++;
- if ((n > 2) || (SFdirPtr + n >= SFdirEnd))
- {
- n = 0;
- f++;
- if ((f > 2) || (SFdirPtr + f >= SFdirEnd))
- f = 0;
- }
- dir = &(SFdirs[SFdirPtr + n]);
- save = *(dir->path);
- *(dir->path) = 0;
- if (SFchdir(SFcurrentPath))
- {
- *(dir->path) = save;
-
- /*
- * force a re-read
- */
- *(dir->dir) = 0;
-
- SFupdatePath();
- }
- else
- {
- *(dir->path) = save;
- if (SFcheckDir(n, dir) || ((f == n) && SFcheckFiles(dir)))
- SFdrawList(n, SF_DO_SCROLL);
- }
- }
-
- SFdirModTimerId = XtAppAddTimeOut(SFapp, (unsigned long) 1000,
- SFdirModTimer, (XtPointer) NULL);
-}
-
-// Return a single character describing what kind of file STATBUF is.
-
- static char
-SFstatChar(stat_T *statBuf)
-{
- if (S_ISDIR (statBuf->st_mode))
- return '/';
- if (S_ISREG (statBuf->st_mode))
- return S_ISXXX (statBuf->st_mode) ? '*' : ' ';
-#ifdef S_ISSOCK
- if (S_ISSOCK (statBuf->st_mode))
- return '=';
-#endif // S_ISSOCK
- return ' ';
-}
-
-////////////////// Draw.c
-
-#ifdef FEAT_GUI_NEXTAW
-# include <X11/neXtaw/Cardinals.h>
-#else
-# include <X11/Xaw/Cardinals.h>
-#endif
-
-#ifdef FEAT_XFONTSET
-# define SF_DEFAULT_FONT "-misc-fixed-medium-r-normal--14-*"
-#else
-# define SF_DEFAULT_FONT "9x15"
-#endif
-
-#ifdef ABS
-# undef ABS
-#endif
-#define ABS(x) (((x) < 0) ? (-(x)) : (x))
-
-typedef struct
-{
- char *fontname;
-} TextData;
-
-static GC SFlineGC, SFscrollGC, SFinvertGC, SFtextGC;
-
-static XtResource textResources[] =
-{
-#ifdef FEAT_XFONTSET
- {XtNfontSet, XtCFontSet, XtRString, sizeof (char *),
- XtOffsetOf(TextData, fontname), XtRString, SF_DEFAULT_FONT},
-#else
- {XtNfont, XtCFont, XtRString, sizeof (char *),
- XtOffsetOf(TextData, fontname), XtRString, SF_DEFAULT_FONT},
-#endif
-};
-
-#ifdef FEAT_XFONTSET
-static XFontSet SFfont;
-#else
-static XFontStruct *SFfont;
-#endif
-
-static int SFcurrentListY;
-
-static XtIntervalId SFscrollTimerId;
-
- static void
-SFinitFont(void)
-{
- TextData *data;
-#ifdef FEAT_XFONTSET
- XFontSetExtents *extents;
- char **missing, *def_str;
- int num_missing;
-#endif
-
- data = XtNew(TextData);
-
- XtGetApplicationResources(selFileForm, (XtPointer) data, textResources,
- XtNumber(textResources), (Arg *) NULL, ZERO);
-
-#ifdef FEAT_XFONTSET
- SFfont = XCreateFontSet(SFdisplay, data->fontname,
- &missing, &num_missing, &def_str);
-#else
- SFfont = XLoadQueryFont(SFdisplay, data->fontname);
-#endif
- if (!SFfont)
- {
-#ifdef FEAT_XFONTSET
- SFfont = XCreateFontSet(SFdisplay, SF_DEFAULT_FONT,
- &missing, &num_missing, &def_str);
-#else
- SFfont = XLoadQueryFont(SFdisplay, SF_DEFAULT_FONT);
-#endif
- if (!SFfont)
- {
- semsg(_(e_vim_selfile_cant_get_font_str), SF_DEFAULT_FONT);
- SFstatus = SEL_FILE_CANCEL;
- return;
- }
- }
-
-#ifdef FEAT_XFONTSET
- extents = XExtentsOfFontSet(SFfont);
- SFcharWidth = extents->max_logical_extent.width;
- SFcharAscent = -extents->max_logical_extent.y;
- SFcharHeight = extents->max_logical_extent.height;
-#else
- SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
- SFcharAscent = SFfont->max_bounds.ascent;
- SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
-#endif
-}
-
- static void
-SFcreateGC(void)
-{
- XGCValues gcValues;
- XRectangle rectangles[1];
-
- gcValues.foreground = SFfore;
-
- SFlineGC = XtGetGC(
- selFileLists[0],
- (XtGCMask)GCForeground,
- &gcValues);
-
- SFscrollGC = XtGetGC(
- selFileLists[0],
- (XtGCMask)0,
- &gcValues);
-
- gcValues.function = GXxor;
- gcValues.foreground = SFfore ^ SFback;
- gcValues.background = SFfore ^ SFback;
-
- SFinvertGC = XtGetGC(
- selFileLists[0],
- (XtGCMask)GCFunction | GCForeground | GCBackground,
- &gcValues);
-
- gcValues.foreground = SFfore;
- gcValues.background = SFback;
-#ifndef FEAT_XFONTSET
- gcValues.font = SFfont->fid;
-#endif
-
- SFtextGC = XCreateGC(
- SFdisplay,
- XtWindow(selFileLists[0]),
-#ifdef FEAT_XFONTSET
- (unsigned long)GCForeground | GCBackground,
-#else
- (unsigned long)GCForeground | GCBackground | GCFont,
-#endif
- &gcValues);
-
- rectangles[0].x = SFlineToTextH + SFbesideText;
- rectangles[0].y = 0;
- rectangles[0].width = SFcharsPerEntry * SFcharWidth;
- rectangles[0].height = SFupperY + 1;
-
- XSetClipRectangles(
- SFdisplay,
- SFtextGC,
- 0,
- 0,
- rectangles,
- 1,
- Unsorted);
-}
-
- static void
-SFclearList(int n, int doScroll)
-{
- SFDir *dir;
-
- SFcurrentInvert[n] = -1;
-
- XClearWindow(SFdisplay, XtWindow(selFileLists[n]));
-
- XDrawSegments(SFdisplay, XtWindow(selFileLists[n]), SFlineGC, SFsegs, 2);
-
- if (doScroll)
- {
- dir = &(SFdirs[SFdirPtr + n]);
-
- if ((SFdirPtr + n < SFdirEnd) && dir->nEntries && dir->nChars)
- {
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) /
- dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize)
- ? dir->nEntries : SFlistSize)) /
- dir->nEntries));
-#else
- vim_XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) /
- dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize)
- ? dir->nEntries : SFlistSize)) /
- dir->nEntries),
- (double)dir->nEntries);
-#endif
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- selFileHScrolls[n],
- (float) (((double) dir->hOrigin) / dir->nChars),
- (float) (((double) ((dir->nChars <
- SFcharsPerEntry) ? dir->nChars :
- SFcharsPerEntry)) / dir->nChars));
-#else
- vim_XawScrollbarSetThumb(
- selFileHScrolls[n],
- (float) (((double) dir->hOrigin) / dir->nChars),
- (float) (((double) ((dir->nChars <
- SFcharsPerEntry) ? dir->nChars :
- SFcharsPerEntry)) / dir->nChars),
- (double)dir->nChars);
-#endif
- }
- else
- {
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(selFileVScrolls[n], (float) 0.0,
- (float) 1.0);
-#else
- vim_XawScrollbarSetThumb(selFileVScrolls[n], (float) 0.0,
- (float) 1.0, 1.0);
-#endif
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(selFileHScrolls[n], (float) 0.0,
- (float) 1.0);
-#else
- vim_XawScrollbarSetThumb(selFileHScrolls[n], (float) 0.0,
- (float) 1.0, 1.0);
-#endif
- }
- }
-}
-
- static void
-SFdeleteEntry(SFDir *dir, SFEntry *entry)
-{
- SFEntry *e;
- SFEntry *end;
- int n;
- int idx;
-
- idx = entry - dir->entries;
-
- if (idx < dir->beginSelection)
- dir->beginSelection--;
- if (idx <= dir->endSelection)
- dir->endSelection--;
- if (dir->beginSelection > dir->endSelection)
- dir->beginSelection = dir->endSelection = -1;
-
- if (idx < dir->vOrigin)
- dir->vOrigin--;
-
- XtFree(entry->real);
-
- end = &(dir->entries[dir->nEntries - 1]);
-
- for (e = entry; e < end; e++)
- *e = *(e + 1);
-
- if (!(--dir->nEntries))
- return;
-
- n = dir - &(SFdirs[SFdirPtr]);
- if ((n < 0) || (n > 2))
- return;
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) / dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries));
-#else
- vim_XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) / dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries),
- (double)dir->nEntries);
-#endif
-}
-
- static void
-SFwriteStatChar(
- char *name,
- int last,
- stat_T *statBuf)
-{
- name[last] = SFstatChar(statBuf);
-}
-
- static int
-SFstatAndCheck(SFDir *dir, SFEntry *entry)
-{
- stat_T statBuf;
- char save;
- int last;
-
- /*
- * must be restored before returning
- */
- save = *(dir->path);
- *(dir->path) = 0;
-
- if (!SFchdir(SFcurrentPath))
- {
- last = strlen(entry->real) - 1;
- entry->real[last] = 0;
- entry->statDone = 1;
- if ((!mch_stat(entry->real, &statBuf))
-#ifdef S_IFLNK
- || (!mch_lstat(entry->real, &statBuf))
-#endif
- )
- {
- if (SFfunc)
- {
- char *shown;
-
- shown = NULL;
- if (SFfunc(entry->real, &shown, &statBuf))
- {
- if (shown)
- {
- int len;
-
- len = strlen(shown);
- entry->shown = XtMalloc((unsigned)(len + 2));
- (void) strcpy(entry->shown, shown);
- SFwriteStatChar(entry->shown, len, &statBuf);
- entry->shown[len + 1] = 0;
- }
- }
- else
- {
- SFdeleteEntry(dir, entry);
-
- *(dir->path) = save;
- return 1;
- }
- }
- SFwriteStatChar(entry->real, last, &statBuf);
- }
- else
- entry->real[last] = ' ';
- }
-
- *(dir->path) = save;
- return 0;
-}
-
-
- static void
-SFdrawStrings(
- Window w,
- SFDir *dir,
- int from,
- int to)
-{
- int i;
- SFEntry *entry;
- int x;
-
- x = SFtextX - dir->hOrigin * SFcharWidth;
-
- if (dir->vOrigin + to >= dir->nEntries)
- to = dir->nEntries - dir->vOrigin - 1;
- for (i = from; i <= to; i++)
- {
- entry = &(dir->entries[dir->vOrigin + i]);
- if (!(entry->statDone))
- {
- if (SFstatAndCheck(dir, entry))
- {
- if (dir->vOrigin + to >= dir->nEntries)
- to = dir->nEntries - dir->vOrigin - 1;
- i--;
- continue;
- }
- }
-#ifdef FEAT_XFONTSET
- XmbDrawImageString(
- SFdisplay,
- w,
- SFfont,
- SFtextGC,
- x,
- SFtextYoffset + i * SFentryHeight,
- entry->shown,
- strlen(entry->shown));
-#else
- XDrawImageString(
- SFdisplay,
- w,
- SFtextGC,
- x,
- SFtextYoffset + i * SFentryHeight,
- entry->shown,
- strlen(entry->shown));
-#endif
- if (dir->vOrigin + i == dir->beginSelection)
- {
- XDrawLine(
- SFdisplay,
- w,
- SFlineGC,
- SFlineToTextH + 1,
- SFlowerY + i * SFentryHeight,
- SFlineToTextH + SFentryWidth - 2,
- SFlowerY + i * SFentryHeight);
- }
- if ((dir->vOrigin + i >= dir->beginSelection) &&
- (dir->vOrigin + i <= dir->endSelection))
- {
- SFcompletionSegs[0].y1 = SFcompletionSegs[1].y1 =
- SFlowerY + i * SFentryHeight;
- SFcompletionSegs[0].y2 = SFcompletionSegs[1].y2 =
- SFlowerY + (i + 1) * SFentryHeight - 1;
- XDrawSegments(
- SFdisplay,
- w,
- SFlineGC,
- SFcompletionSegs,
- 2);
- }
- if (dir->vOrigin + i == dir->endSelection)
- {
- XDrawLine(
- SFdisplay,
- w,
- SFlineGC,
- SFlineToTextH + 1,
- SFlowerY + (i + 1) * SFentryHeight - 1,
- SFlineToTextH + SFentryWidth - 2,
- SFlowerY + (i + 1) * SFentryHeight - 1);
- }
- }
-}
-
- static void
-SFdrawList(int n, int doScroll)
-{
- SFDir *dir;
- Window w;
-
- SFclearList(n, doScroll);
-
- if (SFdirPtr + n < SFdirEnd)
- {
- dir = &(SFdirs[SFdirPtr + n]);
- w = XtWindow(selFileLists[n]);
-#ifdef FEAT_XFONTSET
- XmbDrawImageString(
- SFdisplay,
- w,
- SFfont,
- SFtextGC,
- SFtextX - dir->hOrigin * SFcharWidth,
- SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
- dir->dir,
- strlen(dir->dir));
-#else
- XDrawImageString(
- SFdisplay,
- w,
- SFtextGC,
- SFtextX - dir->hOrigin * SFcharWidth,
- SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
- dir->dir,
- strlen(dir->dir));
-#endif
- SFdrawStrings(w, dir, 0, SFlistSize - 1);
- }
-}
-
- static void
-SFdrawLists(int doScroll)
-{
- int i;
-
- for (i = 0; i < 3; i++)
- SFdrawList(i, doScroll);
-}
-
- static void
-SFinvertEntry(int n)
-{
- XFillRectangle(
- SFdisplay,
- XtWindow(selFileLists[n]),
- SFinvertGC,
- SFlineToTextH,
- SFcurrentInvert[n] * SFentryHeight + SFlowerY,
- SFentryWidth,
- SFentryHeight);
-}
-
- static unsigned long
-SFscrollTimerInterval(void)
-{
- static int maxVal = 200;
- static int varyDist = 50;
- static int minDist = 50;
- int t;
- int dist;
-
- if (SFcurrentListY < SFlowerY)
- dist = SFlowerY - SFcurrentListY;
- else if (SFcurrentListY > SFupperY)
- dist = SFcurrentListY - SFupperY;
- else
- return (unsigned long) 1;
-
- t = maxVal - ((maxVal / varyDist) * (dist - minDist));
-
- if (t < 1)
- t = 1;
-
- if (t > maxVal)
- t = maxVal;
-
- return (unsigned long)t;
-}
-
- static void
-SFscrollTimer(XtPointer p, XtIntervalId *id UNUSED)
-{
- SFDir *dir;
- int save;
- int n;
-
- n = (long)p;
-
- dir = &(SFdirs[SFdirPtr + n]);
- save = dir->vOrigin;
-
- if (SFcurrentListY < SFlowerY)
- {
- if (dir->vOrigin > 0)
- SFvSliderMovedCallback(selFileVScrolls[n], n, dir->vOrigin - 1);
- }
- else if (SFcurrentListY > SFupperY)
- {
- if (dir->vOrigin < dir->nEntries - SFlistSize)
- SFvSliderMovedCallback(selFileVScrolls[n], n, dir->vOrigin + 1);
- }
-
- if (dir->vOrigin != save)
- {
- if (dir->nEntries)
- {
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) / dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries));
-#else
- vim_XawScrollbarSetThumb(
- selFileVScrolls[n],
- (float) (((double) dir->vOrigin) / dir->nEntries),
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries),
- (double)dir->nEntries);
-#endif
- }
- }
-
- if (SFbuttonPressed)
- SFscrollTimerId = XtAppAddTimeOut(SFapp,
- SFscrollTimerInterval(), SFscrollTimer,
- (XtPointer)(long_u)n);
-}
-
- static int
-SFnewInvertEntry(int n, XMotionEvent *event)
-{
- int x, y;
- int nw;
- static int SFscrollTimerAdded = 0;
-
- x = event->x;
- y = event->y;
-
- if (SFdirPtr + n >= SFdirEnd)
- return -1;
-
- if ((x >= 0) && (x <= SFupperX) && (y >= SFlowerY) && (y <= SFupperY))
- {
- SFDir *dir = &(SFdirs[SFdirPtr + n]);
-
- if (SFscrollTimerAdded)
- {
- SFscrollTimerAdded = 0;
- XtRemoveTimeOut(SFscrollTimerId);
- }
-
- nw = (y - SFlowerY) / SFentryHeight;
- if (dir->vOrigin + nw >= dir->nEntries)
- return -1;
- return nw;
- }
- else
- {
- if (SFbuttonPressed)
- {
- SFcurrentListY = y;
- if (!SFscrollTimerAdded)
- {
- SFscrollTimerAdded = 1;
- SFscrollTimerId = XtAppAddTimeOut(SFapp,
- SFscrollTimerInterval(), SFscrollTimer,
- (XtPointer)(long_u)n);
- }
- }
- return -1;
- }
-}
-
- static void
-SFenterList(
- Widget w UNUSED,
- XtPointer np,
- XEvent *event,
- Boolean *cont UNUSED)
-{
- long n = (long)np;
- int nw;
-
- // sanity
- if (SFcurrentInvert[n] != -1)
- {
- SFinvertEntry(n);
- SFcurrentInvert[n] = -1;
- }
-
- nw = SFnewInvertEntry(n, (XMotionEvent *) event);
- if (nw != -1)
- {
- SFcurrentInvert[n] = nw;
- SFinvertEntry(n);
- }
-}
-
- static void
-SFleaveList(
- Widget w UNUSED,
- XtPointer np,
- XEvent *event UNUSED,
- Boolean *cont UNUSED)
-{
- long n = (long)np;
-
- if (SFcurrentInvert[n] != -1)
- {
- SFinvertEntry(n);
- SFcurrentInvert[n] = -1;
- }
-}
-
- static void
-SFmotionList(
- Widget w UNUSED,
- XtPointer np,
- XMotionEvent *event UNUSED,
- Boolean *cont UNUSED)
-{
- long n = (long)np;
- int nw;
-
- nw = SFnewInvertEntry(n, event);
-
- if (nw != SFcurrentInvert[n])
- {
- if (SFcurrentInvert[n] != -1)
- SFinvertEntry(n);
- SFcurrentInvert[n] = nw;
- if (nw != -1)
- SFinvertEntry(n);
- }
-}
-
- static void
-SFvFloatSliderMovedCallback(Widget w, XtPointer n, XtPointer fnew)
-{
- int nw;
-
- nw = (*(float *)fnew) * SFdirs[SFdirPtr + (int)(long)n].nEntries;
- SFvSliderMovedCallback(w, (int)(long)n, nw);
-}
-
- static void
-SFvSliderMovedCallback(Widget w UNUSED, int n, int nw)
-{
- int old;
- Window win;
- SFDir *dir;
-
- dir = &(SFdirs[SFdirPtr + n]);
-
- old = dir->vOrigin;
- dir->vOrigin = nw;
-
- if (old == nw)
- return;
-
- win = XtWindow(selFileLists[n]);
-
- if (ABS(nw - old) < SFlistSize)
- {
- if (nw > old)
- {
- XCopyArea(
- SFdisplay,
- win,
- win,
- SFscrollGC,
- SFlineToTextH,
- SFlowerY + (nw - old) * SFentryHeight,
- SFentryWidth + SFlineToTextH,
- (SFlistSize - (nw - old)) * SFentryHeight,
- SFlineToTextH,
- SFlowerY);
- XClearArea(
- SFdisplay,
- win,
- SFlineToTextH,
- SFlowerY + (SFlistSize - (nw - old)) *
- SFentryHeight,
- SFentryWidth + SFlineToTextH,
- (nw - old) * SFentryHeight,
- False);
- SFdrawStrings(win, dir, SFlistSize - (nw - old),
- SFlistSize - 1);
- }
- else
- {
- XCopyArea(
- SFdisplay,
- win,
- win,
- SFscrollGC,
- SFlineToTextH,
- SFlowerY,
- SFentryWidth + SFlineToTextH,
- (SFlistSize - (old - nw)) * SFentryHeight,
- SFlineToTextH,
- SFlowerY + (old - nw) * SFentryHeight);
- XClearArea(
- SFdisplay,
- win,
- SFlineToTextH,
- SFlowerY,
- SFentryWidth + SFlineToTextH,
- (old - nw) * SFentryHeight,
- False);
- SFdrawStrings(win, dir, 0, old - nw);
- }
- }
- else
- {
- XClearArea(
- SFdisplay,
- win,
- SFlineToTextH,
- SFlowerY,
- SFentryWidth + SFlineToTextH,
- SFlistSize * SFentryHeight,
- False);
- SFdrawStrings(win, dir, 0, SFlistSize - 1);
- }
-}
-
- static void
-SFvAreaSelectedCallback(Widget w, XtPointer n, XtPointer pnew)
-{
- SFDir *dir;
- int nw = (int)(long)pnew;
-
- dir = &(SFdirs[SFdirPtr + (int)(long)n]);
-
-#ifdef FEAT_GUI_NEXTAW
- if (nw < 0)
- {
- if (nw > -SFvScrollHeight)
- nw = -1;
- else
- nw = -SFlistSize;
- }
- else if (nw > 0)
- {
- if (nw < SFvScrollHeight)
- nw = 1;
- else
- nw = SFlistSize;
- }
-#endif
- nw += dir->vOrigin;
-
- if (nw > dir->nEntries - SFlistSize)
- nw = dir->nEntries - SFlistSize;
-
- if (nw < 0)
- nw = 0;
-
- if (dir->nEntries)
- {
- float f;
-
- f = ((double) nw) / dir->nEntries;
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries));
-#else
- vim_XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((dir->nEntries < SFlistSize) ?
- dir->nEntries : SFlistSize)) / dir->nEntries),
- (double)dir->nEntries);
-#endif
- }
-
- SFvSliderMovedCallback(w, (int)(long)n, nw);
-}
-
- static void
-SFhSliderMovedCallback(Widget w UNUSED, XtPointer n, XtPointer nw)
-{
- SFDir *dir;
- int save;
-
- dir = &(SFdirs[SFdirPtr + (int)(long)n]);
- save = dir->hOrigin;
- dir->hOrigin = (*(float *)nw) * dir->nChars;
- if (dir->hOrigin == save)
- return;
-
- SFdrawList((int)(long)n, SF_DO_NOT_SCROLL);
-}
-
- static void
-SFhAreaSelectedCallback(Widget w, XtPointer n, XtPointer pnew)
-{
- SFDir *dir;
- int nw = (int)(long)pnew;
-
- dir = &(SFdirs[SFdirPtr + (int)(long)n]);
-
-#ifdef FEAT_GUI_NEXTAW
- if (nw < 0)
- {
- if (nw > -SFhScrollWidth)
- nw = -1;
- else
- nw = -SFcharsPerEntry;
- }
- else if (nw > 0)
- {
- if (nw < SFhScrollWidth)
- nw = 1;
- else
- nw = SFcharsPerEntry;
- }
-#endif
- nw += dir->hOrigin;
-
- if (nw > dir->nChars - SFcharsPerEntry)
- nw = dir->nChars - SFcharsPerEntry;
-
- if (nw < 0)
- nw = 0;
-
- if (dir->nChars)
- {
- float f;
-
- f = ((double) nw) / dir->nChars;
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((dir->nChars < SFcharsPerEntry) ?
- dir->nChars : SFcharsPerEntry)) / dir->nChars));
-#else
- vim_XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((dir->nChars < SFcharsPerEntry) ?
- dir->nChars : SFcharsPerEntry)) / dir->nChars),
- (double)dir->nChars);
-#endif
-
- SFhSliderMovedCallback(w, n, (XtPointer)&f);
- }
-}
-
- static void
-SFpathSliderMovedCallback(
- Widget w UNUSED,
- XtPointer client_data UNUSED,
- XtPointer nw)
-{
- SFDir *dir;
- int n;
- XawTextPosition pos;
- int SFdirPtrSave;
-
- SFdirPtrSave = SFdirPtr;
- SFdirPtr = (*(float *)nw) * SFdirEnd;
- if (SFdirPtr == SFdirPtrSave)
- return;
-
- SFdrawLists(SF_DO_SCROLL);
-
- n = 2;
- while (SFdirPtr + n >= SFdirEnd)
- n--;
-
- dir = &(SFdirs[SFdirPtr + n]);
-
- pos = dir->path - SFcurrentPath;
-
- if (!strncmp(SFcurrentPath, SFstartDir, strlen(SFstartDir)))
- {
- pos -= strlen(SFstartDir);
- if (pos < 0)
- pos = 0;
- }
-
- XawTextSetInsertionPoint(selFileField, pos);
-}
-
- static void
-SFpathAreaSelectedCallback(
- Widget w,
- XtPointer client_data UNUSED,
- XtPointer pnew)
-{
- int nw = (int)(long)pnew;
- float f;
-
-#ifdef FEAT_GUI_NEXTAW
- if (nw < 0)
- {
- if (nw > -SFpathScrollWidth)
- nw = -1;
- else
- nw = -3;
- }
- else if (nw > 0)
- {
- if (nw < SFpathScrollWidth)
- nw = 1;
- else
- nw = 3;
- }
-#endif
- nw += SFdirPtr;
-
- if (nw > SFdirEnd - 3)
- nw = SFdirEnd - 3;
-
- if (nw < 0)
- nw = 0;
-
- f = ((double) nw) / SFdirEnd;
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) / SFdirEnd));
-#else
- vim_XawScrollbarSetThumb(
- w,
- f,
- (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) / SFdirEnd),
- (double)SFdirEnd);
-#endif
-
- SFpathSliderMovedCallback(w, (XtPointer) NULL, (XtPointer)&f);
-}
-
- static Boolean
-SFworkProc(void *arg UNUSED)
-{
- SFDir *dir;
- SFEntry *entry;
-
- for (dir = &(SFdirs[SFdirEnd - 1]); dir >= SFdirs; dir--)
- {
- if (!(dir->nEntries))
- continue;
- for (entry = &(dir->entries[dir->nEntries - 1]);
- entry >= dir->entries;
- entry--)
- {
- if (!(entry->statDone))
- {
- (void)SFstatAndCheck(dir, entry);
- return False;
- }
- }
- }
-
- SFworkProcAdded = 0;
-
- return True;
-}
-
-////////////////// Dir.c
-
- static int
-SFcompareEntries(const void *p, const void *q)
-{
- return strcmp(((SFEntry *)p)->real, ((SFEntry *)q)->real);
-}
-
- static int
-SFgetDir(
- SFDir *dir)
-{
- SFEntry *result = NULL;
- int Alloc = 0;
- int i;
- DIR *dirp;
- struct dirent *dp;
- char *str;
- int len;
- int maxChars;
- stat_T statBuf;
-
- maxChars = strlen(dir->dir) - 1;
-
- dir->entries = NULL;
- dir->nEntries = 0;
- dir->nChars = 0;
-
- result = NULL;
- i = 0;
-
- dirp = opendir(".");
- if (!dirp)
- return 1;
-
- (void)mch_stat(".", &statBuf);
- dir->mtime = statBuf.st_mtime;
-
- while ((dp = readdir(dirp)))
- {
- // Ignore "." and ".."
- if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
- continue;
- if (i >= Alloc)
- {
- Alloc = 2 * (Alloc + 1);
- result = (SFEntry *) XtRealloc((char *) result,
- (unsigned) (Alloc * sizeof(SFEntry)));
- }
- result[i].statDone = 0;
- str = dp->d_name;
- len = strlen(str);
- result[i].real = XtMalloc((unsigned)(len + 2));
- (void) strcat(strcpy(result[i].real, str), " ");
- if (len > maxChars)
- maxChars = len;
- result[i].shown = result[i].real;
- i++;
- }
-
- qsort((char *) result, (size_t) i, sizeof(SFEntry), SFcompareEntries);
-
- dir->entries = result;
- dir->nEntries = i;
- dir->nChars = maxChars + 1;
-
- closedir(dirp);
-
- return 0;
-}
-
-////////////////// SFinternal.h
-
-#include <sys/param.h>
-#include <X11/cursorfont.h>
-#include <X11/Composite.h>
-#include <X11/Shell.h>
-#ifdef FEAT_GUI_NEXTAW
-# include <X11/neXtaw/Form.h>
-# include <X11/neXtaw/Command.h>
-# include <X11/neXtaw/Label.h>
-#else
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/Command.h>
-#include <X11/Xaw/Label.h>
-#endif
-
-static char *oneLineTextEditTranslations = "\
- <Key>Return: redraw-display()\n\
- Ctrl<Key>M: redraw-display()\n\
-";
-
- static void
-SFexposeList(
- Widget w UNUSED,
- XtPointer n,
- XEvent *event,
- Boolean *cont UNUSED)
-{
- if ((event->type == NoExpose) || event->xexpose.count)
- return;
-
- SFdrawList((int)(long)n, SF_DO_NOT_SCROLL);
-}
-
- static void
-SFmodVerifyCallback(
- Widget w UNUSED,
- XtPointer client_data UNUSED,
- XEvent *event,
- Boolean *cont UNUSED)
-{
- char buf[2];
-
- if ((XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1) &&
- ((*buf) == '\r'))
- SFstatus = SEL_FILE_OK;
- else
- SFstatus = SEL_FILE_TEXT;
-}
-
- static void
-SFokCallback(Widget w UNUSED, XtPointer cl UNUSED, XtPointer cd UNUSED)
-{
- SFstatus = SEL_FILE_OK;
-}
-
-static XtCallbackRec SFokSelect[] =
-{
- { SFokCallback, (XtPointer) NULL },
- { NULL, (XtPointer) NULL },
-};
-
- static void
-SFcancelCallback(Widget w UNUSED, XtPointer cl UNUSED, XtPointer cd UNUSED)
-{
- SFstatus = SEL_FILE_CANCEL;
-}
-
-static XtCallbackRec SFcancelSelect[] =
-{
- { SFcancelCallback, (XtPointer) NULL },
- { NULL, (XtPointer) NULL },
-};
-
- static void
-SFdismissAction(
- Widget w UNUSED,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- if (event->type == ClientMessage
- && (Atom)event->xclient.data.l[0] != SFwmDeleteWindow)
- return;
-
- SFstatus = SEL_FILE_CANCEL;
-}
-
-static char *wmDeleteWindowTranslation = "\
- <Message>WM_PROTOCOLS: SelFileDismiss()\n\
-";
-
-static XtActionsRec actions[] =
-{
- {"SelFileDismiss", SFdismissAction},
-};
-
- static void
-SFsetColors(
- guicolor_T bg,
- guicolor_T fg,
- guicolor_T scroll_bg,
- guicolor_T scroll_fg)
-{
- if (selFileForm)
- {
- XtVaSetValues(selFileForm, XtNbackground, bg,
- XtNforeground, fg,
- XtNborderColor, bg,
- NULL);
- }
- {
- int i;
-
- for (i = 0; i < 3; ++i)
- {
- if (selFileLists[i])
- {
- XtVaSetValues(selFileLists[i], XtNbackground, bg,
- XtNforeground, fg,
- XtNborderColor, fg,
- NULL);
- }
- }
- }
- if (selFileOK)
- {
- XtVaSetValues(selFileOK, XtNbackground, bg,
- XtNforeground, fg,
- XtNborderColor, fg,
- NULL);
- }
- if (selFileCancel)
- {
- XtVaSetValues(selFileCancel, XtNbackground, bg,
- XtNforeground, fg,
- XtNborderColor, fg,
- NULL);
- }
- if (selFilePrompt)
- {
- XtVaSetValues(selFilePrompt, XtNbackground, bg,
- XtNforeground, fg,
- NULL);
- }
- if (gui.dpy)
- {
- XSetBackground(gui.dpy, SFtextGC, bg);
- XSetForeground(gui.dpy, SFtextGC, fg);
- XSetForeground(gui.dpy, SFlineGC, fg);
-
- // This is an xor GC, so combine the fg and background
- XSetBackground(gui.dpy, SFinvertGC, fg ^ bg);
- XSetForeground(gui.dpy, SFinvertGC, fg ^ bg);
- }
- if (selFileHScroll)
- {
- XtVaSetValues(selFileHScroll, XtNbackground, scroll_bg,
- XtNforeground, scroll_fg,
- XtNborderColor, fg,
- NULL);
- }
- {
- int i;
-
- for (i = 0; i < 3; i++)
- {
- XtVaSetValues(selFileVScrolls[i], XtNbackground, scroll_bg,
- XtNforeground, scroll_fg,
- XtNborderColor, fg,
- NULL);
- XtVaSetValues(selFileHScrolls[i], XtNbackground, scroll_bg,
- XtNforeground, scroll_fg,
- XtNborderColor, fg,
- NULL);
- }
- }
-}
-
- static void
-SFcreateWidgets(
- Widget toplevel,
- char *prompt,
- char *ok,
- char *cancel)
-{
- Cardinal n;
- int listWidth, listHeight;
- int listSpacing = 10;
- int scrollThickness = 15;
- int hScrollX, hScrollY;
- int vScrollX, vScrollY;
-
- selFile = XtVaAppCreateShell("selFile", "SelFile",
- transientShellWidgetClass, SFdisplay,
- XtNtransientFor, toplevel,
- XtNtitle, prompt,
- NULL);
-
- // Add WM_DELETE_WINDOW protocol
- XtAppAddActions(XtWidgetToApplicationContext(selFile),
- actions, XtNumber(actions));
- XtOverrideTranslations(selFile,
- XtParseTranslationTable(wmDeleteWindowTranslation));
-
- selFileForm = XtVaCreateManagedWidget("selFileForm",
- formWidgetClass, selFile,
- XtNdefaultDistance, 30,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFback,
- NULL);
-
- selFilePrompt = XtVaCreateManagedWidget("selFilePrompt",
- labelWidgetClass, selFileForm,
- XtNlabel, prompt,
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNborderWidth, 0,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- NULL);
-
- /*
- XtVaGetValues(selFilePrompt,
- XtNforeground, &SFfore,
- XtNbackground, &SFback,
- NULL);
- */
-
- SFinitFont();
-
- SFentryWidth = SFbesideText + SFcharsPerEntry * SFcharWidth +
- SFbesideText;
- SFentryHeight = SFaboveAndBelowText + SFcharHeight +
- SFaboveAndBelowText;
-
- listWidth = SFlineToTextH + SFentryWidth + SFlineToTextH + 1 +
- scrollThickness;
- listHeight = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
- SFlineToTextV + SFlistSize * SFentryHeight +
- SFlineToTextV + 1 + scrollThickness;
-
- SFpathScrollWidth = 3 * listWidth + 2 * listSpacing + 4;
-
- hScrollX = -1;
- hScrollY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
- SFlineToTextV + SFlistSize * SFentryHeight +
- SFlineToTextV;
- SFhScrollWidth = SFlineToTextH + SFentryWidth + SFlineToTextH;
-
- vScrollX = SFlineToTextH + SFentryWidth + SFlineToTextH;
- vScrollY = SFlineToTextV + SFentryHeight + SFlineToTextV;
- SFvScrollHeight = SFlineToTextV + SFlistSize * SFentryHeight +
- SFlineToTextV;
-
- SFupperX = SFlineToTextH + SFentryWidth + SFlineToTextH - 1;
- SFlowerY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
- SFlineToTextV;
- SFupperY = SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
- SFlineToTextV + SFlistSize * SFentryHeight - 1;
-
- SFtextX = SFlineToTextH + SFbesideText;
- SFtextYoffset = SFlowerY + SFaboveAndBelowText + SFcharAscent;
-
- SFsegs[0].x1 = 0;
- SFsegs[0].y1 = vScrollY;
- SFsegs[0].x2 = vScrollX - 1;
- SFsegs[0].y2 = vScrollY;
- SFsegs[1].x1 = vScrollX;
- SFsegs[1].y1 = 0;
- SFsegs[1].x2 = vScrollX;
- SFsegs[1].y2 = vScrollY - 1;
-
- SFcompletionSegs[0].x1 = SFcompletionSegs[0].x2 = SFlineToTextH;
- SFcompletionSegs[1].x1 = SFcompletionSegs[1].x2 =
- SFlineToTextH + SFentryWidth - 1;
-
- selFileField = XtVaCreateManagedWidget("selFileField",
- asciiTextWidgetClass, selFileForm,
- XtNwidth, 3 * listWidth + 2 * listSpacing + 4,
- XtNborderColor, SFfore,
- XtNfromVert, selFilePrompt,
- XtNvertDistance, 10,
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNstring, SFtextBuffer,
- XtNlength, MAXPATHL,
- XtNeditType, XawtextEdit,
- XtNwrap, XawtextWrapWord,
- XtNresize, XawtextResizeHeight,
- XtNuseStringInPlace, True,
- NULL);
-
- XtOverrideTranslations(selFileField,
- XtParseTranslationTable(oneLineTextEditTranslations));
- XtSetKeyboardFocus(selFileForm, selFileField);
-
- selFileHScroll = XtVaCreateManagedWidget("selFileHScroll",
-#ifdef FEAT_GUI_NEXTAW
- scrollbarWidgetClass, selFileForm,
-#else
- vim_scrollbarWidgetClass, selFileForm,
-#endif
- XtNorientation, XtorientHorizontal,
- XtNwidth, SFpathScrollWidth,
- XtNheight, scrollThickness,
- XtNborderColor, SFfore,
- XtNfromVert, selFileField,
- XtNvertDistance, 30,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNforeground, gui.scroll_fg_pixel,
- XtNbackground, gui.scroll_bg_pixel,
-#ifndef FEAT_GUI_NEXTAW
- XtNlimitThumb, 1,
-#endif
- NULL);
-
- XtAddCallback(selFileHScroll, XtNjumpProc,
- (XtCallbackProc) SFpathSliderMovedCallback, (XtPointer)NULL);
- XtAddCallback(selFileHScroll, XtNscrollProc,
- (XtCallbackProc) SFpathAreaSelectedCallback, (XtPointer)NULL);
-
- selFileLists[0] = XtVaCreateManagedWidget("selFileList1",
- compositeWidgetClass, selFileForm,
- XtNwidth, listWidth,
- XtNheight, listHeight,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFfore,
- XtNfromVert, selFileHScroll,
- XtNvertDistance, 10,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- NULL);
-
- selFileLists[1] = XtVaCreateManagedWidget("selFileList2",
- compositeWidgetClass, selFileForm,
- XtNwidth, listWidth,
- XtNheight, listHeight,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFfore,
- XtNfromHoriz, selFileLists[0],
- XtNfromVert, selFileHScroll,
- XtNhorizDistance, listSpacing,
- XtNvertDistance, 10,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- NULL);
-
- selFileLists[2] = XtVaCreateManagedWidget("selFileList3",
- compositeWidgetClass, selFileForm,
- XtNwidth, listWidth,
- XtNheight, listHeight,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFfore,
- XtNfromHoriz, selFileLists[1],
- XtNfromVert, selFileHScroll,
- XtNhorizDistance, listSpacing,
- XtNvertDistance, 10,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- NULL);
-
- for (n = 0; n < 3; n++)
- {
- selFileVScrolls[n] = XtVaCreateManagedWidget("selFileVScroll",
-#ifdef FEAT_GUI_NEXTAW
- scrollbarWidgetClass, selFileLists[n],
-#else
- vim_scrollbarWidgetClass, selFileLists[n],
-#endif
- XtNx, vScrollX,
- XtNy, vScrollY,
- XtNwidth, scrollThickness,
- XtNheight, SFvScrollHeight,
- XtNborderColor, SFfore,
- XtNforeground, gui.scroll_fg_pixel,
- XtNbackground, gui.scroll_bg_pixel,
-#ifndef FEAT_GUI_NEXTAW
- XtNlimitThumb, 1,
-#endif
- NULL);
-
- XtAddCallback(selFileVScrolls[n], XtNjumpProc,
- (XtCallbackProc)SFvFloatSliderMovedCallback,
- (XtPointer)(long_u)n);
- XtAddCallback(selFileVScrolls[n], XtNscrollProc,
- (XtCallbackProc)SFvAreaSelectedCallback, (XtPointer)(long_u)n);
-
- selFileHScrolls[n] = XtVaCreateManagedWidget("selFileHScroll",
-#ifdef FEAT_GUI_NEXTAW
- scrollbarWidgetClass, selFileLists[n],
-#else
- vim_scrollbarWidgetClass, selFileLists[n],
-#endif
- XtNorientation, XtorientHorizontal,
- XtNx, hScrollX,
- XtNy, hScrollY,
- XtNwidth, SFhScrollWidth,
- XtNheight, scrollThickness,
- XtNborderColor, SFfore,
- XtNforeground, gui.scroll_fg_pixel,
- XtNbackground, gui.scroll_bg_pixel,
-#ifndef FEAT_GUI_NEXTAW
- XtNlimitThumb, 1,
-#endif
- NULL);
-
- XtAddCallback(selFileHScrolls[n], XtNjumpProc,
- (XtCallbackProc)SFhSliderMovedCallback,
- (XtPointer)(long_u)n);
- XtAddCallback(selFileHScrolls[n], XtNscrollProc,
- (XtCallbackProc)SFhAreaSelectedCallback, (XtPointer)(long_u)n);
- }
-
- selFileOK = XtVaCreateManagedWidget("selFileOK",
- commandWidgetClass, selFileForm,
- XtNlabel, ok,
- XtNresizable, True,
- XtNcallback, SFokSelect,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFfore,
- XtNfromHoriz, selFileLists[0],
- XtNfromVert, selFileLists[0],
- XtNvertDistance, 30,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- NULL);
-
- selFileCancel = XtVaCreateManagedWidget("selFileCancel",
- commandWidgetClass, selFileForm,
- XtNlabel, cancel,
- XtNresizable, True,
- XtNcallback, SFcancelSelect,
- XtNforeground, SFfore,
- XtNbackground, SFback,
- XtNborderColor, SFfore,
- XtNfromHoriz, selFileOK,
- XtNfromVert, selFileLists[0],
- XtNhorizDistance, 30,
- XtNvertDistance, 30,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- NULL);
-
- XtSetMappedWhenManaged(selFile, False);
- XtRealizeWidget(selFile);
-
- // Add WM_DELETE_WINDOW protocol
- SFwmDeleteWindow = XInternAtom(SFdisplay, "WM_DELETE_WINDOW", False);
- XSetWMProtocols(SFdisplay, XtWindow(selFile), &SFwmDeleteWindow, 1);
-
- SFcreateGC();
-
- for (n = 0; n < 3; n++)
- {
- XtAddEventHandler(selFileLists[n], ExposureMask, True,
- (XtEventHandler)SFexposeList, (XtPointer)(long_u)n);
- XtAddEventHandler(selFileLists[n], EnterWindowMask, False,
- (XtEventHandler)SFenterList, (XtPointer)(long_u)n);
- XtAddEventHandler(selFileLists[n], LeaveWindowMask, False,
- (XtEventHandler)SFleaveList, (XtPointer)(long_u)n);
- XtAddEventHandler(selFileLists[n], PointerMotionMask, False,
- (XtEventHandler)SFmotionList, (XtPointer)(long_u)n);
- XtAddEventHandler(selFileLists[n], ButtonPressMask, False,
- (XtEventHandler)SFbuttonPressList, (XtPointer)(long_u)n);
- XtAddEventHandler(selFileLists[n], ButtonReleaseMask, False,
- (XtEventHandler)SFbuttonReleaseList, (XtPointer)(long_u)n);
- }
-
- XtAddEventHandler(selFileField, KeyPressMask, False,
- SFmodVerifyCallback, (XtPointer)NULL);
-
- SFapp = XtWidgetToApplicationContext(selFile);
-}
-
- static void
-SFtextChanged(void)
-{
-#if defined(FEAT_XFONTSET) && defined(XtNinternational)
- if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
- {
- wchar_t *wcbuf=(wchar_t *)SFtextBuffer;
-
- if ((wcbuf[0] == L'/') || (wcbuf[0] == L'~'))
- {
- (void) wcstombs(SFcurrentPath, wcbuf, MAXPATHL);
- SFtextPos = XawTextGetInsertionPoint(selFileField);
- }
- else
- {
- strcpy(SFcurrentPath, SFstartDir);
- (void) wcstombs(SFcurrentPath + strlen(SFcurrentPath), wcbuf, MAXPATHL);
-
- SFtextPos = XawTextGetInsertionPoint(selFileField) + strlen(SFstartDir);
- }
- }
- else
-#endif
- if ((SFtextBuffer[0] == '/') || (SFtextBuffer[0] == '~'))
- {
- (void) strcpy(SFcurrentPath, SFtextBuffer);
- SFtextPos = XawTextGetInsertionPoint(selFileField);
- }
- else
- {
- (void) strcat(strcpy(SFcurrentPath, SFstartDir), SFtextBuffer);
-
- SFtextPos = XawTextGetInsertionPoint(selFileField) + strlen(SFstartDir);
- }
-
- if (!SFworkProcAdded)
- {
- (void) XtAppAddWorkProc(SFapp, (XtWorkProc)SFworkProc, NULL);
- SFworkProcAdded = 1;
- }
-
- SFupdatePath();
-}
-
- static char *
-SFgetText(void)
-{
-#if defined(FEAT_XFONTSET) && defined(XtNinternational)
- char *buf;
-
- if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
- {
- wchar_t *wcbuf;
- int mbslength;
-
- XtVaGetValues(selFileField,
- XtNstring, &wcbuf,
- NULL);
- mbslength = wcstombs(NULL, wcbuf, 0);
- // Hack: some broken wcstombs() returns zero, just get a large buffer
- if (mbslength == 0 && wcbuf != NULL && wcbuf[0] != 0)
- mbslength = MAXPATHL;
- buf=(char *)XtMalloc(mbslength + 1);
- wcstombs(buf, wcbuf, mbslength +1);
- return buf;
- }
-#endif
- return (char *)vim_strsave((char_u *)SFtextBuffer);
-}
-
- static void
-SFprepareToReturn(void)
-{
- SFstatus = SEL_FILE_NULL;
- XtRemoveGrab(selFile);
- XtUnmapWidget(selFile);
- XtRemoveTimeOut(SFdirModTimerId);
- if (SFchdir(SFstartDir))
- {
- emsg(_(e_vim_selfile_cant_return_to_current_directory));
- SFstatus = SEL_FILE_CANCEL;
- }
-}
-
- char *
-vim_SelFile(
- Widget toplevel,
- char *prompt,
- char *init_path,
- int (*show_entry)(),
- int x,
- int y,
- guicolor_T fg,
- guicolor_T bg,
- guicolor_T scroll_fg,
- guicolor_T scroll_bg) // The "Scrollbar" group colors
-{
- static int firstTime = 1;
- XEvent event;
- char *name_return;
-
- if (prompt == NULL)
- prompt = _("Pathname:");
- SFfore = fg;
- SFback = bg;
-
- if (mch_dirname((char_u *)SFstartDir, MAXPATHL) == FAIL)
- {
- emsg(_(e_vim_selfile_cant_get_current_directory));
- return NULL;
- }
-
- if (firstTime)
- {
- firstTime = 0;
- SFdisplay = XtDisplay(toplevel);
- SFcreateWidgets(toplevel, prompt, _("OK"), _("Cancel"));
- }
- else
- {
- XtVaSetValues(selFilePrompt, XtNlabel, prompt, NULL);
- XtVaSetValues(selFile, XtNtitle, prompt, NULL);
- SFsetColors(bg, fg, scroll_bg, scroll_fg);
- }
-
- XtVaSetValues(selFile, XtNx, x, XtNy, y, NULL);
- XtMapWidget(selFile);
-
- (void)strcat(SFstartDir, "/");
- (void)strcpy(SFcurrentDir, SFstartDir);
-
- if (init_path)
- {
- if (init_path[0] == '/')
- {
- (void)strcpy(SFcurrentPath, init_path);
- if (strncmp(SFcurrentPath, SFstartDir, strlen(SFstartDir)))
- SFsetText(SFcurrentPath);
- else
- SFsetText(&(SFcurrentPath[strlen(SFstartDir)]));
- }
- else
- {
- (void)strcat(strcpy(SFcurrentPath, SFstartDir), init_path);
- SFsetText(&(SFcurrentPath[strlen(SFstartDir)]));
- }
- }
- else
- (void)strcpy(SFcurrentPath, SFstartDir);
-
- SFfunc = show_entry;
-
- SFtextChanged();
-
- XtAddGrab(selFile, True, True);
-
- SFdirModTimerId = XtAppAddTimeOut(SFapp, (unsigned long) 1000,
- SFdirModTimer, (XtPointer) NULL);
-
- for (;;)
- {
- XtAppNextEvent(SFapp, &event);
- XtDispatchEvent(&event);
- switch (SFstatus)
- {
- case SEL_FILE_TEXT:
- SFstatus = SEL_FILE_NULL;
- SFtextChanged();
- break;
- case SEL_FILE_OK:
- name_return = SFgetText();
- SFprepareToReturn();
- return name_return;
- case SEL_FILE_CANCEL:
- SFprepareToReturn();
- return NULL;
- case SEL_FILE_NULL:
- break;
- }
- }
-}
-#endif // FEAT_BROWSE
diff --git a/src/gui_at_sb.c b/src/gui_at_sb.c
deleted file mode 100644
index 0a68210..0000000
--- a/src/gui_at_sb.c
+++ /dev/null
@@ -1,1192 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4 noet: */
-/*
- * MODIFIED ATHENA SCROLLBAR (USING ARROWHEADS AT ENDS OF TRAVEL)
- * Modifications Copyright 1992 by Mitch Trachtenberg
- * Rights, permissions, and disclaimer of warranty are as in the DEC and MIT
- * notice below.
- * $XConsortium: Scrollbar.c,v 1.72 94/04/17 20:12:40 kaleb Exp $
- */
-
-/*
- * Modified for Vim by Bill Foster and Bram Moolenaar
- */
-
-/*
-
-Copyright (c) 1987, 1988, 1994 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X
-CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 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 X Consortium 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 X Consortium.
-
-Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-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 not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL
-BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
-OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-*/
-
-// ScrollBar.c
-// created by weissman, Mon Jul 7 13:20:03 1986
-// converted by swick, Thu Aug 27 1987
-
-#include "vim.h"
-
-#include <X11/IntrinsicP.h>
-#include <X11/StringDefs.h>
-
-#include <X11/Xaw/XawInit.h>
-#include "gui_at_sb.h"
-
-#include <X11/Xmu/Drawing.h>
-
-// Private definitions.
-
-static char defaultTranslations[] =
- "<Btn1Down>: NotifyScroll()\n\
- <Btn2Down>: MoveThumb() NotifyThumb()\n\
- <Btn3Down>: NotifyScroll()\n\
- <Btn4Down>: ScrollOneLineUp()\n\
- Shift<Btn4Down>: ScrollPageUp()\n\
- <Btn5Down>: ScrollOneLineDown()\n\
- Shift<Btn5Down>: ScrollPageDown()\n\
- <Btn1Motion>: HandleThumb()\n\
- <Btn3Motion>: HandleThumb()\n\
- <Btn2Motion>: MoveThumb() NotifyThumb()\n\
- <BtnUp>: EndScroll()";
-
-static float floatZero = 0.0;
-
-#define Offset(field) XtOffsetOf(ScrollbarRec, field)
-
-static XtResource resources[] =
-{
- {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
- Offset(scrollbar.length), XtRImmediate, (XtPointer) 1},
- {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
- Offset(scrollbar.thickness), XtRImmediate, (XtPointer) 14},
- {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
- Offset(scrollbar.orientation), XtRImmediate, (XtPointer) XtorientVertical},
- {XtNscrollProc, XtCCallback, XtRCallback, sizeof(XtPointer),
- Offset(scrollbar.scrollProc), XtRCallback, NULL},
- {XtNthumbProc, XtCCallback, XtRCallback, sizeof(XtPointer),
- Offset(scrollbar.thumbProc), XtRCallback, NULL},
- {XtNjumpProc, XtCCallback, XtRCallback, sizeof(XtPointer),
- Offset(scrollbar.jumpProc), XtRCallback, NULL},
- {XtNthumb, XtCThumb, XtRBitmap, sizeof(Pixmap),
- Offset(scrollbar.thumb), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
- {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
- Offset(scrollbar.foreground), XtRString, XtDefaultForeground},
- {XtNshown, XtCShown, XtRFloat, sizeof(float),
- Offset(scrollbar.shown), XtRFloat, (XtPointer)&floatZero},
- {XtNtopOfThumb, XtCTopOfThumb, XtRFloat, sizeof(float),
- Offset(scrollbar.top), XtRFloat, (XtPointer)&floatZero},
- {XtNmaxOfThumb, XtCMaxOfThumb, XtRFloat, sizeof(float),
- Offset(scrollbar.max), XtRFloat, (XtPointer)&floatZero},
- {XtNminimumThumb, XtCMinimumThumb, XtRDimension, sizeof(Dimension),
- Offset(scrollbar.min_thumb), XtRImmediate, (XtPointer) 7},
- {XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension),
- Offset(scrollbar.shadow_width), XtRImmediate, (XtPointer) 1},
- {XtNtopShadowPixel, XtCTopShadowPixel, XtRPixel, sizeof(Pixel),
- Offset(scrollbar.top_shadow_pixel), XtRString, XtDefaultBackground},
- {XtNbottomShadowPixel, XtCBottomShadowPixel, XtRPixel, sizeof(Pixel),
- Offset(scrollbar.bot_shadow_pixel), XtRString, XtDefaultForeground},
- {XtNlimitThumb, XtCLimitThumb, XtRBool, sizeof(Bool),
- Offset(scrollbar.limit_thumb), XtRImmediate, (XtPointer)0}
-};
-#undef Offset
-
-static void ClassInitialize(void);
-static void Initialize(Widget, Widget, ArgList, Cardinal *);
-static void Destroy(Widget);
-static void Realize(Widget, Mask *, XSetWindowAttributes *);
-static void Resize(Widget);
-static void Redisplay(Widget, XEvent *, Region);
-static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
-
-static void HandleThumb(Widget, XEvent *, String *, Cardinal *);
-static void MoveThumb(Widget, XEvent *, String *, Cardinal *);
-static void NotifyThumb(Widget, XEvent *, String *, Cardinal *);
-static void NotifyScroll(Widget, XEvent *, String *, Cardinal *);
-static void EndScroll(Widget, XEvent *, String *, Cardinal *);
-static void ScrollOneLineUp(Widget, XEvent *, String *, Cardinal *);
-static void ScrollOneLineDown(Widget, XEvent *, String *, Cardinal *);
-static void ScrollPageUp(Widget, XEvent *, String *, Cardinal *);
-static void ScrollPageDown(Widget, XEvent *, String *, Cardinal *);
-static void ScrollSome(Widget w, XEvent *event, int call_data);
-static void _Xaw3dDrawShadows(Widget, XEvent *, Region, int);
-static void AllocTopShadowGC(Widget);
-static void AllocBotShadowGC(Widget);
-
-static XtActionsRec actions[] =
-{
- {"HandleThumb", HandleThumb},
- {"MoveThumb", MoveThumb},
- {"NotifyThumb", NotifyThumb},
- {"NotifyScroll", NotifyScroll},
- {"EndScroll", EndScroll},
- {"ScrollOneLineUp", ScrollOneLineUp},
- {"ScrollOneLineDown", ScrollOneLineDown},
- {"ScrollPageUp", ScrollPageUp},
- {"ScrollPageDown", ScrollPageDown}
-};
-
-
-ScrollbarClassRec vim_scrollbarClassRec =
-{
- { // core fields
- /* superclass */ (WidgetClass) &simpleClassRec,
- /* class_name */ "Scrollbar",
- /* size */ sizeof(ScrollbarRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_init */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ actions,
- /* num_actions */ XtNumber(actions),
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure*/ TRUE,
- /* compress_enterleave*/ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ Redisplay,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ defaultTranslations,
- /* query_geometry */ XtInheritQueryGeometry,
- /* display_accelerator*/ XtInheritDisplayAccelerator,
- /* extension */ NULL
- },
- { // simple fields
- /* change_sensitive */ XtInheritChangeSensitive,
-#ifndef OLDXAW
- /* extension */ NULL
-#endif
- },
- { // scrollbar fields
- /* empty */ 0
- }
-};
-
-WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec;
-
-#define NoButton -1
-#define PICKLENGTH(widget, x, y) \
- ((widget->scrollbar.orientation == XtorientHorizontal) ? (x) : (y))
-#define AT_MIN(x,y) ((x) < (y) ? (x) : (y))
-#define AT_MAX(x,y) ((x) > (y) ? (x) : (y))
-
-#define LINE_DELAY 300
-#define PAGE_DELAY 300
-#define LINE_REPEAT 50
-#define PAGE_REPEAT 250
-
- static void
-ClassInitialize(void)
-{
- XawInitializeWidgetSet();
- XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
- (XtConvertArgList)NULL, (Cardinal)0 );
-}
-
-#define MARGIN(sbw) (sbw)->scrollbar.thickness + (sbw)->scrollbar.shadow_width
-
- static void
-FillArea(
- ScrollbarWidget sbw,
- Position top,
- Position bottom,
- int fill,
- int draw_shadow)
-{
- int tlen = bottom - top; // length of thumb in pixels
- int sw, margin, floor;
- int lx, ly, lw, lh;
-
- if (bottom <= 0 || bottom <= top)
- return;
- sw = sbw->scrollbar.shadow_width;
- if (sw < 0)
- sw = 0;
- margin = MARGIN (sbw);
- floor = sbw->scrollbar.length - margin + 2;
-
- if (sbw->scrollbar.orientation == XtorientHorizontal)
- {
- lx = ((top < margin) ? margin : top);
- ly = sw;
- lw = (((top + tlen) > floor) ? floor - top : tlen);
- lh = sbw->core.height - 2 * sw;
- }
- else
- {
- lx = sw;
- ly = ((top < margin) ? margin : top);
- lw = sbw->core.width - 2 * sw;
- lh = (((top + tlen) > floor) ? floor - top : tlen);
- }
- if (lh <= 0 || lw <= 0)
- return;
-
- if (draw_shadow)
- {
- if (!(sbw->scrollbar.orientation == XtorientHorizontal))
- {
- // Top border
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- lx, ly, lx + lw - 1, ly);
-
- // Bottom border
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
- }
- else
- {
- // Left border
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- lx, ly, lx, ly + lh - 1);
-
- // Right border
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
- }
- return;
- }
-
- if (fill)
- {
- XFillRectangle(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
- sbw->scrollbar.gc,
- lx, ly, (unsigned int) lw, (unsigned int) lh);
-
- if (!(sbw->scrollbar.orientation == XtorientHorizontal))
- {
- // Left border
- XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- lx, ly, lx, ly + lh - 1);
-
- // Right border
- XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
- }
- else
- {
- // Top border
- XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- lx, ly, lx + lw - 1, ly);
-
- // Bottom border
- XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
- }
- }
- else
- {
- XClearArea(XtDisplay((Widget) sbw), XtWindow((Widget) sbw),
- lx, ly, (unsigned int) lw, (unsigned int) lh, FALSE);
- }
-}
-
-/*
- * Paint the thumb in the area specified by sbw->top and
- * sbw->shown. The old area is erased. The painting and
- * erasing is done cleverly so that no flickering will occur.
- */
- static void
-PaintThumb(ScrollbarWidget sbw)
-{
- Position oldtop, oldbot, newtop, newbot;
- Dimension margin, tzl;
-
- margin = MARGIN (sbw);
- tzl = sbw->scrollbar.length - 2 * margin;
- newtop = margin + (int)(tzl * sbw->scrollbar.top);
- newbot = newtop + (int)(tzl * sbw->scrollbar.shown) + 1;
- if (newbot < newtop + (int)sbw->scrollbar.min_thumb)
- newbot = newtop + sbw->scrollbar.min_thumb;
-
- oldtop = sbw->scrollbar.topLoc;
- oldbot = oldtop + sbw->scrollbar.shownLength;
- sbw->scrollbar.topLoc = newtop;
- sbw->scrollbar.shownLength = newbot - newtop;
- if (XtIsRealized ((Widget) sbw))
- {
- if (newtop < oldtop)
- FillArea(sbw, newtop, AT_MIN(newbot, oldtop+1),1,0);
- if (newtop > oldtop)
- FillArea(sbw, oldtop, AT_MIN(newtop, oldbot ),0,0);
- if (newbot < oldbot)
- FillArea(sbw, AT_MAX(newbot, oldtop), oldbot, 0,0);
- if (newbot > oldbot)
- FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot, 1,0);
-
- // Only draw the missing shadows
- FillArea(sbw, newtop, newbot, 0, 1);
- }
-}
-
- static void
-PaintArrows(ScrollbarWidget sbw)
-{
- XPoint point[6];
- Dimension thickness = sbw->scrollbar.thickness - 1;
- Dimension size;
- Dimension off;
-
- if (XtIsRealized((Widget) sbw))
- {
- if ((int)thickness * 2 > (int)sbw->scrollbar.length)
- {
- size = sbw->scrollbar.length / 2;
- off = (int)(thickness - size) / 2;
- }
- else
- {
- size = thickness;
- off = 0;
- }
- point[0].x = off + sbw->scrollbar.shadow_width;
- point[0].y = size;
- point[1].x = thickness - off - sbw->scrollbar.shadow_width;
- point[1].y = size;
- point[2].x = thickness / 2;
- point[2].y = sbw->scrollbar.shadow_width;
-
- point[3].x = off + sbw->scrollbar.shadow_width;
- point[3].y = sbw->scrollbar.length - size;
- point[4].x = thickness - off - sbw->scrollbar.shadow_width;
- point[4].y = sbw->scrollbar.length - size;
- point[5].x = thickness / 2;
- point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1;
-
- // horizontal arrows require that x and y coordinates be swapped
- if (sbw->scrollbar.orientation == XtorientHorizontal)
- {
- int n;
- int swap;
- for (n = 0; n < 6; n++)
- {
- swap = point[n].x;
- point[n].x = point[n].y;
- point[n].y = swap;
- }
- }
- // draw the up/left arrow
- XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.gc,
- point, 3,
- Convex, CoordModeOrigin);
- XDrawLines (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- point, 3,
- CoordModeOrigin);
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- point[0].x, point[0].y,
- point[2].x, point[2].y);
- // draw the down/right arrow
- XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.gc,
- point+3, 3,
- Convex, CoordModeOrigin);
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- point[3].x, point[3].y,
- point[4].x, point[4].y);
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.top_shadow_GC,
- point[3].x, point[3].y,
- point[5].x, point[5].y);
- XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
- sbw->scrollbar.bot_shadow_GC,
- point[4].x, point[4].y,
- point[5].x, point[5].y);
- }
-}
-
- static void
-Destroy(Widget w)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- if (sbw->scrollbar.timer_id != (XtIntervalId) 0)
- XtRemoveTimeOut (sbw->scrollbar.timer_id);
- XtReleaseGC(w, sbw->scrollbar.gc);
- XtReleaseGC(w, sbw->scrollbar.top_shadow_GC);
- XtReleaseGC(w, sbw->scrollbar.bot_shadow_GC);
-}
-
- static void
-CreateGC(Widget w)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- XGCValues gcValues;
- XtGCMask mask;
- unsigned int depth = 1;
-
- if (sbw->scrollbar.thumb == XtUnspecifiedPixmap)
- {
- sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
- (Pixel) 1, (Pixel) 0, depth);
- }
- else if (sbw->scrollbar.thumb != None)
- {
- Window root;
- int x, y;
- unsigned int width, height, bw;
-
- if (XGetGeometry (XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
- &width, &height, &bw, &depth) == 0)
- emsg(_("Scrollbar Widget: Could not get geometry of thumb pixmap."));
- }
-
- gcValues.foreground = sbw->scrollbar.foreground;
- gcValues.background = sbw->core.background_pixel;
- mask = GCForeground | GCBackground;
-
- if (sbw->scrollbar.thumb != None)
- {
- gcValues.fill_style = FillSolid;
- mask |= GCFillStyle;
- }
- // the creation should be non-caching, because
- // we now set and clear clip masks on the gc returned
- sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
-}
-
- static void
-SetDimensions(ScrollbarWidget sbw)
-{
- if (sbw->scrollbar.orientation == XtorientVertical)
- {
- sbw->scrollbar.length = sbw->core.height;
- sbw->scrollbar.thickness = sbw->core.width;
- }
- else
- {
- sbw->scrollbar.length = sbw->core.width;
- sbw->scrollbar.thickness = sbw->core.height;
- }
-}
-
- static void
-Initialize(
- Widget request UNUSED, // what the client asked for
- Widget new, // what we're going to give him
- ArgList args UNUSED,
- Cardinal *num_args UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) new;
-
- CreateGC(new);
- AllocTopShadowGC(new);
- AllocBotShadowGC(new);
-
- if (sbw->core.width == 0)
- sbw->core.width = (sbw->scrollbar.orientation == XtorientVertical)
- ? sbw->scrollbar.thickness : sbw->scrollbar.length;
-
- if (sbw->core.height == 0)
- sbw->core.height = (sbw->scrollbar.orientation == XtorientHorizontal)
- ? sbw->scrollbar.thickness : sbw->scrollbar.length;
-
- SetDimensions(sbw);
- sbw->scrollbar.scroll_mode = SMODE_NONE;
- sbw->scrollbar.timer_id = (XtIntervalId)0;
- sbw->scrollbar.topLoc = 0;
- sbw->scrollbar.shownLength = sbw->scrollbar.min_thumb;
-}
-
- static void
-Realize(
- Widget w,
- Mask *valueMask,
- XSetWindowAttributes *attributes)
-{
- // The Simple widget actually stuffs the value in the valuemask.
- (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize)
- (w, valueMask, attributes);
-}
-
- static Boolean
-SetValues(
- Widget current, // what I am
- Widget request UNUSED, // what he wants me to be
- Widget desired, // what I will become
- ArgList args UNUSED,
- Cardinal *num_args UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) current;
- ScrollbarWidget dsbw = (ScrollbarWidget) desired;
- Boolean redraw = FALSE;
-
-/*
- * If these values are outside the acceptable range ignore them...
- */
- if (dsbw->scrollbar.top < 0.0 || dsbw->scrollbar.top > 1.0)
- dsbw->scrollbar.top = sbw->scrollbar.top;
-
- if (dsbw->scrollbar.shown < 0.0 || dsbw->scrollbar.shown > 1.0)
- dsbw->scrollbar.shown = sbw->scrollbar.shown;
-
-/*
- * Change colors and stuff...
- */
- if (XtIsRealized(desired))
- {
- if (sbw->scrollbar.foreground != dsbw->scrollbar.foreground ||
- sbw->core.background_pixel != dsbw->core.background_pixel ||
- sbw->scrollbar.thumb != dsbw->scrollbar.thumb)
- {
- XtReleaseGC(desired, sbw->scrollbar.gc);
- CreateGC (desired);
- redraw = TRUE;
- }
- if (sbw->scrollbar.top != dsbw->scrollbar.top ||
- sbw->scrollbar.shown != dsbw->scrollbar.shown)
- redraw = TRUE;
- }
- return redraw;
-}
-
- static void
-Resize(Widget w)
-{
- // ForgetGravity has taken care of background, but thumb may
- // have to move as a result of the new size.
- SetDimensions ((ScrollbarWidget) w);
- Redisplay(w, (XEvent*) NULL, (Region)NULL);
-}
-
-
- static void
-Redisplay(Widget w, XEvent *event, Region region)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- int x, y;
- unsigned int width, height;
-
- _Xaw3dDrawShadows(w, event, region, FALSE);
-
- if (sbw->scrollbar.orientation == XtorientHorizontal)
- {
- x = sbw->scrollbar.topLoc;
- y = 1;
- width = sbw->scrollbar.shownLength;
- height = sbw->core.height - 2;
- }
- else
- {
- x = 1;
- y = sbw->scrollbar.topLoc;
- width = sbw->core.width - 2;
- height = sbw->scrollbar.shownLength;
- }
- if (region == NULL ||
- XRectInRegion (region, x, y, width, height) != RectangleOut)
- {
- // Forces entire thumb to be painted.
- sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1);
- PaintThumb (sbw);
- }
- // we'd like to be region aware here!!!!
- PaintArrows(sbw);
-}
-
-
- static Boolean
-CompareEvents(XEvent *oldEvent, XEvent *newEvent)
-{
-#define Check(field) \
- do { \
- if (newEvent->field != oldEvent->field) \
- return False; \
- } while (0)
-
- Check(xany.display);
- Check(xany.type);
- Check(xany.window);
-
- switch (newEvent->type)
- {
- case MotionNotify:
- Check(xmotion.state);
- break;
- case ButtonPress:
- case ButtonRelease:
- Check(xbutton.state);
- Check(xbutton.button);
- break;
- case KeyPress:
- case KeyRelease:
- Check(xkey.state);
- Check(xkey.keycode);
- break;
- case EnterNotify:
- case LeaveNotify:
- Check(xcrossing.mode);
- Check(xcrossing.detail);
- Check(xcrossing.state);
- break;
- }
-#undef Check
-
- return True;
-}
-
-struct EventData
-{
- XEvent *oldEvent;
- int count;
-};
-
- static Bool
-PeekNotifyEvent(Display *dpy, XEvent *event, char *args)
-{
- struct EventData *eventData = (struct EventData*)args;
-
- return ((++eventData->count == QLength(dpy)) // since PeekIf blocks
- || CompareEvents(event, eventData->oldEvent));
-}
-
-
- static Boolean
-LookAhead(Widget w, XEvent *event)
-{
- XEvent newEvent;
- struct EventData eventData;
-
- if (QLength (XtDisplay (w)) == 0)
- return False;
-
- eventData.count = 0;
- eventData.oldEvent = event;
-
- XPeekIfEvent (XtDisplay (w), &newEvent, PeekNotifyEvent, (char*)&eventData);
-
- return CompareEvents (event, &newEvent);
-}
-
-
- static void
-ExtractPosition(
- XEvent *event,
- Position *x, // RETURN
- Position *y, // RETURN
- unsigned int *state) // RETURN
-{
- switch (event->type)
- {
- case MotionNotify:
- *x = event->xmotion.x;
- *y = event->xmotion.y;
- if (state != NULL)
- *state = event->xmotion.state;
- break;
- case ButtonPress:
- case ButtonRelease:
- *x = event->xbutton.x;
- *y = event->xbutton.y;
- if (state != NULL)
- *state = event->xbutton.state;
- break;
- case KeyPress:
- case KeyRelease:
- *x = event->xkey.x;
- *y = event->xkey.y;
- if (state != NULL)
- *state = event->xkey.state;
- break;
- case EnterNotify:
- case LeaveNotify:
- *x = event->xcrossing.x;
- *y = event->xcrossing.y;
- if (state != NULL)
- *state = event->xcrossing.state;
- break;
- default:
- *x = 0; *y = 0;
- if (state != NULL)
- *state = 0;
- }
-}
-
- static void
-HandleThumb(
- Widget w,
- XEvent *event,
- String *params,
- Cardinal *num_params)
-{
- Position x, y, loc;
- ScrollbarWidget sbw = (ScrollbarWidget) w;
-
- ExtractPosition(event, &x, &y, (unsigned int *)NULL);
- loc = PICKLENGTH(sbw, x, y);
- // if the motion event puts the pointer in thumb, call Move and Notify
- // also call Move and Notify if we're already in continuous scroll mode
- if (sbw->scrollbar.scroll_mode == SMODE_CONT ||
- (loc >= sbw->scrollbar.topLoc &&
- loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength))
- {
- XtCallActionProc(w, "MoveThumb", event, params, *num_params);
- XtCallActionProc(w, "NotifyThumb", event, params, *num_params);
- }
-}
-
- static void
-RepeatNotify(XtPointer client_data, XtIntervalId *idp UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) client_data;
- int call_data;
- char mode = sbw->scrollbar.scroll_mode;
- unsigned long rep;
-
- if (mode == SMODE_NONE || mode == SMODE_CONT)
- {
- sbw->scrollbar.timer_id = (XtIntervalId)0;
- return;
- }
-
- if (mode == SMODE_LINE_DOWN || mode == SMODE_LINE_UP)
- {
- call_data = ONE_LINE_DATA;
- rep = LINE_REPEAT;
- }
- else
- {
- call_data = ONE_PAGE_DATA;
- rep = PAGE_REPEAT;
- }
-
- if (mode == SMODE_PAGE_UP || mode == SMODE_LINE_UP)
- call_data = -call_data;
-
- XtCallCallbacks((Widget)sbw, XtNscrollProc, (XtPointer)(long_u)call_data);
-
- sbw->scrollbar.timer_id =
- XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)sbw),
- rep,
- RepeatNotify,
- client_data);
-}
-
-/*
- * Same as above, but for floating numbers.
- */
- static float
-FloatInRange(float num, float small, float big)
-{
- return (num < small) ? small : ((num > big) ? big : num);
-}
-
- static void
-ScrollOneLineUp(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollSome(w, event, -ONE_LINE_DATA);
-}
-
- static void
-ScrollOneLineDown(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollSome(w, event, ONE_LINE_DATA);
-}
-
- static void
-ScrollPageDown(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollSome(w, event, ONE_PAGE_DATA);
-}
-
- static void
-ScrollPageUp(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollSome(w, event, -ONE_PAGE_DATA);
-}
-
- static void
-ScrollSome(
- Widget w,
- XEvent *event,
- int call_data)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
-
- if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous
- return;
-
- if (LookAhead(w, event))
- return;
-
- sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
- XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data);
-}
-
- static void
-NotifyScroll(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- Position x, y, loc;
- Dimension arrow_size;
- unsigned long delay = 0;
- int call_data = 0;
- unsigned int state;
-
- if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if scroll continuous
- return;
-
- if (LookAhead (w, event))
- return;
-
- ExtractPosition(event, &x, &y, &state);
- loc = PICKLENGTH(sbw, x, y);
-
- if ((int)sbw->scrollbar.thickness * 2 > (int)sbw->scrollbar.length)
- arrow_size = sbw->scrollbar.length / 2;
- else
- arrow_size = sbw->scrollbar.thickness;
-
- /*
- * handle CTRL modifier
- */
- if (state & ControlMask)
- {
- if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
- call_data = END_PAGE_DATA;
- else
- call_data = -END_PAGE_DATA;
- sbw->scrollbar.scroll_mode = SMODE_NONE;
- }
- /*
- * handle first arrow zone
- */
- else if (loc < (Position)arrow_size)
- {
- call_data = -ONE_LINE_DATA;
- sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
- delay = LINE_DELAY;
- }
-
- /*
- * handle last arrow zone
- */
- else if (loc > (Position)(sbw->scrollbar.length - arrow_size))
- {
- call_data = ONE_LINE_DATA;
- sbw->scrollbar.scroll_mode = SMODE_LINE_DOWN;
- delay = LINE_DELAY;
- }
-
- /*
- * handle zone "above" the thumb
- */
- else if (loc < sbw->scrollbar.topLoc)
- {
- call_data = -ONE_PAGE_DATA;
- sbw->scrollbar.scroll_mode = SMODE_PAGE_UP;
- delay = PAGE_DELAY;
- }
-
- /*
- * handle zone "below" the thumb
- */
- else if (loc > sbw->scrollbar.topLoc + (Position)sbw->scrollbar.shownLength)
- {
- call_data = ONE_PAGE_DATA;
- sbw->scrollbar.scroll_mode = SMODE_PAGE_DOWN;
- delay = PAGE_DELAY;
- }
-
- if (call_data)
- XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data);
-
- // establish autoscroll
- if (delay)
- sbw->scrollbar.timer_id =
- XtAppAddTimeOut(XtWidgetToApplicationContext(w),
- delay, RepeatNotify, (XtPointer)w);
-}
-
- static void
-EndScroll(
- Widget w,
- XEvent *event UNUSED,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
-
- sbw->scrollbar.scroll_mode = SMODE_NONE;
- // no need to remove any autoscroll timeout; it will no-op
- // because the scroll_mode is SMODE_NONE
- // but be sure to remove timeout in destroy proc
-}
-
- static float
-FractionLoc(ScrollbarWidget sbw, int x, int y)
-{
- int margin;
- float height, width;
-
- margin = MARGIN(sbw);
- x -= margin;
- y -= margin;
- height = (float)sbw->core.height - 2 * margin;
- width = (float)sbw->core.width - 2 * margin;
- return PICKLENGTH(sbw, x / width, y / height);
-}
-
- static void
-MoveThumb(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget)w;
- Position x, y;
- float top;
- char old_mode = sbw->scrollbar.scroll_mode;
-
- sbw->scrollbar.scroll_mode = SMODE_CONT; // indicate continuous scroll
-
- if (LookAhead(w, event))
- return;
-
- if (!event->xmotion.same_screen)
- return;
-
- ExtractPosition(event, &x, &y, (unsigned int *)NULL);
-
- top = FractionLoc(sbw, x, y);
-
- if (old_mode != SMODE_CONT) // start dragging: set offset
- {
- if (event->xbutton.button == Button2)
- sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.;
- else
- sbw->scrollbar.scroll_off = top - sbw->scrollbar.top;
- }
-
- top -= sbw->scrollbar.scroll_off;
- if (sbw->scrollbar.limit_thumb)
- top = FloatInRange(top, 0.0,
- sbw->scrollbar.max - sbw->scrollbar.shown + 0.000001);
- else
- top = FloatInRange(top, 0.0, sbw->scrollbar.max);
-
- sbw->scrollbar.top = top;
- PaintThumb(sbw);
- XFlush(XtDisplay(w)); // re-draw it before Notifying
-}
-
-
- static void
-NotifyThumb(
- Widget w,
- XEvent *event,
- String *params UNUSED,
- Cardinal *num_params UNUSED)
-{
- ScrollbarWidget sbw = (ScrollbarWidget)w;
- // Use a union to avoid a warning for the weird conversion from float to
- // XtPointer. Comes from Xaw/Scrollbar.c.
- union {
- XtPointer xtp;
- float xtf;
- } xtpf;
-
- if (LookAhead(w, event))
- return;
-
- // thumbProc is not pretty, but is necessary for backwards
- // compatibility on those architectures for which it work{s,ed};
- // the intent is to pass a (truncated) float by value.
- xtpf.xtf = sbw->scrollbar.top;
- XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
- XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
-}
-
- static void
-AllocTopShadowGC(Widget w)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- XtGCMask valuemask;
- XGCValues myXGCV;
-
- valuemask = GCForeground;
- myXGCV.foreground = sbw->scrollbar.top_shadow_pixel;
- sbw->scrollbar.top_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
-}
-
- static void
-AllocBotShadowGC(Widget w)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
- XtGCMask valuemask;
- XGCValues myXGCV;
-
- valuemask = GCForeground;
- myXGCV.foreground = sbw->scrollbar.bot_shadow_pixel;
- sbw->scrollbar.bot_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
-}
-
- static void
-_Xaw3dDrawShadows(
- Widget gw,
- XEvent *event UNUSED,
- Region region,
- int out)
-{
- XPoint pt[6];
- ScrollbarWidget sbw = (ScrollbarWidget) gw;
- Dimension s = sbw->scrollbar.shadow_width;
- /*
- * draw the shadows using the core part width and height,
- * and the scrollbar part shadow_width.
- *
- * no point to do anything if the shadow_width is 0 or the
- * widget has not been realized.
- */
- if (s > 0 && XtIsRealized(gw))
- {
- Dimension h = sbw->core.height;
- Dimension w = sbw->core.width;
- Dimension wms = w - s;
- Dimension hms = h - s;
- Display *dpy = XtDisplay (gw);
- Window win = XtWindow (gw);
- GC top, bot;
-
- if (out)
- {
- top = sbw->scrollbar.top_shadow_GC;
- bot = sbw->scrollbar.bot_shadow_GC;
- }
- else
- {
- top = sbw->scrollbar.bot_shadow_GC;
- bot = sbw->scrollbar.top_shadow_GC;
- }
-
- // top-left shadow
- if ((region == NULL) ||
- (XRectInRegion (region, 0, 0, w, s) != RectangleOut) ||
- (XRectInRegion (region, 0, 0, s, h) != RectangleOut))
- {
- pt[0].x = 0; pt[0].y = h;
- pt[1].x = pt[1].y = 0;
- pt[2].x = w; pt[2].y = 0;
- pt[3].x = wms; pt[3].y = s;
- pt[4].x = pt[4].y = s;
- pt[5].x = s; pt[5].y = hms;
- XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin);
- }
-
- // bottom-right shadow
- if ((region == NULL) ||
- (XRectInRegion (region, 0, hms, w, s) != RectangleOut) ||
- (XRectInRegion (region, wms, 0, s, h) != RectangleOut))
- {
- pt[0].x = 0; pt[0].y = h;
- pt[1].x = w; pt[1].y = h;
- pt[2].x = w; pt[2].y = 0;
- pt[3].x = wms; pt[3].y = s;
- pt[4].x = wms; pt[4].y = hms;
- pt[5].x = s; pt[5].y = hms;
- XFillPolygon (dpy, win, bot, pt, 6, Complex, CoordModeOrigin);
- }
- }
-}
-
-
-/*
- * Set the scroll bar to the given location.
- */
- void
-vim_XawScrollbarSetThumb(Widget w, double top, double shown, double max)
-{
- ScrollbarWidget sbw = (ScrollbarWidget) w;
-
- if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if still thumbing
- return;
-
- sbw->scrollbar.max = (max > 1.0) ? 1.0 :
- (max >= 0.0) ? max : sbw->scrollbar.max;
-
- sbw->scrollbar.top = (top > sbw->scrollbar.max) ? sbw->scrollbar.max :
- (top >= 0.0) ? top : sbw->scrollbar.top;
-
- sbw->scrollbar.shown = (shown > 1.0) ? 1.0 :
- (shown >= 0.0) ? shown : sbw->scrollbar.shown;
-
- PaintThumb(sbw);
-}
diff --git a/src/gui_at_sb.h b/src/gui_at_sb.h
deleted file mode 100644
index 38aa441..0000000
--- a/src/gui_at_sb.h
+++ /dev/null
@@ -1,161 +0,0 @@
-// vi:set ts=8 sts=4 sw=4 noet:
-// MODIFIED ATHENA SCROLLBAR (USING ARROWHEADS AT ENDS OF TRAVEL)
-// Modifications Copyright 1992 by Mitch Trachtenberg
-// Rights, permissions, and disclaimer of warranty are as in the
-// DEC and MIT notice below. See usage warning in .c file.
-/*
- * $XConsortium: ScrollbarP.h,v 1.3 94/04/17 20:12:42 jim Exp $
- */
-
-
-/***********************************************************
-
-Copyright (c) 1987, 1988 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-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 X Consortium 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 X Consortium.
-
-
-Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-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 not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifndef _Scrollbar_h
-#define _Scrollbar_h
-
-/****************************************************************
- *
- * Scrollbar Widget
- *
- ****************************************************************/
-
-#include <X11/IntrinsicP.h>
-#include <X11/Xaw/SimpleP.h>
-#include <X11/Xmu/Converters.h>
-
-/*
- * Most things we need are in StringDefs.h
- */
-#define XtCMinimumThumb "MinimumThumb"
-#define XtCShown "Shown"
-#define XtCTopOfThumb "TopOfThumb"
-#define XtCMaxOfThumb "MaxOfThumb"
-#define XtCShadowWidth "ShadowWidth"
-#define XtCTopShadowPixel "TopShadowPixel"
-#define XtCBottomShadowPixel "BottomShadowPixel"
-#define XtCLimitThumb "LimitThumb"
-
-#define XtNminimumThumb "minimumThumb"
-#define XtNtopOfThumb "topOfThumb"
-#define XtNmaxOfThumb "maxOfThumb"
-#define XtNshadowWidth "shadowWidth"
-#define XtNtopShadowPixel "topShadowPixel"
-#define XtNbottomShadowPixel "bottomShadowPixel"
-#define XtNlimitThumb "limitThumb"
-
-typedef struct _ScrollbarRec *ScrollbarWidget;
-typedef struct _ScrollbarClassRec *ScrollbarWidgetClass;
-
-extern WidgetClass vim_scrollbarWidgetClass;
-
-extern void vim_XawScrollbarSetThumb(Widget, double, double, double);
-
-typedef struct
-{
- // public
- Pixel foreground; // thumb foreground color
- XtOrientation orientation; // horizontal or vertical
- XtCallbackList scrollProc; // proportional scroll
- XtCallbackList thumbProc; // jump (to position) scroll
- XtCallbackList jumpProc; // same as thumbProc but pass data by ref
- Pixmap thumb; // thumb color
- float top; // What percent is above the win's top
- float shown; // What percent is shown in the win
- float max; // Maximum value for top
- Dimension length; // either height or width
- Dimension thickness; // either width or height
- Dimension min_thumb; // minimum size for the thumb.
-
- // private
- XtIntervalId timer_id; // autorepeat timer; remove on destruction
- char scroll_mode; // see below
- float scroll_off; // offset from event to top of thumb
- GC gc; // a (shared) gc
- Position topLoc; // Pixel that corresponds to top
- Dimension shownLength; // Num pixels corresponding to shown
-
- // From 3d widget
- Dimension shadow_width;
- Pixel top_shadow_pixel;
- Pixel bot_shadow_pixel;
- Bool limit_thumb; // limit thumb to inside scrollbar
- int top_shadow_contrast;
- int bot_shadow_contrast;
- GC top_shadow_GC;
- GC bot_shadow_GC;
-} ScrollbarPart;
-
-#define SMODE_NONE 0
-#define SMODE_CONT 1
-#define SMODE_PAGE_UP 2
-#define SMODE_PAGE_DOWN 3
-#define SMODE_LINE_UP 4
-#define SMODE_LINE_DOWN 5
-
-#define ONE_LINE_DATA 1
-#define ONE_PAGE_DATA 10
-#define END_PAGE_DATA 9999
-
-typedef struct _ScrollbarRec {
- CorePart core;
- SimplePart simple;
- ScrollbarPart scrollbar;
-} ScrollbarRec;
-
-typedef struct {int empty;} ScrollbarClassPart;
-
-typedef struct _ScrollbarClassRec {
- CoreClassPart core_class;
- SimpleClassPart simple_class;
- ScrollbarClassPart scrollbar_class;
-} ScrollbarClassRec;
-
-extern ScrollbarClassRec vim_scrollbarClassRec;
-
-#endif // _Scrollbar_h
diff --git a/src/gui_athena.c b/src/gui_athena.c
deleted file mode 100644
index 8b5af63..0000000
--- a/src/gui_athena.c
+++ /dev/null
@@ -1,2303 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4 noet:
- *
- * VIM - Vi IMproved by Bram Moolenaar
- * GUI/Motif support by Robert Webb
- * Athena port by Bill Foster
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-#include "vim.h"
-
-#include <X11/StringDefs.h>
-#include <X11/Intrinsic.h>
-#ifdef FEAT_GUI_NEXTAW
-# include <X11/neXtaw/Form.h>
-# include <X11/neXtaw/SimpleMenu.h>
-# include <X11/neXtaw/MenuButton.h>
-# include <X11/neXtaw/SmeBSB.h>
-# include <X11/neXtaw/SmeLine.h>
-# include <X11/neXtaw/Box.h>
-# include <X11/neXtaw/Dialog.h>
-# include <X11/neXtaw/Text.h>
-# include <X11/neXtaw/AsciiText.h>
-# include <X11/neXtaw/Scrollbar.h>
-#else
-# include <X11/Xaw/Form.h>
-# include <X11/Xaw/SimpleMenu.h>
-# include <X11/Xaw/MenuButton.h>
-# include <X11/Xaw/SmeBSB.h>
-# include <X11/Xaw/SmeLine.h>
-# include <X11/Xaw/Box.h>
-# include <X11/Xaw/Dialog.h>
-# include <X11/Xaw/Text.h>
-# include <X11/Xaw/AsciiText.h>
-#endif // FEAT_GUI_NEXTAW
-
-#ifndef FEAT_GUI_NEXTAW
-# include "gui_at_sb.h"
-#endif
-
-extern Widget vimShell;
-
-static Widget vimForm = (Widget)0;
-Widget textArea = (Widget)0;
-#ifdef FEAT_MENU
-static Widget menuBar = (Widget)0;
-static XtIntervalId timer = 0; // 0 = expired, otherwise active
-
-// Used to figure out menu ordering
-static vimmenu_T *a_cur_menu = NULL;
-static Cardinal athena_calculate_ins_pos(Widget);
-
-static void gui_athena_popup_callback(Widget, XtPointer, XtPointer);
-static void gui_athena_delayed_arm_action(Widget, XEvent *, String *,
- Cardinal *);
-static void gui_athena_popdown_submenus_action(Widget, XEvent *,
- String *, Cardinal *);
-static XtActionsRec pullAction[2] = {
- { "menu-delayedpopup", (XtActionProc)gui_athena_delayed_arm_action},
- { "menu-popdownsubmenus", (XtActionProc)gui_athena_popdown_submenus_action}
-};
-#endif
-
-#ifdef FEAT_TOOLBAR
-static void gui_mch_reset_focus(void);
-static Widget toolBar = (Widget)0;
-#endif
-
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_MENU)
-static void gui_athena_menu_colors(Widget id);
-#endif
-static void gui_athena_scroll_colors(Widget id);
-
-#ifdef FEAT_MENU
-static XtTranslations popupTrans, parentTrans, menuTrans, supermenuTrans;
-static Pixmap pullerBitmap = None;
-static int puller_width = 0;
-#endif
-
-/*
- * Scrollbar callback (XtNjumpProc) for when the scrollbar is dragged with the
- * left or middle mouse button.
- */
- static void
-gui_athena_scroll_cb_jump(
- Widget w UNUSED,
- XtPointer client_data,
- XtPointer call_data)
-{
- scrollbar_T *sb, *sb_info;
- long value;
-
- sb = gui_find_scrollbar((long)client_data);
-
- if (sb == NULL)
- return;
- else if (sb->wp != NULL) // Left or right scrollbar
- {
- /*
- * Careful: need to get scrollbar info out of first (left) scrollbar
- * for window, but keep real scrollbar too because we must pass it to
- * gui_drag_scrollbar().
- */
- sb_info = &sb->wp->w_scrollbars[0];
- }
- else // Bottom scrollbar
- sb_info = sb;
-
- value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001);
- if (value > sb_info->max)
- value = sb_info->max;
-
- gui_drag_scrollbar(sb, value, TRUE);
-}
-
-/*
- * Scrollbar callback (XtNscrollProc) for paging up or down with the left or
- * right mouse buttons.
- */
- static void
-gui_athena_scroll_cb_scroll(
- Widget w UNUSED,
- XtPointer client_data,
- XtPointer call_data)
-{
- scrollbar_T *sb, *sb_info;
- long value;
- int data = (int)(long)call_data;
- int page;
-
- sb = gui_find_scrollbar((long)client_data);
-
- if (sb == NULL)
- return;
- if (sb->wp != NULL) // Left or right scrollbar
- {
- /*
- * Careful: need to get scrollbar info out of first (left) scrollbar
- * for window, but keep real scrollbar too because we must pass it to
- * gui_drag_scrollbar().
- */
- sb_info = &sb->wp->w_scrollbars[0];
-
- if (sb_info->size > 5)
- page = sb_info->size - 2; // use two lines of context
- else
- page = sb_info->size;
-#ifdef FEAT_GUI_NEXTAW
- if (data < 0)
- {
- data = (data - gui.char_height + 1) / gui.char_height;
- if (data > -sb_info->size)
- data = -1;
- else
- data = -page;
- }
- else if (data > 0)
- {
- data = (data + gui.char_height - 1) / gui.char_height;
- if (data < sb_info->size)
- data = 1;
- else
- data = page;
- }
-#else
- switch (data)
- {
- case ONE_LINE_DATA: data = 1; break;
- case -ONE_LINE_DATA: data = -1; break;
- case ONE_PAGE_DATA: data = page; break;
- case -ONE_PAGE_DATA: data = -page; break;
- case END_PAGE_DATA: data = sb_info->max; break;
- case -END_PAGE_DATA: data = -sb_info->max; break;
- default: data = 0; break;
- }
-#endif
- }
- else // Bottom scrollbar
- {
- sb_info = sb;
-#ifdef FEAT_GUI_NEXTAW
- if (data < 0)
- {
- data = (data - gui.char_width + 1) / gui.char_width;
- if (data > -sb->size)
- data = -1;
- }
- else if (data > 0)
- {
- data = (data + gui.char_width - 1) / gui.char_width;
- if (data < sb->size)
- data = 1;
- }
-#endif
- if (data < -1) // page-width left
- {
- if (sb->size > 8)
- data = -(sb->size - 5);
- else
- data = -sb->size;
- }
- else if (data > 1) // page-width right
- {
- if (sb->size > 8)
- data = (sb->size - 5);
- else
- data = sb->size;
- }
- }
-
- value = sb_info->value + data;
- if (value > sb_info->max)
- value = sb_info->max;
- else if (value < 0)
- value = 0;
-
- // Update the bottom scrollbar an extra time (why is this needed??)
- if (sb->wp == NULL) // Bottom scrollbar
- gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max);
-
- gui_drag_scrollbar(sb, value, FALSE);
-}
-
-/*
- * Create all the Athena widgets necessary.
- */
- void
-gui_x11_create_widgets(void)
-{
- /*
- * We don't have any borders handled internally by the textArea to worry
- * about so only skip over the configured border width.
- */
- gui.border_offset = gui.border_width;
-
- // The form containing all the other widgets
- vimForm = XtVaCreateManagedWidget("vimForm",
- formWidgetClass, vimShell,
- XtNborderWidth, 0,
- NULL);
- gui_athena_scroll_colors(vimForm);
-
-#ifdef FEAT_MENU
- // The top menu bar
- menuBar = XtVaCreateManagedWidget("menuBar",
- boxWidgetClass, vimForm,
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainRight,
- XtNinsertPosition, athena_calculate_ins_pos,
- NULL);
- gui_athena_menu_colors(menuBar);
- if (gui.menu_fg_pixel != INVALCOLOR)
- XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL);
-#endif
-
-#ifdef FEAT_TOOLBAR
- // Don't create it Managed, it will be managed when creating the first
- // item. Otherwise an empty toolbar shows up.
- toolBar = XtVaCreateWidget("toolBar",
- boxWidgetClass, vimForm,
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainRight,
- XtNorientation, XtorientHorizontal,
- XtNhSpace, 1,
- XtNvSpace, 3,
- XtNinsertPosition, athena_calculate_ins_pos,
- NULL);
- gui_athena_menu_colors(toolBar);
-#endif
-
- // The text area.
- textArea = XtVaCreateManagedWidget("textArea",
- coreWidgetClass, vimForm,
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNbackground, gui.back_pixel,
- XtNborderWidth, 0,
- NULL);
-
- /*
- * Install the callbacks.
- */
- gui_x11_callbacks(textArea, vimForm);
-
-#ifdef FEAT_MENU
- popupTrans = XtParseTranslationTable(
- "<EnterWindow>: menu-popdownsubmenus() highlight() menu-delayedpopup()\n"
- "<LeaveWindow>: unhighlight()\n"
- "<BtnUp>: menu-popdownsubmenus() XtMenuPopdown() notify() unhighlight()\n"
- "<Motion>: highlight() menu-delayedpopup()");
- parentTrans = XtParseTranslationTable("<LeaveWindow>: unhighlight()");
- menuTrans = XtParseTranslationTable(
- "<EnterWindow>: menu-popdownsubmenus() highlight() menu-delayedpopup()\n"
- "<LeaveWindow>: menu-popdownsubmenus() XtMenuPopdown() unhighlight()\n"
- "<BtnUp>: notify() unhighlight()\n"
- "<BtnMotion>: highlight() menu-delayedpopup()");
- supermenuTrans = XtParseTranslationTable(
- "<EnterWindow>: menu-popdownsubmenus() highlight() menu-delayedpopup()\n"
- "<LeaveWindow>: unhighlight()\n"
- "<BtnUp>: menu-popdownsubmenus() XtMenuPopdown() notify() unhighlight()\n"
- "<BtnMotion>: highlight() menu-delayedpopup()");
-
- XtAppAddActions(XtWidgetToApplicationContext(vimForm), pullAction,
- XtNumber(pullAction));
-#endif
-
- // Pretend we don't have input focus, we will get an event if we do.
- gui.in_focus = FALSE;
-}
-
-#ifdef FEAT_MENU
-/*
- * Calculates the Pixmap based on the size of the current menu font.
- */
- static Pixmap
-gui_athena_create_pullright_pixmap(Widget w)
-{
- Pixmap retval;
-#ifdef FONTSET_ALWAYS
- XFontSet font = None;
-#else
- XFontStruct *font = NULL;
-#endif
-
-#ifdef FONTSET_ALWAYS
- if (gui.menu_fontset == NOFONTSET)
-#else
- if (gui.menu_font == NOFONT)
-#endif
- {
- XrmValue from, to;
- WidgetList children;
- Cardinal num_children;
-
-#ifdef FONTSET_ALWAYS
- from.size = strlen(from.addr = XtDefaultFontSet);
- to.addr = (XtPointer)&font;
- to.size = sizeof(XFontSet);
-#else
- from.size = strlen(from.addr = XtDefaultFont);
- to.addr = (XtPointer)&font;
- to.size = sizeof(XFontStruct *);
-#endif
- // Assumption: The menuBar children will use the same font as the
- // pulldown menu items AND they will all be of type
- // XtNfont.
- XtVaGetValues(menuBar, XtNchildren, &children,
- XtNnumChildren, &num_children,
- NULL);
- if (XtConvertAndStore(w ? w :
- (num_children > 0) ? children[0] : menuBar,
- XtRString, &from,
-#ifdef FONTSET_ALWAYS
- XtRFontSet, &to
-#else
- XtRFontStruct, &to
-#endif
- ) == False)
- return None;
- // "font" should now contain data
- }
- else
-#ifdef FONTSET_ALWAYS
- font = (XFontSet)gui.menu_fontset;
-#else
- font = (XFontStruct *)gui.menu_font;
-#endif
-
- {
- int width, height;
- GC draw_gc, undraw_gc;
- XGCValues gc_values;
- XPoint points[3];
-
-#ifdef FONTSET_ALWAYS
- height = fontset_height2(font);
-#else
- height = font->max_bounds.ascent + font->max_bounds.descent;
-#endif
- width = height - 2;
- puller_width = width + 4;
- retval = XCreatePixmap(gui.dpy,DefaultRootWindow(gui.dpy),width,
- height, 1);
- gc_values.foreground = 1;
- gc_values.background = 0;
- draw_gc = XCreateGC(gui.dpy, retval,
- GCForeground | GCBackground,
- &gc_values);
- gc_values.foreground = 0;
- gc_values.background = 1;
- undraw_gc = XCreateGC(gui.dpy, retval,
- GCForeground | GCBackground,
- &gc_values);
- points[0].x = 0;
- points[0].y = 0;
- points[1].x = width - 1;
- points[1].y = (height - 1) / 2;
- points[2].x = 0;
- points[2].y = height - 1;
- XFillRectangle(gui.dpy, retval, undraw_gc, 0, 0, height, height);
- XFillPolygon(gui.dpy, retval, draw_gc, points, XtNumber(points),
- Convex, CoordModeOrigin);
- XFreeGC(gui.dpy, draw_gc);
- XFreeGC(gui.dpy, undraw_gc);
- }
- return retval;
-}
-#endif
-
-/*
- * Called when the GUI is not going to start after all.
- */
- void
-gui_x11_destroy_widgets(void)
-{
- textArea = NULL;
-#ifdef FEAT_MENU
- menuBar = NULL;
-#endif
-#ifdef FEAT_TOOLBAR
- toolBar = NULL;
-#endif
-}
-
-#if defined(FEAT_TOOLBAR) || defined(PROTO)
-# include "gui_x11_pm.h"
-# ifdef HAVE_X11_XPM_H
-# include <X11/xpm.h>
-# endif
-
-static void createXpmImages(char_u *path, char **xpm, Pixmap *sen);
-
-/*
- * Allocated a pixmap for toolbar menu "menu".
- * Return in "sen".
- */
- static void
-get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen)
-{
- char_u buf[MAXPATHL]; // buffer storing expanded pathname
- char **xpm = NULL; // xpm array
-
- buf[0] = NUL; // start with NULL path
-
- if (menu->iconfile != NULL)
- {
- // Use the "icon=" argument.
- gui_find_iconfile(menu->iconfile, buf, "xpm");
- createXpmImages(buf, NULL, sen);
-
- // If it failed, try using the menu name.
- if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK)
- createXpmImages(buf, NULL, sen);
- if (*sen != (Pixmap)0)
- return;
- }
-
- if (menu->icon_builtin || gui_find_bitmap(menu->name, buf, "xpm") == FAIL)
- {
- if (menu->iconidx >= 0 && menu->iconidx
- < (int)ARRAY_LENGTH(built_in_pixmaps))
- xpm = built_in_pixmaps[menu->iconidx];
- else
- xpm = tb_blank_xpm;
- }
-
- if (xpm != NULL || buf[0] != NUL)
- createXpmImages(buf, xpm, sen);
-}
-
-/*
- * Read an Xpm file, doing color substitutions for the foreground and
- * background colors. If there is an error reading a color xpm file,
- * drop back and read the monochrome file. If successful, create the
- * insensitive Pixmap too.
- */
- static void
-createXpmImages(char_u *path, char **xpm, Pixmap *sen)
-{
- Window rootWindow;
- XpmAttributes attrs;
- XpmColorSymbol color[5] =
- {
- {"none", "none", 0},
- {"iconColor1", NULL, 0},
- {"bottomShadowColor", NULL, 0},
- {"topShadowColor", NULL, 0},
- {"selectColor", NULL, 0}
- };
- int screenNum;
- int status;
- Pixmap mask;
- Pixmap map;
-
- gui_mch_get_toolbar_colors(
- &color[BACKGROUND].pixel,
- &color[FOREGROUND].pixel,
- &color[BOTTOM_SHADOW].pixel,
- &color[TOP_SHADOW].pixel,
- &color[HIGHLIGHT].pixel);
-
- // Setup the color substitution table
- attrs.valuemask = XpmColorSymbols;
- attrs.colorsymbols = color;
- attrs.numsymbols = 5;
-
- screenNum = DefaultScreen(gui.dpy);
- rootWindow = RootWindow(gui.dpy, screenNum);
-
- // Create the "sensitive" pixmap
- if (xpm != NULL)
- status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm,
- &map, &mask, &attrs);
- else
- status = XpmReadFileToPixmap(gui.dpy, rootWindow, (char *)path,
- &map, &mask, &attrs);
- if (status == XpmSuccess && map != 0)
- {
- XGCValues gcvalues;
- GC back_gc;
- GC mask_gc;
-
- // Need to create new Pixmaps with the mask applied.
- gcvalues.foreground = color[BACKGROUND].pixel;
- back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
- mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
- XSetClipMask(gui.dpy, mask_gc, mask);
-
- // Create the "sensitive" pixmap.
- *sen = XCreatePixmap(gui.dpy, rootWindow,
- attrs.width, attrs.height,
- DefaultDepth(gui.dpy, screenNum));
- XFillRectangle(gui.dpy, *sen, back_gc, 0, 0,
- attrs.width, attrs.height);
- XCopyArea(gui.dpy, map, *sen, mask_gc, 0, 0,
- attrs.width, attrs.height, 0, 0);
-
- XFreeGC(gui.dpy, back_gc);
- XFreeGC(gui.dpy, mask_gc);
- XFreePixmap(gui.dpy, map);
- }
- else
- *sen = 0;
-
- XpmFreeAttributes(&attrs);
-}
-
- void
-gui_mch_set_toolbar_pos(
- int x,
- int y,
- int w,
- int h)
-{
- Dimension border;
- int height;
-
- if (!XtIsManaged(toolBar)) // nothing to do
- return;
- XtUnmanageChild(toolBar);
- XtVaGetValues(toolBar,
- XtNborderWidth, &border,
- NULL);
- height = h - 2 * border;
- if (height < 0)
- height = 1;
- XtVaSetValues(toolBar,
- XtNhorizDistance, x,
- XtNvertDistance, y,
- XtNwidth, w - 2 * border,
- XtNheight, height,
- NULL);
- XtManageChild(toolBar);
-}
-#endif
-
- void
-gui_mch_set_text_area_pos(
- int x,
- int y,
- int w,
- int h)
-{
- XtUnmanageChild(textArea);
- XtVaSetValues(textArea,
- XtNhorizDistance, x,
- XtNvertDistance, y,
- XtNwidth, w,
- XtNheight, h,
- NULL);
- XtManageChild(textArea);
-#ifdef FEAT_TOOLBAR
- // Give keyboard focus to the textArea instead of the toolbar.
- gui_mch_reset_focus();
-#endif
-}
-
-#ifdef FEAT_TOOLBAR
-/*
- * A toolbar button has been pushed; now reset the input focus
- * such that the user can type page up/down etc. and have the
- * input go to the editor window, not the button
- */
- static void
-gui_mch_reset_focus(void)
-{
- XtSetKeyboardFocus(vimForm, textArea);
-}
-#endif
-
-
- void
-gui_x11_set_back_color(void)
-{
- if (textArea != NULL)
- XtVaSetValues(textArea,
- XtNbackground, gui.back_pixel,
- NULL);
-}
-
-#if defined(FEAT_MENU) || defined(PROTO)
-/*
- * Menu stuff.
- */
-
-static char_u *make_pull_name(char_u * name);
-static Widget get_popup_entry(Widget w);
-static Widget submenu_widget(Widget);
-static Boolean has_submenu(Widget);
-static void gui_mch_submenu_change(vimmenu_T *mp, int colors);
-static void gui_athena_menu_font(Widget id);
-
- void
-gui_mch_enable_menu(int flag)
-{
- if (flag)
- {
- XtManageChild(menuBar);
-# ifdef FEAT_TOOLBAR
- if (XtIsManaged(toolBar))
- {
- XtVaSetValues(toolBar,
- XtNvertDistance, gui.menu_height,
- NULL);
- XtVaSetValues(textArea,
- XtNvertDistance, gui.menu_height + gui.toolbar_height,
- NULL);
- }
-# endif
- }
- else
- {
- XtUnmanageChild(menuBar);
-# ifdef FEAT_TOOLBAR
- if (XtIsManaged(toolBar))
- {
- XtVaSetValues(toolBar,
- XtNvertDistance, 0,
- NULL);
- }
-# endif
- }
-}
-
- void
-gui_mch_set_menu_pos(
- int x,
- int y,
- int w,
- int h)
-{
- Dimension border;
- int height;
-
- XtUnmanageChild(menuBar);
- XtVaGetValues(menuBar, XtNborderWidth, &border, NULL);
- // avoid trouble when there are no menu items, and h is 1
- height = h - 2 * border;
- if (height < 0)
- height = 1;
- XtVaSetValues(menuBar,
- XtNhorizDistance, x,
- XtNvertDistance, y,
- XtNwidth, w - 2 * border,
- XtNheight, height,
- NULL);
- XtManageChild(menuBar);
-}
-
-/*
- * Used to calculate the insertion position of a widget with respect to its
- * neighbors.
- *
- * Valid range of return values is: 0 (beginning of children) to
- * numChildren (end of children).
- */
- static Cardinal
-athena_calculate_ins_pos(Widget widget)
-{
- // Assume that if the parent of the vimmenu_T is NULL, then we can get
- // to this menu by traversing "next", starting at "root_menu".
- //
- // This holds true for popup menus, toolbar, and toplevel menu items.
-
- // Popup menus: "id" is NULL. Only submenu_id is valid
-
- // Menus that are not toplevel: "parent" will be non-NULL, "id" &
- // "submenu_id" will be non-NULL.
-
- // Toplevel menus: "parent" is NULL, id is the widget of the menu item
-
- WidgetList children;
- Cardinal num_children = 0;
- int retval;
- Arg args[2];
- int n = 0;
- int i;
-
- XtSetArg(args[n], XtNchildren, &children); n++;
- XtSetArg(args[n], XtNnumChildren, &num_children); n++;
- XtGetValues(XtParent(widget), args, n);
-
- retval = num_children;
- for (i = 0; i < (int)num_children; ++i)
- {
- Widget current = children[i];
- vimmenu_T *menu = NULL;
-
- for (menu = (a_cur_menu->parent == NULL)
- ? root_menu : a_cur_menu->parent->children;
- menu != NULL;
- menu = menu->next)
- if (current == menu->id
- && a_cur_menu->priority < menu->priority
- && i < retval)
- retval = i;
- }
- return retval;
-}
-
- void
-gui_mch_add_menu(vimmenu_T *menu, int idx UNUSED)
-{
- char_u *pullright_name;
- Dimension height, space, border;
- vimmenu_T *parent = menu->parent;
-
- a_cur_menu = menu;
- if (parent == NULL)
- {
- if (menu_is_popup(menu->dname))
- {
- menu->submenu_id = XtVaCreatePopupShell((char *)menu->dname,
- simpleMenuWidgetClass, vimShell,
- XtNinsertPosition, athena_calculate_ins_pos,
- XtNtranslations, popupTrans,
- NULL);
- gui_athena_menu_colors(menu->submenu_id);
- }
- else if (menu_is_menubar(menu->dname))
- {
- menu->id = XtVaCreateManagedWidget((char *)menu->dname,
- menuButtonWidgetClass, menuBar,
- XtNmenuName, menu->dname,
-#ifdef FONTSET_ALWAYS
- XtNinternational, True,
-#endif
- NULL);
- if (menu->id == (Widget)0)
- return;
- gui_athena_menu_colors(menu->id);
- gui_athena_menu_font(menu->id);
-
- menu->submenu_id = XtVaCreatePopupShell((char *)menu->dname,
- simpleMenuWidgetClass, menu->id,
- XtNinsertPosition, athena_calculate_ins_pos,
- XtNtranslations, supermenuTrans,
- NULL);
- gui_athena_menu_colors(menu->submenu_id);
- gui_athena_menu_font(menu->submenu_id);
-
- // Don't update the menu height when it was set at a fixed value
- if (!gui.menu_height_fixed)
- {
- /*
- * When we add a top-level item to the menu bar, we can figure
- * out how high the menu bar should be.
- */
- XtVaGetValues(menuBar,
- XtNvSpace, &space,
- XtNborderWidth, &border,
- NULL);
- XtVaGetValues(menu->id,
- XtNheight, &height,
- NULL);
- gui.menu_height = height + 2 * (space + border);
- }
- }
- }
- else if (parent->submenu_id != (Widget)0)
- {
- menu->id = XtVaCreateManagedWidget((char *)menu->dname,
- smeBSBObjectClass, parent->submenu_id,
- XtNlabel, menu->dname,
-#ifdef FONTSET_ALWAYS
- XtNinternational, True,
-#endif
- NULL);
- if (menu->id == (Widget)0)
- return;
- if (pullerBitmap == None)
- pullerBitmap = gui_athena_create_pullright_pixmap(menu->id);
-
- XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap,
- NULL);
- // If there are other menu items that are not pulldown menus,
- // we need to adjust the right margins of those, too.
- {
- WidgetList children;
- Cardinal num_children;
- int i;
-
- XtVaGetValues(parent->submenu_id, XtNchildren, &children,
- XtNnumChildren, &num_children,
- NULL);
- for (i = 0; i < (int)num_children; ++i)
- {
- XtVaSetValues(children[i],
- XtNrightMargin, puller_width,
- NULL);
- }
- }
- gui_athena_menu_colors(menu->id);
- gui_athena_menu_font(menu->id);
-
- pullright_name = make_pull_name(menu->dname);
- menu->submenu_id = XtVaCreatePopupShell((char *)pullright_name,
- simpleMenuWidgetClass, parent->submenu_id,
- XtNtranslations, menuTrans,
- NULL);
- gui_athena_menu_colors(menu->submenu_id);
- gui_athena_menu_font(menu->submenu_id);
- vim_free(pullright_name);
- XtAddCallback(menu->submenu_id, XtNpopupCallback,
- gui_athena_popup_callback, (XtPointer)menu);
-
- if (parent->parent != NULL)
- XtOverrideTranslations(parent->submenu_id, parentTrans);
- }
- a_cur_menu = NULL;
-}
-
-// Used to determine whether a SimpleMenu has pulldown entries.
-//
-// "id" is the parent of the menu items.
-// Ignore widget "ignore" in the pane.
- static Boolean
-gui_athena_menu_has_submenus(Widget id, Widget ignore)
-{
- WidgetList children;
- Cardinal num_children;
- int i;
-
- XtVaGetValues(id, XtNchildren, &children,
- XtNnumChildren, &num_children,
- NULL);
- for (i = 0; i < (int)num_children; ++i)
- {
- if (children[i] == ignore)
- continue;
- if (has_submenu(children[i]))
- return True;
- }
- return False;
-}
-
- static void
-gui_athena_menu_font(Widget id)
-{
-#ifdef FONTSET_ALWAYS
- if (gui.menu_fontset != NOFONTSET)
- {
- if (XtIsManaged(id))
- {
- XtUnmanageChild(id);
- XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL);
- // We should force the widget to recalculate its
- // geometry now.
- XtManageChild(id);
- }
- else
- XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL);
- if (has_submenu(id))
- XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL);
- }
-#else
- int managed = FALSE;
-
- if (gui.menu_font != NOFONT)
- {
- if (XtIsManaged(id))
- {
- XtUnmanageChild(id);
- managed = TRUE;
- }
-
-# ifdef FEAT_XFONTSET
- if (gui.fontset != NOFONTSET)
- XtVaSetValues(id, XtNfontSet, gui.menu_font, NULL);
- else
-# endif
- XtVaSetValues(id, XtNfont, gui.menu_font, NULL);
- if (has_submenu(id))
- XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL);
-
- // Force the widget to recalculate its geometry now.
- if (managed)
- XtManageChild(id);
- }
-#endif
-}
-
-
- void
-gui_mch_new_menu_font(void)
-{
- Pixmap oldpuller = None;
-
- if (menuBar == (Widget)0)
- return;
-
- if (pullerBitmap != None)
- {
- oldpuller = pullerBitmap;
- pullerBitmap = gui_athena_create_pullright_pixmap(NULL);
- }
- gui_mch_submenu_change(root_menu, FALSE);
-
- {
- // Iterate through the menubar menu items and get the height of
- // each one. The menu bar height is set to the maximum of all
- // the heights.
- vimmenu_T *mp;
- int max_height = 9999;
-
- FOR_ALL_MENUS(mp)
- {
- if (menu_is_menubar(mp->dname))
- {
- Dimension height;
-
- XtVaGetValues(mp->id,
- XtNheight, &height,
- NULL);
- if (height < max_height)
- max_height = height;
- }
- }
- if (max_height != 9999)
- {
- // Don't update the menu height when it was set at a fixed value
- if (!gui.menu_height_fixed)
- {
- Dimension space, border;
-
- XtVaGetValues(menuBar,
- XtNvSpace, &space,
- XtNborderWidth, &border,
- NULL);
- gui.menu_height = max_height + 2 * (space + border);
- }
- }
- }
- // Now, to simulate the window being resized. Only, this
- // will resize the window to its current state.
- //
- // There has to be a better way, but I do not see one at this time.
- // (David Harrison)
- {
- Position w, h;
-
- XtVaGetValues(vimShell,
- XtNwidth, &w,
- XtNheight, &h,
- NULL);
- gui_resize_shell(w, h
-#ifdef FEAT_XIM
- - xim_get_status_area_height()
-#endif
- );
- }
- gui_set_shellsize(FALSE, TRUE, RESIZE_VERT);
- ui_new_shellsize();
- if (oldpuller != None)
- XFreePixmap(gui.dpy, oldpuller);
-}
-
-#if defined(FEAT_BEVAL_GUI) || defined(PROTO)
- void
-gui_mch_new_tooltip_font(void)
-{
-# ifdef FEAT_TOOLBAR
- vimmenu_T *menu;
-
- if (toolBar == (Widget)0)
- return;
-
- menu = gui_find_menu((char_u *)"ToolBar");
- if (menu != NULL)
- gui_mch_submenu_change(menu, FALSE);
-# endif
-}
-
- void
-gui_mch_new_tooltip_colors(void)
-{
-# ifdef FEAT_TOOLBAR
- vimmenu_T *menu;
-
- if (toolBar == (Widget)0)
- return;
-
- menu = gui_find_menu((char_u *)"ToolBar");
- if (menu != NULL)
- gui_mch_submenu_change(menu, TRUE);
-# endif
-}
-#endif
-
- static void
-gui_mch_submenu_change(
- vimmenu_T *menu,
- int colors) // TRUE for colors, FALSE for font
-{
- vimmenu_T *mp;
-
- for (mp = menu; mp != NULL; mp = mp->next)
- {
- if (mp->id != (Widget)0)
- {
- if (colors)
- {
- gui_athena_menu_colors(mp->id);
-#ifdef FEAT_TOOLBAR
- // For a toolbar item: Free the pixmap and allocate a new one,
- // so that the background color is right.
- if (mp->image != (Pixmap)0)
- {
- XFreePixmap(gui.dpy, mp->image);
- get_toolbar_pixmap(mp, &mp->image);
- if (mp->image != (Pixmap)0)
- XtVaSetValues(mp->id, XtNbitmap, mp->image, NULL);
- }
-
-# ifdef FEAT_BEVAL_GUI
- // If we have a tooltip, then we need to change its colors
- if (mp->tip != NULL)
- {
- Arg args[2];
-
- args[0].name = XtNbackground;
- args[0].value = gui.tooltip_bg_pixel;
- args[1].name = XtNforeground;
- args[1].value = gui.tooltip_fg_pixel;
- XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
- }
-# endif
-#endif
- }
- else
- {
- gui_athena_menu_font(mp->id);
-#ifdef FEAT_BEVAL_GUI
- // If we have a tooltip, then we need to change its font
- // Assume XtNinternational == True (in createBalloonEvalWindow)
- if (mp->tip != NULL)
- {
- Arg args[1];
-
- args[0].name = XtNfontSet;
- args[0].value = (XtArgVal)gui.tooltip_fontset;
- XtSetValues(mp->tip->balloonLabel, &args[0], XtNumber(args));
- }
-#endif
- }
- }
-
- if (mp->children != NULL)
- {
- // Set the colors/font for the tear off widget
- if (mp->submenu_id != (Widget)0)
- {
- if (colors)
- gui_athena_menu_colors(mp->submenu_id);
- else
- gui_athena_menu_font(mp->submenu_id);
- }
- // Set the colors for the children
- gui_mch_submenu_change(mp->children, colors);
- }
- }
-}
-
-/*
- * Make a submenu name into a pullright name.
- * Replace '.' by '_', can't include '.' in the submenu name.
- */
- static char_u *
-make_pull_name(char_u * name)
-{
- char_u *pname;
- char_u *p;
-
- pname = vim_strnsave(name, STRLEN(name) + strlen("-pullright"));
- if (pname != NULL)
- {
- strcat((char *)pname, "-pullright");
- while ((p = vim_strchr(pname, '.')) != NULL)
- *p = '_';
- }
- return pname;
-}
-
- void
-gui_mch_add_menu_item(vimmenu_T *menu, int idx UNUSED)
-{
- vimmenu_T *parent = menu->parent;
-
- a_cur_menu = menu;
-# ifdef FEAT_TOOLBAR
- if (menu_is_toolbar(parent->name))
- {
- WidgetClass type;
- int n;
- Arg args[21];
-
- n = 0;
- if (menu_is_separator(menu->name))
- {
- XtSetArg(args[n], XtNlabel, ""); n++;
- XtSetArg(args[n], XtNborderWidth, 0); n++;
- }
- else
- {
- get_toolbar_pixmap(menu, &menu->image);
- XtSetArg(args[n], XtNlabel, menu->dname); n++;
- XtSetArg(args[n], XtNinternalHeight, 1); n++;
- XtSetArg(args[n], XtNinternalWidth, 1); n++;
- XtSetArg(args[n], XtNborderWidth, 1); n++;
- if (menu->image != 0)
- {
- XtSetArg(args[n], XtNbitmap, menu->image); n++;
- }
- }
- XtSetArg(args[n], XtNhighlightThickness, 0); n++;
- type = commandWidgetClass;
- // TODO: figure out the position in the toolbar?
- // This currently works fine for the default toolbar, but
- // what if we add/remove items during later runtime?
-
- // NOTE: "idx" isn't used here. The position is calculated by
- // athena_calculate_ins_pos(). The position it calculates
- // should be equal to "idx".
- // TODO: Could we just store "idx" and use that as the child
- // placement?
-
- if (menu->id == NULL)
- {
- menu->id = XtCreateManagedWidget((char *)menu->dname,
- type, toolBar, args, n);
- XtAddCallback(menu->id,
- XtNcallback, gui_x11_menu_cb, menu);
- }
- else
- XtSetValues(menu->id, args, n);
- gui_athena_menu_colors(menu->id);
-
-#ifdef FEAT_BEVAL_GUI
- gui_mch_menu_set_tip(menu);
-#endif
-
- menu->parent = parent;
- menu->submenu_id = (Widget)0;
- if (!XtIsManaged(toolBar)
- && vim_strchr(p_go, GO_TOOLBAR) != NULL)
- gui_mch_show_toolbar(TRUE);
- gui.toolbar_height = gui_mch_compute_toolbar_height();
- return;
- } // toolbar menu item
-# endif
-
- // Add menu separator
- if (menu_is_separator(menu->name))
- {
- menu->submenu_id = (Widget)0;
- menu->id = XtVaCreateManagedWidget((char *)menu->dname,
- smeLineObjectClass, parent->submenu_id,
- NULL);
- if (menu->id == (Widget)0)
- return;
- gui_athena_menu_colors(menu->id);
- }
- else
- {
- if (parent != NULL && parent->submenu_id != (Widget)0)
- {
- menu->submenu_id = (Widget)0;
- menu->id = XtVaCreateManagedWidget((char *)menu->dname,
- smeBSBObjectClass, parent->submenu_id,
- XtNlabel, menu->dname,
-#ifdef FONTSET_ALWAYS
- XtNinternational, True,
-#endif
- NULL);
- if (menu->id == (Widget)0)
- return;
-
- // If there are other "pulldown" items in this pane, then adjust
- // the right margin to accommodate the arrow pixmap, otherwise
- // the right margin will be the same as the left margin.
- {
- Dimension left_margin;
-
- XtVaGetValues(menu->id, XtNleftMargin, &left_margin, NULL);
- XtVaSetValues(menu->id, XtNrightMargin,
- gui_athena_menu_has_submenus(parent->submenu_id, NULL) ?
- puller_width :
- left_margin,
- NULL);
- }
-
- gui_athena_menu_colors(menu->id);
- gui_athena_menu_font(menu->id);
- XtAddCallback(menu->id, XtNcallback, gui_x11_menu_cb,
- (XtPointer)menu);
- }
- }
- a_cur_menu = NULL;
-}
-
-#if defined(FEAT_TOOLBAR) || defined(PROTO)
- void
-gui_mch_show_toolbar(int showit)
-{
- Cardinal numChildren; // how many children toolBar has
-
- if (toolBar == (Widget)0)
- return;
- XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL);
- if (showit && numChildren > 0)
- {
- // Assume that we want to show the toolbar if p_toolbar contains valid
- // option settings, therefore p_toolbar must not be NULL.
- WidgetList children;
-
- XtVaGetValues(toolBar, XtNchildren, &children, NULL);
- {
- void (*action)(BalloonEval *);
- int text = 0;
-
- if (strstr((const char *)p_toolbar, "tooltips"))
- action = &gui_mch_enable_beval_area;
- else
- action = &gui_mch_disable_beval_area;
- if (strstr((const char *)p_toolbar, "text"))
- text = 1;
- else if (strstr((const char *)p_toolbar, "icons"))
- text = -1;
- if (text != 0)
- {
- vimmenu_T *toolbar;
- vimmenu_T *cur;
-
- FOR_ALL_MENUS(toolbar)
- if (menu_is_toolbar(toolbar->dname))
- break;
- // Assumption: toolbar is NULL if there is no toolbar,
- // otherwise it contains the toolbar menu structure.
- //
- // Assumption: "numChildren" == the number of items in the list
- // of items beginning with toolbar->children.
- if (toolbar)
- {
- for (cur = toolbar->children; cur; cur = cur->next)
- {
- Arg args[2];
- int n = 0;
-
- // Enable/Disable tooltip (OK to enable while currently
- // enabled)
- if (cur->tip != NULL)
- (*action)(cur->tip);
- if (text == 1)
- {
- XtSetArg(args[n], XtNbitmap, None);
- n++;
- XtSetArg(args[n], XtNlabel,
- menu_is_separator(cur->name) ? "" :
- (char *)cur->dname);
- n++;
- }
- else
- {
- XtSetArg(args[n], XtNbitmap, cur->image);
- n++;
- XtSetArg(args[n], XtNlabel, (cur->image == None) ?
- menu_is_separator(cur->name) ?
- "" :
- (char *)cur->dname
- :
- (char *)None);
- n++;
- }
- if (cur->id != NULL)
- {
- XtUnmanageChild(cur->id);
- XtSetValues(cur->id, args, n);
- XtManageChild(cur->id);
- }
- }
- }
- }
- }
- gui.toolbar_height = gui_mch_compute_toolbar_height();
- XtManageChild(toolBar);
- if (XtIsManaged(menuBar))
- {
- XtVaSetValues(textArea,
- XtNvertDistance, gui.toolbar_height + gui.menu_height,
- NULL);
- XtVaSetValues(toolBar,
- XtNvertDistance, gui.menu_height,
- NULL);
- }
- else
- {
- XtVaSetValues(textArea,
- XtNvertDistance, gui.toolbar_height,
- NULL);
- XtVaSetValues(toolBar,
- XtNvertDistance, 0,
- NULL);
- }
- }
- else
- {
- gui.toolbar_height = 0;
- if (XtIsManaged(menuBar))
- XtVaSetValues(textArea,
- XtNvertDistance, gui.menu_height,
- NULL);
- else
- XtVaSetValues(textArea,
- XtNvertDistance, 0,
- NULL);
-
- XtUnmanageChild(toolBar);
- }
- gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
-}
-
-
- int
-gui_mch_compute_toolbar_height(void)
-{
- Dimension height; // total Toolbar height
- Dimension whgt; // height of each widget
- Dimension marginHeight; // XmNmarginHeight of toolBar
- Dimension shadowThickness; // thickness of Xtparent(toolBar)
- WidgetList children; // list of toolBar's children
- Cardinal numChildren; // how many children toolBar has
- int i;
-
- height = 0;
- shadowThickness = 0;
- marginHeight = 0;
- if (toolBar != (Widget)0)
- {
- XtVaGetValues(toolBar,
- XtNborderWidth, &shadowThickness,
- XtNvSpace, &marginHeight,
- XtNchildren, &children,
- XtNnumChildren, &numChildren,
- NULL);
- for (i = 0; i < (int)numChildren; i++)
- {
- whgt = 0;
-
- XtVaGetValues(children[i], XtNheight, &whgt, NULL);
- if (height < whgt)
- height = whgt;
- }
- }
-
- return (int)(height + (marginHeight << 1) + (shadowThickness << 1));
-}
-
- void
-gui_mch_get_toolbar_colors(
- Pixel *bgp,
- Pixel *fgp,
- Pixel *bsp,
- Pixel *tsp,
- Pixel *hsp)
-{
- XtVaGetValues(toolBar, XtNbackground, bgp, XtNborderColor, fgp, NULL);
- *bsp = *bgp;
- *tsp = *fgp;
- *hsp = *tsp;
-}
-#endif
-
-
- void
-gui_mch_toggle_tearoffs(int enable UNUSED)
-{
- // no tearoff menus
-}
-
- void
-gui_mch_new_menu_colors(void)
-{
- if (menuBar == (Widget)0)
- return;
- if (gui.menu_fg_pixel != INVALCOLOR)
- XtVaSetValues(menuBar, XtNborderColor, gui.menu_fg_pixel, NULL);
- gui_athena_menu_colors(menuBar);
-#ifdef FEAT_TOOLBAR
- gui_athena_menu_colors(toolBar);
-#endif
-
- gui_mch_submenu_change(root_menu, TRUE);
-}
-
-/*
- * Destroy the machine specific menu widget.
- */
- void
-gui_mch_destroy_menu(vimmenu_T *menu)
-{
- Widget parent;
-
- // There is no item for the toolbar.
- if (menu->id == (Widget)0)
- return;
-
- parent = XtParent(menu->id);
-
- // When removing the last "pulldown" menu item from a pane, adjust the
- // right margins of the remaining widgets.
- if (menu->submenu_id != (Widget)0)
- {
- // Go through the menu items in the parent of this item and
- // adjust their margins, if necessary.
- // This takes care of the case when we delete the last menu item in a
- // pane that has a submenu. In this case, there will be no arrow
- // pixmaps shown anymore.
- {
- WidgetList children;
- Cardinal num_children;
- int i;
- Dimension right_margin = 0;
- Boolean get_left_margin = False;
-
- XtVaGetValues(parent, XtNchildren, &children,
- XtNnumChildren, &num_children,
- NULL);
- if (gui_athena_menu_has_submenus(parent, menu->id))
- right_margin = puller_width;
- else
- get_left_margin = True;
-
- for (i = 0; i < (int)num_children; ++i)
- {
- if (children[i] == menu->id)
- continue;
- if (get_left_margin == True)
- {
- Dimension left_margin;
-
- XtVaGetValues(children[i], XtNleftMargin, &left_margin,
- NULL);
- XtVaSetValues(children[i], XtNrightMargin, left_margin,
- NULL);
- }
- else
- XtVaSetValues(children[i], XtNrightMargin, right_margin,
- NULL);
- }
- }
- }
- // Please be sure to destroy the parent widget first (i.e. menu->id).
- //
- // This code should be basically identical to that in the file gui_motif.c
- // because they are both Xt based.
- if (menu->id != (Widget)0)
- {
- Cardinal num_children;
- Dimension height, space, border;
-
- XtVaGetValues(menuBar,
- XtNvSpace, &space,
- XtNborderWidth, &border,
- NULL);
- XtVaGetValues(menu->id,
- XtNheight, &height,
- NULL);
-#if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
- if (parent == toolBar && menu->tip != NULL)
- {
- // We try to destroy this before the actual menu, because there are
- // callbacks, etc. that will be unregistered during the tooltip
- // destruction.
- //
- // If you call "gui_mch_destroy_beval_area()" after destroying
- // menu->id, then the tooltip's window will have already been
- // deallocated by Xt, and unknown behaviour will ensue (probably
- // a core dump).
- gui_mch_destroy_beval_area(menu->tip);
- menu->tip = NULL;
- }
-#endif
- /*
- * This is a hack to stop the Athena simpleMenuWidget from getting a
- * BadValue error when a menu's last child is destroyed. We check to
- * see if this is the last child and if so, don't delete it. The parent
- * will be deleted soon anyway, and it will delete its children like
- * all good widgets do.
- */
- // NOTE: The cause of the BadValue X Protocol Error is because when the
- // last child is destroyed, it is first unmanaged, thus causing a
- // geometry resize request from the parent Shell widget.
- // Since the Shell widget has no more children, it is resized to have
- // width/height of 0. XConfigureWindow() is then called with the
- // width/height of 0, which generates the BadValue.
- //
- // This happens in phase two of the widget destruction process.
- {
- if (parent != menuBar
-#ifdef FEAT_TOOLBAR
- && parent != toolBar
-#endif
- )
- {
- XtVaGetValues(parent, XtNnumChildren, &num_children, NULL);
- if (num_children > 1)
- XtDestroyWidget(menu->id);
- }
- else
- XtDestroyWidget(menu->id);
- menu->id = (Widget)0;
- }
-
- if (parent == menuBar)
- {
- if (!gui.menu_height_fixed)
- gui.menu_height = height + 2 * (space + border);
- }
-#ifdef FEAT_TOOLBAR
- else if (parent == toolBar)
- {
- // When removing last toolbar item, don't display the toolbar.
- XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL);
- if (num_children == 0)
- gui_mch_show_toolbar(FALSE);
- else
- gui.toolbar_height = gui_mch_compute_toolbar_height();
- }
-#endif
- }
- if (menu->submenu_id != (Widget)0)
- {
- XtDestroyWidget(menu->submenu_id);
- menu->submenu_id = (Widget)0;
- }
-}
-
- static void
-gui_athena_menu_timeout(
- XtPointer client_data,
- XtIntervalId *id UNUSED)
-{
- Widget w = (Widget)client_data;
- Widget popup;
-
- timer = 0;
- if (XtIsSubclass(w,smeBSBObjectClass))
- {
- Pixmap p;
-
- XtVaGetValues(w, XtNrightBitmap, &p, NULL);
- if ((p != None) && (p != XtUnspecifiedPixmap))
- {
- // We are dealing with an item that has a submenu
- popup = get_popup_entry(XtParent(w));
- if (popup == (Widget)0)
- return;
- XtPopup(popup, XtGrabNonexclusive);
- }
- }
-}
-
-/*
- * This routine is used to calculate the position (in screen coordinates)
- * where a submenu should appear relative to the menu entry that popped it
- * up. It should appear even with and just slightly to the left of the
- * rightmost end of the menu entry that caused the popup.
- *
- * This is called when XtPopup() is called.
- */
- static void
-gui_athena_popup_callback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data UNUSED)
-{
- // Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass)
- vimmenu_T *menu = (vimmenu_T *)client_data;
- Dimension width;
- Position root_x, root_y;
-
- // First, popdown any siblings that may have menus popped up
- {
- vimmenu_T *i;
-
- FOR_ALL_CHILD_MENUS(menu->parent, i)
- {
- if (i->submenu_id != NULL && XtIsManaged(i->submenu_id))
- XtPopdown(i->submenu_id);
- }
- }
- XtVaGetValues(XtParent(w),
- XtNwidth, &width,
- NULL);
- // Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id
- // i.e. This IS the active entry
- XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y);
- XtVaSetValues(w, XtNx, root_x,
- XtNy, root_y,
- NULL);
-}
-
- static void
-gui_athena_popdown_submenus_action(
- Widget w,
- XEvent *event,
- String *args,
- Cardinal *nargs)
-{
- WidgetList children;
- Cardinal num_children;
-
- XtVaGetValues(w, XtNchildren, &children,
- XtNnumChildren, &num_children,
- NULL);
- for (; num_children > 0; --num_children)
- {
- Widget child = children[num_children - 1];
-
- if (has_submenu(child))
- {
- Widget temp_w;
-
- temp_w = submenu_widget(child);
- gui_athena_popdown_submenus_action(temp_w,event,args,nargs);
- XtPopdown(temp_w);
- }
- }
-}
-
-/*
- * Used to determine if the given widget has a submenu that can be popped up.
- */
- static Boolean
-has_submenu(Widget widget)
-{
- if ((widget != NULL) && XtIsSubclass(widget,smeBSBObjectClass))
- {
- Pixmap p;
-
- XtVaGetValues(widget, XtNrightBitmap, &p, NULL);
- if ((p != None) && (p != XtUnspecifiedPixmap))
- return True;
- }
- return False;
-}
-
- static void
-gui_athena_delayed_arm_action(
- Widget w,
- XEvent *event,
- String *args,
- Cardinal *nargs)
-{
- Dimension width, height;
-
- if (event->type != MotionNotify)
- return;
-
- XtVaGetValues(w,
- XtNwidth, &width,
- XtNheight, &height,
- NULL);
-
- if (event->xmotion.x >= (int)width || event->xmotion.y >= (int)height)
- return;
-
- {
- static Widget previous_active_widget = NULL;
- Widget current;
-
- current = XawSimpleMenuGetActiveEntry(w);
- if (current != previous_active_widget)
- {
- if (timer)
- {
- // If the timeout hasn't been triggered, remove it
- XtRemoveTimeOut(timer);
- }
- gui_athena_popdown_submenus_action(w,event,args,nargs);
- if (has_submenu(current))
- {
- XtAppAddTimeOut(XtWidgetToApplicationContext(w), 600L,
- gui_athena_menu_timeout,
- (XtPointer)current);
- }
- previous_active_widget = current;
- }
- }
-}
-
- static Widget
-get_popup_entry(Widget w)
-{
- Widget menuw;
-
- // Get the active entry for the current menu
- if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0)
- return NULL;
-
- return submenu_widget(menuw);
-}
-
-/*
- * Given the widget that has been determined to have a submenu, return the
- * submenu widget that is to be popped up.
- */
- static Widget
-submenu_widget(Widget widget)
-{
- // Precondition: has_submenu(widget) == True
- // XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True
-
- char_u *pullright_name;
- Widget popup;
-
- pullright_name = make_pull_name((char_u *)XtName(widget));
- popup = XtNameToWidget(XtParent(widget), (char *)pullright_name);
- vim_free(pullright_name);
-
- return popup;
- // Postcondition: (popup != NULL) implies
- // (XtIsSubclass(popup,simpleMenuWidgetClass) == True)
-}
-
- void
-gui_mch_show_popupmenu(vimmenu_T *menu)
-{
- int rootx, rooty, winx, winy;
- Window root, child;
- unsigned int mask;
-
- if (menu->submenu_id == (Widget)0)
- return;
-
- // Position the popup menu at the pointer
- if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child,
- &rootx, &rooty, &winx, &winy, &mask))
- {
- rootx -= 30;
- if (rootx < 0)
- rootx = 0;
- rooty -= 5;
- if (rooty < 0)
- rooty = 0;
- XtVaSetValues(menu->submenu_id,
- XtNx, rootx,
- XtNy, rooty,
- NULL);
- }
-
- XtOverrideTranslations(menu->submenu_id, popupTrans);
- XtPopupSpringLoaded(menu->submenu_id);
-}
-
-#endif // FEAT_MENU
-
-/*
- * Set the menu and scrollbar colors to their default values.
- */
- void
-gui_mch_def_colors(void)
-{
- /*
- * Get the colors ourselves. Using the automatic conversion doesn't
- * handle looking for approximate colors.
- */
- if (gui.in_use)
- {
- gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
- gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
- gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
- gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name);
-#ifdef FEAT_BEVAL_GUI
- gui.tooltip_fg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_fg_name);
- gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
-#endif
- }
-}
-
-
-/*
- * Scrollbar stuff.
- */
-
- void
-gui_mch_set_scrollbar_thumb(
- scrollbar_T *sb,
- long val,
- long size,
- long max)
-{
- double v, s;
-
- if (sb->id == (Widget)0)
- return;
-
- /*
- * Athena scrollbar must go from 0.0 to 1.0.
- */
- if (max == 0)
- {
- // So you can't scroll it at all (normally it scrolls past end)
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(sb->id, 0.0, 1.0);
-#else
- vim_XawScrollbarSetThumb(sb->id, 0.0, 1.0, 0.0);
-#endif
- }
- else
- {
- v = (double)val / (double)(max + 1);
- s = (double)size / (double)(max + 1);
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(sb->id, v, s);
-#else
- vim_XawScrollbarSetThumb(sb->id, v, s, 1.0);
-#endif
- }
-}
-
- void
-gui_mch_set_scrollbar_pos(
- scrollbar_T *sb,
- int x,
- int y,
- int w,
- int h)
-{
- if (sb->id == (Widget)0)
- return;
-
- XtUnmanageChild(sb->id);
- XtVaSetValues(sb->id,
- XtNhorizDistance, x,
- XtNvertDistance, y,
- XtNwidth, w,
- XtNheight, h,
- NULL);
- XtManageChild(sb->id);
-}
-
- int
-gui_mch_get_scrollbar_xpadding(void)
-{
- int xpad;
- Dimension tw, ww;
- Position tx;
-
- XtVaGetValues(textArea, XtNwidth, &tw, XtNx, &tx, NULL);
- XtVaGetValues(vimShell, XtNwidth, &ww, NULL);
- xpad = ww - tw - tx - gui.scrollbar_width;
- return (xpad < 0) ? 0 : xpad;
-}
-
- int
-gui_mch_get_scrollbar_ypadding(void)
-{
- int ypad;
- Dimension th, wh;
- Position ty;
-
- XtVaGetValues(textArea, XtNheight, &th, XtNy, &ty, NULL);
- XtVaGetValues(vimShell, XtNheight, &wh, NULL);
- ypad = wh - th - ty - gui.scrollbar_height;
- return (ypad < 0) ? 0 : ypad;
-}
-
- void
-gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
-{
- if (sb->id != (Widget)0)
- {
- if (flag)
- XtManageChild(sb->id);
- else
- XtUnmanageChild(sb->id);
- }
-}
-
- void
-gui_mch_create_scrollbar(
- scrollbar_T *sb,
- int orient) // SBAR_VERT or SBAR_HORIZ
-{
- sb->id = XtVaCreateWidget("scrollBar",
-#ifdef FEAT_GUI_NEXTAW
- scrollbarWidgetClass, vimForm,
-#else
- vim_scrollbarWidgetClass, vimForm,
-#endif
- XtNresizable, True,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNborderWidth, 0,
- XtNorientation, (orient == SBAR_VERT) ? XtorientVertical
- : XtorientHorizontal,
- XtNforeground, gui.scroll_fg_pixel,
- XtNbackground, gui.scroll_bg_pixel,
- NULL);
- if (sb->id == (Widget)0)
- return;
-
- XtAddCallback(sb->id, XtNjumpProc,
- gui_athena_scroll_cb_jump, (XtPointer)sb->ident);
- XtAddCallback(sb->id, XtNscrollProc,
- gui_athena_scroll_cb_scroll, (XtPointer)sb->ident);
-
-#ifdef FEAT_GUI_NEXTAW
- XawScrollbarSetThumb(sb->id, 0.0, 1.0);
-#else
- vim_XawScrollbarSetThumb(sb->id, 0.0, 1.0, 0.0);
-#endif
-}
-
- void
-gui_mch_destroy_scrollbar(scrollbar_T *sb)
-{
- if (sb->id != (Widget)0)
- XtDestroyWidget(sb->id);
-}
-
- void
-gui_mch_set_scrollbar_colors(scrollbar_T *sb)
-{
- if (sb->id != (Widget)0)
- XtVaSetValues(sb->id,
- XtNforeground, gui.scroll_fg_pixel,
- XtNbackground, gui.scroll_bg_pixel,
- NULL);
-
- // This is needed for the rectangle below the vertical scrollbars.
- if (sb == &gui.bottom_sbar && vimForm != (Widget)0)
- gui_athena_scroll_colors(vimForm);
-}
-
-/*
- * Miscellaneous stuff:
- */
- Window
-gui_x11_get_wid(void)
-{
- return XtWindow(textArea);
-}
-
-#if defined(FEAT_BROWSE) || defined(PROTO)
-/*
- * Put up a file requester.
- * Returns the selected name in allocated memory, or NULL for Cancel.
- */
- char_u *
-gui_mch_browse(
- int saving UNUSED, // select file to write
- char_u *title, // title for the window
- char_u *dflt, // default name
- char_u *ext UNUSED, // extension added
- char_u *initdir, // initial directory, NULL for current dir
- char_u *filter UNUSED) // file name filter
-{
- Position x, y;
- char_u dirbuf[MAXPATHL];
-
- // Concatenate "initdir" and "dflt".
- if (initdir == NULL || *initdir == NUL)
- mch_dirname(dirbuf, MAXPATHL);
- else if (STRLEN(initdir) + 2 < MAXPATHL)
- STRCPY(dirbuf, initdir);
- else
- dirbuf[0] = NUL;
- if (dflt != NULL && *dflt != NUL
- && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
- {
- add_pathsep(dirbuf);
- STRCAT(dirbuf, dflt);
- }
-
- // Position the file selector just below the menubar
- XtTranslateCoords(vimShell, (Position)0, (Position)
-#ifdef FEAT_MENU
- gui.menu_height
-#else
- 0
-#endif
- , &x, &y);
- return (char_u *)vim_SelFile(vimShell, (char *)title, (char *)dirbuf,
- NULL, (int)x, (int)y, gui.menu_fg_pixel, gui.menu_bg_pixel,
- gui.scroll_fg_pixel, gui.scroll_bg_pixel);
-}
-#endif
-
-#if defined(FEAT_GUI_DIALOG) || defined(PROTO)
-
-static int dialogStatus;
-static Atom dialogatom;
-
-/*
- * Callback function for the textfield. When CR is hit this works like
- * hitting the "OK" button, ESC like "Cancel".
- */
- static void
-keyhit_callback(
- Widget w UNUSED,
- XtPointer client_data UNUSED,
- XEvent *event,
- Boolean *cont UNUSED)
-{
- char buf[2];
-
- if (XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1)
- {
- if (*buf == CAR)
- dialogStatus = 1;
- else if (*buf == ESC)
- dialogStatus = 0;
- }
-}
-
- static void
-butproc(
- Widget w UNUSED,
- XtPointer client_data,
- XtPointer call_data UNUSED)
-{
- dialogStatus = (int)(long)client_data + 1;
-}
-
-/*
- * Function called when dialog window closed.
- */
- static void
-dialog_wm_handler(
- Widget w UNUSED,
- XtPointer client_data UNUSED,
- XEvent *event,
- Boolean *dum UNUSED)
-{
- if (event->type == ClientMessage
- && (Atom)((XClientMessageEvent *)event)->data.l[0] == dialogatom)
- dialogStatus = 0;
-}
-
- int
-gui_mch_dialog(
- int type UNUSED,
- char_u *title,
- char_u *message,
- char_u *buttons,
- int dfltbutton UNUSED,
- char_u *textfield,
- int ex_cmd UNUSED)
-{
- char_u *buts;
- char_u *p, *next;
- XtAppContext app;
- XEvent event;
- Position wd, hd;
- Position wv, hv;
- Position x, y;
- Widget dialog;
- Widget dialogshell;
- Widget dialogmessage;
- Widget dialogtextfield = 0;
- Widget dialogButton;
- Widget prev_dialogButton = NULL;
- int butcount;
- int vertical;
-
- if (title == NULL)
- title = (char_u *)_("Vim dialog");
- dialogStatus = -1;
-
- // if our pointer is currently hidden, then we should show it.
- gui_mch_mousehide(FALSE);
-
- // Check 'v' flag in 'guioptions': vertical button placement.
- vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
-
- // The shell is created each time, to make sure it is resized properly
- dialogshell = XtVaCreatePopupShell("dialogShell",
- transientShellWidgetClass, vimShell,
- XtNtitle, title,
- NULL);
- if (dialogshell == (Widget)0)
- goto error;
-
- dialog = XtVaCreateManagedWidget("dialog",
- formWidgetClass, dialogshell,
- XtNdefaultDistance, 20,
- NULL);
- if (dialog == (Widget)0)
- goto error;
- gui_athena_menu_colors(dialog);
- dialogmessage = XtVaCreateManagedWidget("dialogMessage",
- labelWidgetClass, dialog,
- XtNlabel, message,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNresizable, True,
- XtNborderWidth, 0,
- NULL);
- gui_athena_menu_colors(dialogmessage);
-
- if (textfield != NULL)
- {
- dialogtextfield = XtVaCreateManagedWidget("textfield",
- asciiTextWidgetClass, dialog,
- XtNwidth, 400,
- XtNtop, XtChainTop,
- XtNbottom, XtChainTop,
- XtNleft, XtChainLeft,
- XtNright, XtChainRight,
- XtNfromVert, dialogmessage,
- XtNresizable, True,
- XtNstring, textfield,
- XtNlength, IOSIZE,
- XtNuseStringInPlace, True,
- XtNeditType, XawtextEdit,
- XtNwrap, XawtextWrapNever,
- XtNresize, XawtextResizeHeight,
- NULL);
- XtManageChild(dialogtextfield);
- XtAddEventHandler(dialogtextfield, KeyPressMask, False,
- (XtEventHandler)keyhit_callback, (XtPointer)NULL);
- XawTextSetInsertionPoint(dialogtextfield,
- (XawTextPosition)STRLEN(textfield));
- XtSetKeyboardFocus(dialog, dialogtextfield);
- }
-
- // make a copy, so that we can insert NULs
- buts = vim_strsave(buttons);
- if (buts == NULL)
- return -1;
-
- p = buts;
- for (butcount = 0; *p; ++butcount)
- {
- for (next = p; *next; ++next)
- {
- if (*next == DLG_HOTKEY_CHAR)
- STRMOVE(next, next + 1);
- if (*next == DLG_BUTTON_SEP)
- {
- *next++ = NUL;
- break;
- }
- }
- dialogButton = XtVaCreateManagedWidget("button",
- commandWidgetClass, dialog,
- XtNlabel, p,
- XtNtop, XtChainBottom,
- XtNbottom, XtChainBottom,
- XtNleft, XtChainLeft,
- XtNright, XtChainLeft,
- XtNfromVert, textfield == NULL ? dialogmessage : dialogtextfield,
- XtNvertDistance, vertical ? 4 : 20,
- XtNresizable, False,
- NULL);
- gui_athena_menu_colors(dialogButton);
- if (butcount > 0)
- XtVaSetValues(dialogButton,
- vertical ? XtNfromVert : XtNfromHoriz, prev_dialogButton,
- NULL);
-
- XtAddCallback(dialogButton, XtNcallback, butproc, (XtPointer)(long_u)butcount);
- p = next;
- prev_dialogButton = dialogButton;
- }
- vim_free(buts);
-
- XtRealizeWidget(dialogshell);
-
- // Setup for catching the close-window event, don't let it close Vim!
- dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False);
- XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1);
- XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL);
-
- XtVaGetValues(dialogshell,
- XtNwidth, &wd,
- XtNheight, &hd,
- NULL);
- XtVaGetValues(vimShell,
- XtNwidth, &wv,
- XtNheight, &hv,
- NULL);
- XtTranslateCoords(vimShell,
- (Position)((wv - wd) / 2),
- (Position)((hv - hd) / 2),
- &x, &y);
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
- XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL);
-
- // Position the mouse pointer in the dialog, required for when focus
- // follows mouse.
- XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40);
-
-
- app = XtWidgetToApplicationContext(dialogshell);
-
- XtPopup(dialogshell, XtGrabNonexclusive);
-
- for (;;)
- {
- XtAppNextEvent(app, &event);
- XtDispatchEvent(&event);
- if (dialogStatus >= 0)
- break;
- }
-
- XtPopdown(dialogshell);
-
- if (textfield != NULL && dialogStatus < 0)
- *textfield = NUL;
-
-error:
- XtDestroyWidget(dialogshell);
-
- return dialogStatus;
-}
-#endif
-
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_MENU)
-/*
- * Set the colors of Widget "id" to the menu colors.
- */
- static void
-gui_athena_menu_colors(Widget id)
-{
- if (gui.menu_bg_pixel != INVALCOLOR)
- XtVaSetValues(id, XtNbackground, gui.menu_bg_pixel, NULL);
- if (gui.menu_fg_pixel != INVALCOLOR)
- XtVaSetValues(id, XtNforeground, gui.menu_fg_pixel, NULL);
-}
-#endif
-
-/*
- * Set the colors of Widget "id" to the scroll colors.
- */
- static void
-gui_athena_scroll_colors(Widget id)
-{
- if (gui.scroll_bg_pixel != INVALCOLOR)
- XtVaSetValues(id, XtNbackground, gui.scroll_bg_pixel, NULL);
- if (gui.scroll_fg_pixel != INVALCOLOR)
- XtVaSetValues(id, XtNforeground, gui.scroll_fg_pixel, NULL);
-}
diff --git a/src/gui_beval.c b/src/gui_beval.c
index b460e36..e1b0e4b 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -24,22 +24,12 @@
# include <gtk/gtk.h>
#else
# include <X11/keysym.h>
-# ifdef FEAT_GUI_MOTIF
-# include <Xm/PushB.h>
-# include <Xm/Separator.h>
-# include <Xm/List.h>
-# include <Xm/Label.h>
-# include <Xm/AtomMgr.h>
-# include <Xm/Protocols.h>
-# else
- // Assume Athena
-# include <X11/Shell.h>
-# ifdef FEAT_GUI_NEXTAW
-# include <X11/neXtaw/Label.h>
-# else
-# include <X11/Xaw/Label.h>
-# endif
-# endif
+# include <Xm/PushB.h>
+# include <Xm/Separator.h>
+# include <Xm/List.h>
+# include <Xm/Label.h>
+# include <Xm/AtomMgr.h>
+# include <Xm/Protocols.h>
#endif
#ifndef FEAT_GUI_GTK
@@ -618,7 +608,7 @@
break;
/*
- * Motif and Athena version: Keystrokes will be caught by the
+ * Motif version: Keystrokes will be caught by the
* "textArea" widget, and handled in gui_x11_key_hit_cb().
*/
case KeyPress:
@@ -1072,11 +1062,10 @@
if (beval->msg != NULL)
{
+ XmString s;
// Show the Balloon
// Calculate the label's width and height
-#ifdef FEAT_GUI_MOTIF
- XmString s;
// For the callback function we parse NL characters to create a
// multi-line label. This doesn't work for all languages, but
@@ -1101,21 +1090,6 @@
h += gui.border_offset << 1;
XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL);
XmStringFree(s);
-#else // Athena
- // Assume XtNinternational == True
- XFontSet fset;
- XFontSetExtents *ext;
-
- XtVaGetValues(beval->balloonLabel, XtNfontSet, &fset, NULL);
- ext = XExtentsOfFontSet(fset);
- h = ext->max_ink_extent.height;
- w = XmbTextEscapement(fset,
- (char *)beval->msg,
- (int)STRLEN(beval->msg));
- w += gui.border_offset << 1;
- h += gui.border_offset << 1;
- XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL);
-#endif
// Compute position of the balloon area
tx = beval->x_root + EVAL_OFFSET_X;
@@ -1124,33 +1098,18 @@
tx = beval->screen_width - w;
if ((ty + h) > beval->screen_height)
ty = beval->screen_height - h;
-#ifdef FEAT_GUI_MOTIF
XtVaSetValues(beval->balloonShell,
XmNx, tx,
XmNy, ty,
NULL);
-#else
- // Athena
- XtVaSetValues(beval->balloonShell,
- XtNx, tx,
- XtNy, ty,
- NULL);
-#endif
// Set tooltip colors
{
Arg args[2];
-#ifdef FEAT_GUI_MOTIF
args[0].name = XmNbackground;
args[0].value = gui.tooltip_bg_pixel;
args[1].name = XmNforeground;
args[1].value = gui.tooltip_fg_pixel;
-#else // Athena
- args[0].name = XtNbackground;
- args[0].value = gui.tooltip_bg_pixel;
- args[1].name = XtNforeground;
- args[1].value = gui.tooltip_fg_pixel;
-#endif
XtSetValues(beval->balloonLabel, &args[0], XtNumber(args));
}
@@ -1198,22 +1157,14 @@
int n;
n = 0;
-#ifdef FEAT_GUI_MOTIF
XtSetArg(args[n], XmNallowShellResize, True); n++;
beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
overrideShellWidgetClass, gui.dpy, args, n);
-#else
- // Athena
- XtSetArg(args[n], XtNallowShellResize, True); n++;
- beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
- overrideShellWidgetClass, gui.dpy, args, n);
-#endif
- n = 0;
-#ifdef FEAT_GUI_MOTIF
{
XmFontList fl;
+ n = 0;
fl = gui_motif_fontset2fontlist(&gui.tooltip_fontset);
XtSetArg(args[n], XmNforeground, gui.tooltip_fg_pixel); n++;
XtSetArg(args[n], XmNbackground, gui.tooltip_bg_pixel); n++;
@@ -1222,14 +1173,6 @@
beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
xmLabelWidgetClass, beval->balloonShell, args, n);
}
-#else // FEAT_GUI_ATHENA
- XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++;
- XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++;
- XtSetArg(args[n], XtNinternational, True); n++;
- XtSetArg(args[n], XtNfontSet, gui.tooltip_fontset); n++;
- beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
- labelWidgetClass, beval->balloonShell, args, n);
-#endif
}
#endif // !FEAT_GUI_GTK
diff --git a/src/gui_motif.c b/src/gui_motif.c
index 97b0bf9..27c22d1 100644
--- a/src/gui_motif.c
+++ b/src/gui_motif.c
@@ -641,8 +641,7 @@
}
/*
- * Manage dialog centered on pointer. This could be used by the Athena code as
- * well.
+ * Manage dialog centered on pointer.
*/
void
manage_centered(Widget dialog_child)
@@ -1596,9 +1595,6 @@
// Please be sure to destroy the parent widget first (i.e. menu->id).
// On the other hand, problems have been reported that the submenu must be
// deleted first...
- //
- // This code should be basically identical to that in the file gui_athena.c
- // because they are both Xt based.
if (menu->submenu_id != (Widget)0)
{
XtDestroyWidget(menu->submenu_id);
diff --git a/src/gui_x11.c b/src/gui_x11.c
index 31363a8..6e3e903 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -8,7 +8,7 @@
* See README.txt for an overview of the Vim source code.
*/
/*
- * Common code for the Motif and Athena GUI.
+ * Code for the Motif GUI.
* Not used for GTK.
*/
@@ -66,22 +66,13 @@
#endif
#define DFLT_TOOLTIP_FONT XtDefaultFontSet
-#ifdef FEAT_GUI_ATHENA
-# define DFLT_MENU_BG_COLOR "gray77"
-# define DFLT_MENU_FG_COLOR "black"
-# define DFLT_SCROLL_BG_COLOR "gray60"
-# define DFLT_SCROLL_FG_COLOR "gray77"
-# define DFLT_TOOLTIP_BG_COLOR "#ffff91"
-# define DFLT_TOOLTIP_FG_COLOR "#000000"
-#else
// use the default (CDE) colors
-# define DFLT_MENU_BG_COLOR ""
-# define DFLT_MENU_FG_COLOR ""
-# define DFLT_SCROLL_BG_COLOR ""
-# define DFLT_SCROLL_FG_COLOR ""
-# define DFLT_TOOLTIP_BG_COLOR "#ffff91"
-# define DFLT_TOOLTIP_FG_COLOR "#000000"
-#endif
+#define DFLT_MENU_BG_COLOR ""
+#define DFLT_MENU_FG_COLOR ""
+#define DFLT_SCROLL_BG_COLOR ""
+#define DFLT_SCROLL_FG_COLOR ""
+#define DFLT_TOOLTIP_BG_COLOR "#ffff91"
+#define DFLT_TOOLTIP_FG_COLOR "#000000"
Widget vimShell = (Widget)0;
@@ -385,17 +376,6 @@
(XtPointer)SB_DEFAULT_WIDTH
},
#ifdef FEAT_MENU
-# ifdef FEAT_GUI_ATHENA // with Motif the height is always computed
- {
- XtNmenuHeight,
- XtCMenuHeight,
- XtRInt,
- sizeof(int),
- XtOffsetOf(gui_T, menu_height),
- XtRImmediate,
- (XtPointer)MENU_DEFAULT_HEIGHT // Should figure out at run time
- },
-# endif
{
# ifdef FONTSET_ALWAYS
XtNmenuFontSet,
@@ -1275,8 +1255,6 @@
* Get the colors ourselves. Using the automatic conversion doesn't
* handle looking for approximate colors.
*/
- // NOTE: These next few lines are an exact duplicate of gui_athena.c's
- // gui_mch_def_colors(). Why?
gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
@@ -1286,12 +1264,6 @@
gui.tooltip_bg_pixel = gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
#endif
-#if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA)
- // If the menu height was set, don't change it at runtime
- if (gui.menu_height != MENU_DEFAULT_HEIGHT)
- gui.menu_height_fixed = TRUE;
-#endif
-
// Set default foreground and background colours
gui.norm_pixel = gui.def_norm_pixel;
gui.back_pixel = gui.def_back_pixel;
@@ -1454,11 +1426,7 @@
XpmFreeAttributes(&attr);
}
-# ifdef FEAT_GUI_ATHENA
- XtVaSetValues(vimShell, XtNiconPixmap, icon, XtNiconMask, icon_mask, NULL);
-# else
XtVaSetValues(vimShell, XmNiconPixmap, icon, XmNiconMask, icon_mask, NULL);
-# endif
#endif
}
@@ -1578,16 +1546,6 @@
gui_x11_send_event_handler, NULL);
#endif
-
-#if defined(FEAT_MENU) && defined(FEAT_GUI_ATHENA)
- // The Athena GUI needs this again after opening the window
- gui_position_menu();
-# ifdef FEAT_TOOLBAR
- gui_mch_set_toolbar_pos(0, gui.menu_height, gui.menu_width,
- gui.toolbar_height);
-# endif
-#endif
-
// Get the colors for the highlight groups (gui_check_colors() might have
// changed them)
highlight_gui_started(); // re-init colors and fonts
@@ -2154,22 +2112,6 @@
return extents->max_logical_extent.height;
}
-#if (defined(FONTSET_ALWAYS) && defined(FEAT_GUI_ATHENA) \
- && defined(FEAT_MENU)) || defined(PROTO)
-/*
- * Returns the bounding box height around the actual glyph image of all
- * characters in all fonts of the fontset.
- */
- int
-fontset_height2(XFontSet fs)
-{
- XFontSetExtents *extents;
-
- extents = XExtentsOfFontSet(fs);
- return extents->max_ink_extent.height;
-}
-#endif
-
#if 0
// NOT USED YET
static int
diff --git a/src/if_mzsch.c b/src/if_mzsch.c
index c24edf3..2c0f39c 100644
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -809,7 +809,7 @@
#elif defined(FEAT_GUI_GTK)
static gboolean timer_proc(gpointer);
static guint timer_id = 0;
-#elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+#elif defined(FEAT_GUI_MOTIF)
static void timer_proc(XtPointer, XtIntervalId *);
static XtIntervalId timer_id = (XtIntervalId)0;
#endif
@@ -845,7 +845,7 @@
# elif defined(FEAT_GUI_GTK)
static gboolean
timer_proc(gpointer data UNUSED)
-# elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+# elif defined(FEAT_GUI_MOTIF)
static void
timer_proc(XtPointer timed_out UNUSED, XtIntervalId *interval_id UNUSED)
# endif
@@ -853,7 +853,7 @@
scheme_check_threads();
# if defined(FEAT_GUI_GTK)
return TRUE; // continue receiving notifications
-# elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+# elif defined(FEAT_GUI_MOTIF)
// renew timeout
if (mz_threads_allow && p_mzq > 0)
timer_id = XtAppAddTimeOut(app_context, p_mzq,
@@ -868,7 +868,7 @@
timer_id = SetTimer(NULL, 0, p_mzq, timer_proc);
# elif defined(FEAT_GUI_GTK)
timer_id = g_timeout_add((guint)p_mzq, (GSourceFunc)timer_proc, NULL);
-# elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+# elif defined(FEAT_GUI_MOTIF)
timer_id = XtAppAddTimeOut(app_context, p_mzq, timer_proc, NULL);
# endif
}
@@ -880,7 +880,7 @@
KillTimer(NULL, timer_id);
# elif defined(FEAT_GUI_GTK)
g_source_remove(timer_id);
-# elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+# elif defined(FEAT_GUI_MOTIF)
XtRemoveTimeOut(timer_id);
# endif
timer_id = 0;
diff --git a/src/main.c b/src/main.c
index cf582e9..2a3d310 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3541,14 +3541,6 @@
#ifdef FEAT_GUI_X11
# ifdef FEAT_GUI_MOTIF
mch_msg(_("\nArguments recognised by gvim (Motif version):\n"));
-# else
-# ifdef FEAT_GUI_ATHENA
-# ifdef FEAT_GUI_NEXTAW
- mch_msg(_("\nArguments recognised by gvim (neXtaw version):\n"));
-# else
- mch_msg(_("\nArguments recognised by gvim (Athena version):\n"));
-# endif
-# endif
# endif
main_msg(_("-display <display>\tRun Vim on <display>"));
main_msg(_("-iconic\t\tStart Vim iconified"));
@@ -3560,9 +3552,6 @@
main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)"));
main_msg(_("-borderwidth <width>\tUse a border width of <width> (also: -bw)"));
main_msg(_("-scrollbarwidth <width> Use a scrollbar width of <width> (also: -sw)"));
-# ifdef FEAT_GUI_ATHENA
- main_msg(_("-menuheight <height>\tUse a menu bar height of <height> (also: -mh)"));
-# endif
main_msg(_("-reverse\t\tUse reverse video (also: -rv)"));
main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)"));
main_msg(_("-xrm <resource>\tSet the specified resource"));
diff --git a/src/menu.c b/src/menu.c
index 1c5cc4a..2af54a7 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -609,10 +609,6 @@
#ifdef FEAT_BEVAL_TIP
menu->tip = NULL;
#endif
-#ifdef FEAT_GUI_ATHENA
- menu->image = None; // X-Windows definition for NULL
-#endif
-
/*
* Add after menu that has lower priority.
*/
@@ -2072,10 +2068,7 @@
grey = FALSE;
else
grey = TRUE;
-# ifdef FEAT_GUI_ATHENA
- // Hiding menus doesn't work for Athena, it can cause a crash.
- gui_mch_menu_grey(menu, grey);
-# else
+
// Never hide a toplevel menu, it may make the menubar resize or
// disappear. Same problem for ToolBar items.
if (vim_strchr(p_go, GO_GREY) != NULL || menu->parent == NULL
@@ -2086,7 +2079,6 @@
gui_mch_menu_grey(menu, grey);
else
gui_mch_menu_hidden(menu, grey);
-# endif
gui_update_menus_recurse(menu->children, mode);
menu = menu->next;
}
diff --git a/src/mouse.c b/src/mouse.c
index ffbe842..b81aff2 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -115,7 +115,7 @@
}
#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
- || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
+ || defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_PHOTON) \
|| defined(FEAT_TERM_POPUP_MENU)
# define USE_POPUP_SETPOS
@@ -539,7 +539,7 @@
// menu on the button down event.
return FALSE;
# endif
-# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)
+# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)
if (is_click || is_drag)
// Ignore right button down and drag mouse events. Windows
// only shows the popup menu on the button up event.
diff --git a/src/proto.h b/src/proto.h
index d31629e..9638eaa 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -293,12 +293,6 @@
# include "gui_motif.pro"
# include "gui_xmdlg.pro"
# endif
-# ifdef FEAT_GUI_ATHENA
-# include "gui_athena.pro"
-# ifdef FEAT_BROWSE
-extern char *vim_SelFile(Widget toplevel, char *prompt, char *init_path, int (*show_entry)(), int x, int y, guicolor_T fg, guicolor_T bg, guicolor_T scroll_fg, guicolor_T scroll_bg);
-# endif
-# endif
# ifdef FEAT_GUI_HAIKU
# include "gui_haiku.pro"
# endif
diff --git a/src/proto/gui_athena.pro b/src/proto/gui_athena.pro
deleted file mode 100644
index e74128b..0000000
--- a/src/proto/gui_athena.pro
+++ /dev/null
@@ -1,33 +0,0 @@
-/* gui_athena.c */
-void gui_x11_create_widgets(void);
-void gui_x11_destroy_widgets(void);
-void gui_mch_set_toolbar_pos(int x, int y, int w, int h);
-void gui_mch_set_text_area_pos(int x, int y, int w, int h);
-void gui_x11_set_back_color(void);
-void gui_mch_enable_menu(int flag);
-void gui_mch_set_menu_pos(int x, int y, int w, int h);
-void gui_mch_add_menu(vimmenu_T *menu, int idx);
-void gui_mch_new_menu_font(void);
-void gui_mch_new_tooltip_font(void);
-void gui_mch_new_tooltip_colors(void);
-void gui_mch_add_menu_item(vimmenu_T *menu, int idx);
-void gui_mch_show_toolbar(int showit);
-int gui_mch_compute_toolbar_height(void);
-void gui_mch_get_toolbar_colors(Pixel *bgp, Pixel *fgp, Pixel *bsp, Pixel *tsp, Pixel *hsp);
-void gui_mch_toggle_tearoffs(int enable);
-void gui_mch_new_menu_colors(void);
-void gui_mch_destroy_menu(vimmenu_T *menu);
-void gui_mch_show_popupmenu(vimmenu_T *menu);
-void gui_mch_def_colors(void);
-void gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max);
-void gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h);
-int gui_mch_get_scrollbar_xpadding(void);
-int gui_mch_get_scrollbar_ypadding(void);
-void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
-void gui_mch_create_scrollbar(scrollbar_T *sb, int orient);
-void gui_mch_destroy_scrollbar(scrollbar_T *sb);
-void gui_mch_set_scrollbar_colors(scrollbar_T *sb);
-Window gui_x11_get_wid(void);
-char_u *gui_mch_browse(int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter);
-int gui_mch_dialog(int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield, int ex_cmd);
-/* vim: set ft=c : */
diff --git a/src/structs.h b/src/structs.h
index 6c92f07..9f1e11d 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4003,9 +4003,6 @@
char **xpm; // pixmap data
char *xpm_fname; // file with pixmap data
#endif
-#ifdef FEAT_GUI_ATHENA
- Pixmap image; // Toolbar image
-#endif
#ifdef FEAT_BEVAL_TIP
BalloonEval *tip; // tooltip for this menu item
#endif
diff --git a/src/testdir/gui_init.vim b/src/testdir/gui_init.vim
index 42b2bca..4fa6cbc 100644
--- a/src/testdir/gui_init.vim
+++ b/src/testdir/gui_init.vim
@@ -1,6 +1,6 @@
" gvimrc for test_gui_init.vim
-if has('gui_athena') || has('gui_motif') || has('gui_gtk2') || has('gui_gtk3')
+if has('gui_motif') || has('gui_gtk2') || has('gui_gtk3')
set guiheadroom=0
set guioptions+=p
endif
diff --git a/src/testdir/setup_gui.vim b/src/testdir/setup_gui.vim
index 05e4999..2e5e777 100644
--- a/src/testdir/setup_gui.vim
+++ b/src/testdir/setup_gui.vim
@@ -1,6 +1,6 @@
" Common preparations for running GUI tests.
-let g:x11_based_gui = has('gui_athena') || has('gui_motif')
+let g:x11_based_gui = has('gui_motif')
\ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
" Reasons for 'skipped'.
diff --git a/src/testdir/test_clientserver.vim b/src/testdir/test_clientserver.vim
index 03d201d..aebbc2f 100644
--- a/src/testdir/test_clientserver.vim
+++ b/src/testdir/test_clientserver.vim
@@ -63,8 +63,8 @@
" the GUI and check that the remote command still works.
" Need to wait for the GUI to start up, otherwise the send hangs in trying
" to send to the terminal window.
- if has('gui_athena') || has('gui_motif')
- " For those GUIs, ignore the 'failed to create input context' error.
+ if has('gui_motif')
+ " For this GUI ignore the 'failed to create input context' error.
call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
else
call remote_send(name, ":gui -f\<CR>")
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index e3518d8..a96a95b 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -2094,7 +2094,7 @@
func Test_edit_CTRL_hat()
CheckFeature xim
- " FIXME: test fails with Athena and Motif GUI.
+ " FIXME: test fails with Motif GUI.
" test also fails when running in the GUI.
CheckFeature gui_gtk
CheckNotGui
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index c5332b8..4ae01b8 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -63,7 +63,7 @@
func Test_getfontname_with_arg()
CheckX11BasedGui
- if has('gui_athena') || has('gui_motif')
+ if has('gui_motif')
" Invalid font name. The result should be an empty string.
call assert_equal('', getfontname('notexist'))
@@ -90,7 +90,7 @@
if has('gui_kde')
" 'expected' is the value specified by SetUp() above.
call assert_equal('Courier 10 Pitch/8/-1/5/50/0/0/0/0/0', fname)
- elseif has('gui_athena') || has('gui_motif')
+ elseif has('gui_motif')
" 'expected' is DFLT_FONT of gui_x11.c or its real name.
let pat = '\(7x13\)\|\(\c-Misc-Fixed-Medium-R-Normal--13-120-75-75-C-70-ISO8859-1\)'
call assert_match(pat, fname)
@@ -376,7 +376,7 @@
set guifontset=
endif
- if has('gui_athena') || has('gui_motif')
+ if has('gui_motif')
" Non-empty font list with invalid font names.
"
" This test is twofold: (1) It checks if the command fails as expected
@@ -514,7 +514,7 @@
let &guifontwide = guifontwide_saved
let &guifont = guifont_saved
- elseif has('gui_athena') || has('gui_motif')
+ elseif has('gui_motif')
" guifontwide is premised upon the xfontset feature.
if !has('xfontset')
let skipped = g:not_supported . 'xfontset'
@@ -1280,8 +1280,6 @@
endfunc
func Test_gui_tablabel_tooltip()
- CheckNotFeature gui_athena
-
%bw!
" Removing the tabline at the end of this test, reduces the window height by
" one. Save and restore it after the test.
@@ -1436,10 +1434,6 @@
" Test for generating a GUI tabline event to select a tab page
func Test_gui_tabline_event()
- if has('gui_athena')
- throw 'Skipped: tabline is not supported in Athena GUI'
- endif
-
%bw!
edit Xfile1
tabedit Xfile2
@@ -1467,9 +1461,6 @@
" Test for generating a GUI tabline menu event to execute an action
func Test_gui_tabmenu_event()
- if has('gui_athena')
- throw 'Skipped: tabmenu is not supported in Athena GUI'
- endif
%bw!
" Try to close the last tab page
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index 4b8cd86..51a2524 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -759,7 +759,7 @@
elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
" expect is DEFAULT_FONT of gui_gtk_x11.c
call assert_match('hi Normal\s*font=Monospace 10', hlNormal)
- elseif has('gui_motif') || has('gui_athena')
+ elseif has('gui_motif')
" expect is DEFAULT_FONT of gui_x11.c
call assert_match('hi Normal\s*font=7x13', hlNormal)
elseif has('win32')
diff --git a/src/testdir/test_quotestar.vim b/src/testdir/test_quotestar.vim
index b669019..1d26942 100644
--- a/src/testdir/test_quotestar.vim
+++ b/src/testdir/test_quotestar.vim
@@ -98,7 +98,7 @@
" Running in a terminal and the GUI is available: Tell the server to open
" the GUI and check that the remote command still works.
- if has('gui_athena') || has('gui_motif')
+ if has('gui_motif')
" For those GUIs, ignore the 'failed to create input context' error.
call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
else
diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim
index 1c1e1c0..6926ba3 100644
--- a/src/testdir/test_startup.vim
+++ b/src/testdir/test_startup.vim
@@ -441,7 +441,7 @@
" Test the -reverse and +reverse arguments (for GUI only).
func Test_reverse()
CheckCanRunGui
- CheckAnyOf Feature:gui_gtk Feature:gui_motif Feature:gui_athena
+ CheckAnyOf Feature:gui_gtk Feature:gui_motif
let after =<< trim [CODE]
call writefile([&background], "Xtest_reverse")
@@ -462,7 +462,7 @@
" Test the -background and -foreground arguments (for GUI only).
func Test_background_foreground()
CheckCanRunGui
- CheckAnyOf Feature:gui_gtk Feature:gui_motif Feature:gui_athena
+ CheckAnyOf Feature:gui_gtk Feature:gui_motif
" Is there a better way to check the effect of -background & -foreground
" other than merely looking at &background (dark or light)?
@@ -489,7 +489,7 @@
if has('gui_gtk')
let font = 'Courier 14'
- elseif has('gui_motif') || has('gui_athena')
+ elseif has('gui_motif')
let font = '-misc-fixed-bold-*'
else
throw 'Skipped: test does not set a valid font for this GUI'
@@ -511,10 +511,10 @@
" Test the -geometry argument (for GUI only).
func Test_geometry()
CheckCanRunGui
- CheckAnyOf Feature:gui_gtk Feature:gui_motif Feature:gui_athena
+ CheckAnyOf Feature:gui_gtk Feature:gui_motif
- if has('gui_motif') || has('gui_athena')
- " FIXME: With GUI Athena or Motif, the value of getwinposx(),
+ if has('gui_motif')
+ " FIXME: With GUI Motif the value of getwinposx(),
" getwinposy() and getwinpos() do not match exactly the
" value given in -geometry. Why?
" So only check &columns and &lines for those GUIs.
@@ -550,7 +550,7 @@
" Test the -iconic argument (for GUI only).
func Test_iconic()
CheckCanRunGui
- CheckAnyOf Feature:gui_gtk Feature:gui_motif Feature:gui_athena
+ CheckAnyOf Feature:gui_gtk Feature:gui_motif
call RunVim([], [], '-f -g -iconic -cq')
diff --git a/src/version.c b/src/version.c
index 4deb534..b2986d7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4677,
+/**/
4676,
/**/
4675,
@@ -10454,22 +10456,14 @@
# ifdef FEAT_GUI_MOTIF
msg_puts(_("with X11-Motif GUI."));
# else
-# ifdef FEAT_GUI_ATHENA
-# ifdef FEAT_GUI_NEXTAW
- msg_puts(_("with X11-neXtaw GUI."));
-# else
- msg_puts(_("with X11-Athena GUI."));
-# endif
-# else
-# ifdef FEAT_GUI_HAIKU
+# ifdef FEAT_GUI_HAIKU
msg_puts(_("with Haiku GUI."));
-# else
-# ifdef FEAT_GUI_PHOTON
+# else
+# ifdef FEAT_GUI_PHOTON
msg_puts(_("with Photon GUI."));
-# else
-# if defined(MSWIN)
+# else
+# if defined(MSWIN)
msg_puts(_("with GUI."));
-# endif
# endif
# endif
# endif
diff --git a/src/vim.h b/src/vim.h
index 23771fb..91ef5cc 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -116,7 +116,6 @@
#if defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_GTK) \
- || defined(FEAT_GUI_ATHENA) \
|| defined(FEAT_GUI_HAIKU) \
|| defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_PHOTON)
@@ -190,9 +189,6 @@
# ifdef FEAT_GUI_MOTIF
# undef FEAT_GUI_MOTIF
# endif
-# ifdef FEAT_GUI_ATHENA
-# undef FEAT_GUI_ATHENA
-# endif
# ifdef FEAT_GUI_GTK
# undef FEAT_GUI_GTK
# endif