Skip to content

Instantly share code, notes, and snippets.

@extrowerk
Created December 2, 2016 02:43
Show Gist options
  • Save extrowerk/4854d3c7f1dd159072dc2a72e980f89b to your computer and use it in GitHub Desktop.
Save extrowerk/4854d3c7f1dd159072dc2a72e980f89b to your computer and use it in GitHub Desktop.
From c135936393bfc8bdab12c92da9951be02975f0a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
Date: Fri, 2 Dec 2016 03:05:16 +0100
Subject: [PATCH] Haiku supporting codes and GUI
---
runtime/doc/eval.txt | 2 ++
runtime/doc/gui.txt | 1 +
runtime/doc/help.txt | 1 +
runtime/doc/options.txt | 10 ++++--
runtime/doc/starting.txt | 3 ++
runtime/doc/tags | 16 ++++++++++
runtime/doc/vi_diff.txt | 3 +-
runtime/gvimrc_example.vim | 1 +
runtime/vimrc_example.vim | 1 +
src/Makefile | 80 ++++++++++++++++++++++++++++++++++++++++++++++
src/configure.ac | 37 ++++++++++++++++++---
src/evalfunc.c | 6 ++++
src/ex_cmds.c | 18 +++++++++++
src/ex_docmd.c | 1 +
src/feature.h | 19 +++++++++--
src/gui.c | 34 ++++++++++++++------
src/gui.h | 21 ++++++++++--
src/misc1.c | 15 ++++++++-
src/normal.c | 5 +--
src/option.h | 4 +++
src/os_unix.c | 6 ++--
src/os_unix.h | 4 +++
src/po/zh_CN.cp936.po | 2 +-
src/proto.h | 3 ++
src/pty.c | 2 +-
src/screen.c | 33 +++++++++++++++++++
src/structs.h | 7 ++++
src/term.c | 5 +++
src/ui.c | 2 +-
src/version.c | 4 +++
src/vim.h | 11 ++++++-
31 files changed, 325 insertions(+), 32 deletions(-)
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1f54372..44b2a8e 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -8339,12 +8339,14 @@ gui_gnome Compiled with Gnome support (gui_gtk is also defined).
gui_gtk Compiled with GTK+ GUI (any version).
gui_gtk2 Compiled with GTK+ 2 GUI (gui_gtk is also defined).
gui_gtk3 Compiled with GTK+ 3 GUI (gui_gtk is also defined).
+gui_haiku Compiled with Haiku GUI.
gui_mac Compiled with Macintosh GUI.
gui_motif Compiled with Motif GUI.
gui_photon Compiled with Photon GUI.
gui_running Vim is running in the GUI, or it will start soon.
gui_win32 Compiled with MS Windows Win32 GUI.
gui_win32s idem, and Win32s system being used (Windows 3.1)
+haiku Haiku version of Vim.
hangul_input Compiled with Hangul input support. |hangul|
iconv Can use iconv() for conversion.
insert_expand Compiled with support for CTRL-X expansion commands in
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index efe6319..33b8cd7 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -100,6 +100,7 @@ Recommended place for your personal GUI initializations:
or $VIM/_gvimrc
Amiga s:.gvimrc, home:.gvimrc, home:vimfiles:gvimrc
or $VIM/.gvimrc
+ Haiku $HOME/config/settings/vim/gvimrc
The personal initialization files are searched in the order specified above
and only the first one that is found is read.
diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt
index 58049f6..318e434 100644
--- a/runtime/doc/help.txt
+++ b/runtime/doc/help.txt
@@ -192,6 +192,7 @@ Remarks about specific systems ~
|os_os2.txt| OS/2
|os_qnx.txt| QNX
|os_risc.txt| RISC-OS
+|os_haiku.txt| Haiku
|os_unix.txt| Unix
|os_vms.txt| VMS
|os_win32.txt| MS-Windows 95/98/NT
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 5e0d060..08b364c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3785,7 +3785,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'guitablabel' can be used to change the text in the labels.
When 'e' is missing a non-GUI tab pages line may be used.
The GUI tabs are only supported on some systems, currently
- GTK, Motif, Mac OS/X and MS-Windows.
+ GTK, Motif, Mac OS/X, Haiku and MS-Windows.
*'go-f'*
'f' Foreground: Don't use fork() to detach the GUI from the shell
where it was started. Use this for programs that wait for the
@@ -6089,7 +6089,12 @@ A jump table for the options with a short description can be found at |Q_op|.
$VIM/vimfiles,
$VIMRUNTIME,
$VIM/vimfiles/after,
- sys$login:vimfiles/after")
+ sys$login:vimfiles/after"
+ Haiku: "$BE_USER_SETTINGS/vim,
+ $VIM/vimfiles,
+ $VIMRUNTIME,
+ $VIM/vimfiles/after,
+ $BE_USER_SETTINGS/vim/after")
global
{not in Vi}
This is a list of directories which will be searched for runtime
@@ -7547,6 +7552,7 @@ A jump table for the options with a short description can be found at |Q_op|.
on MiNT: "vt52"
on MS-DOS: "pcterm"
on OS/2: "os2ansi"
+ on Haiku: "xterm"
on Unix: "ansi"
on VMS: "ansi"
on Win 32: "win32")
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 49b1407..5c51890 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -780,6 +780,7 @@ accordingly. Vim proceeds in this order:
or $VIM/_vimrc
Amiga s:.vimrc, home:.vimrc, home:vimfiles:vimrc
or $VIM/.vimrc
+ Haiku $HOME/config/settings/vim/vimrc
The files are searched in the order specified above and only the first
one that is found is read.
@@ -826,6 +827,7 @@ accordingly. Vim proceeds in this order:
"$HOME/_vimrc" (for MS-DOS and Win32) (*)
"$HOME/vimfiles/vimrc" (for MS-DOS and Win32) (*)
"$VIM/_vimrc" (for MS-DOS and Win32) (*)
+ "$HOME/config/settings/vim/vimrc" (for Haiku) (*)
Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
"_vimrc" is also tried, in case an MS-DOS compatible file
system is used. For MS-DOS and Win32 ".vimrc" is checked
@@ -936,6 +938,7 @@ sessions. Put it in a place so that it will be found by 3b:
~/.vimrc (Unix and OS/2)
s:.vimrc (Amiga)
$VIM\_vimrc (MS-DOS and Win32)
+ ~/config/settings/vim/vimrc (Haiku)
Note that creating a vimrc file will cause the 'compatible' option to be off
by default. See |compatible-default|.
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 3ce8dc0..a9706c8 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -4544,6 +4544,7 @@ GetLatestVimScripts-copyright pi_getscript.txt /*GetLatestVimScripts-copyright*
GetLatestVimScripts_dat pi_getscript.txt /*GetLatestVimScripts_dat*
Gnome gui_x11.txt /*Gnome*
H motion.txt /*H*
+Haiku os_haiku.txt /*Haiku*
I insert.txt /*I*
ICCF uganda.txt /*ICCF*
IM-server mbyte.txt /*IM-server*
@@ -6596,6 +6597,20 @@ g~ change.txt /*g~*
g~g~ change.txt /*g~g~*
g~~ change.txt /*g~~*
h motion.txt /*h*
+haiku-bugs os_haiku.txt /*haiku-bugs*
+haiku-colors os_haiku.txt /*haiku-colors*
+haiku-compiling os_haiku.txt /*haiku-compiling*
+haiku-dragndrop os_haiku.txt /*haiku-dragndrop*
+haiku-fonts os_haiku.txt /*haiku-fonts*
+haiku-general os_haiku.txt /*haiku-general*
+haiku-gui os_haiku.txt /*haiku-gui*
+haiku-launch os_haiku.txt /*haiku-launch*
+haiku-meta os_haiku.txt /*haiku-meta*
+haiku-mouse os_haiku.txt /*haiku-mouse*
+haiku-support-credits os_haiku.txt /*haiku-support-credits*
+haiku-toolbar-images os_haiku.txt /*haiku-toolbar-images*
+haiku-user-settings-dir os_haiku.txt /*haiku-user-settings-dir*
+haiku-vimdir os_haiku.txt /*haiku-vimdir*
hangul hangulin.txt /*hangul*
hangulin.txt hangulin.txt /*hangulin.txt*
has() eval.txt /*has()*
@@ -7698,6 +7713,7 @@ os_390.txt os_390.txt /*os_390.txt*
os_amiga.txt os_amiga.txt /*os_amiga.txt*
os_beos.txt os_beos.txt /*os_beos.txt*
os_dos.txt os_dos.txt /*os_dos.txt*
+os_haiku.txt os_haiku.txt /*os_haiku.txt*
os_mac.txt os_mac.txt /*os_mac.txt*
os_mint.txt os_mint.txt /*os_mint.txt*
os_msdos.txt os_msdos.txt /*os_msdos.txt*
diff --git a/runtime/doc/vi_diff.txt b/runtime/doc/vi_diff.txt
index 9a4981f..7f3e415 100644
--- a/runtime/doc/vi_diff.txt
+++ b/runtime/doc/vi_diff.txt
@@ -140,6 +140,7 @@ Support for different systems.
- Atari MiNT
- VMS
- BeOS
+ - Haiku
- Macintosh
- Risc OS
- IBM OS/390
@@ -167,7 +168,7 @@ Graphical User Interface (GUI). |gui|
define your own menus. Better support for CTRL/SHIFT/ALT keys in
combination with special keys and mouse. Supported for various
platforms, such as X11 (with Motif and Athena interfaces), GTK, Win32
- (Windows 95 and later), BeOS, Amiga and Macintosh.
+ (Windows 95 and later), Haiku, Amiga and Macintosh.
Multiple windows and buffers. |windows.txt|
Vim can split the screen into several windows, each editing a
diff --git a/runtime/gvimrc_example.vim b/runtime/gvimrc_example.vim
index fa0f685..a7975f9 100644
--- a/runtime/gvimrc_example.vim
+++ b/runtime/gvimrc_example.vim
@@ -10,6 +10,7 @@
" for Amiga: s:.gvimrc
" for MS-DOS and Win32: $VIM\_gvimrc
" for OpenVMS: sys$login:.gvimrc
+" for Haiku OS: ~/config/settings/vim/gvimrc
" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty
diff --git a/runtime/vimrc_example.vim b/runtime/vimrc_example.vim
index 7f5bae0..77d3a0a 100644
--- a/runtime/vimrc_example.vim
+++ b/runtime/vimrc_example.vim
@@ -8,6 +8,7 @@
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
+" for Haiku OS: ~/config/settings/vim/vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
diff --git a/src/Makefile b/src/Makefile
index a24eb7b..395a84b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1364,6 +1364,23 @@ CARBONGUI_BUNDLE = gui_bundle
APPDIR = $(VIMNAME).app
CARBONGUI_TESTARG = VIMPROG=../$(APPDIR)/Contents/MacOS/$(VIMTARGET)
+### Haiku GUI
+HAIKUGUI_SRC = gui.c gui_haiku.cc pty.c
+HAIKUGUI_OBJ = objects/gui.o objects/gui_haiku.o objects/pty.o
+HAIKUGUI_DEFS = -DFEAT_GUI_HAIKU
+HAIKUGUI_IPATH =
+HAIKUGUI_LIBS_DIR =
+HAIKUGUI_LIBS1 = -lbe -lroot -ltracker -ltranslation
+ifeq ($(strip $(word 1, $(subst -, , $(subst ., , $(shell $(CC) -dumpversion))))), 4)
+HAIKUGUI_LIBS1 += -lsupc++
+endif
+HAIKUGUI_LIBS2 =
+HAIKUGUI_INSTALL = install_normal install_haiku_extra
+HAIKUGUI_TARGETS = installglinks_haiku
+HAIKUGUI_MAN_TARGETS =
+HAIKUGUI_TESTTARGET = gui
+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 pty.c
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
@@ -2967,6 +2984,9 @@ objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c
objects/gui_gtk_x11.o: gui_gtk_x11.c
$(CCC) -o $@ gui_gtk_x11.c
+objects/gui_haiku.o: gui_haiku.cc
+ $(CCC) -o $@ gui_haiku.cc
+
objects/gui_motif.o: gui_motif.c
$(CCC) -o $@ gui_motif.c
@@ -3086,6 +3106,9 @@ objects/option.o: option.c
objects/os_beos.o: os_beos.c
$(CCC) -o $@ os_beos.c
+objects/os_haiku.rsrc: os_haiku.rdef
+ cat $< | $(CCC) -E - | grep -v '^#' | rc -o "$@" -
+
objects/os_qnx.o: os_qnx.c
$(CCC) -o $@ os_qnx.c
@@ -3254,6 +3277,63 @@ $(APPDIR)/Contents:
###############################################################################
+###
+### Haiku installation
+###
+### This rule:
+### - add resources to already installed vim binary to avoid stripping
+### them during install;
+### - copy rgb.txt to runtime directory;
+### - update system MIME database with info about vim application.
+###
+install_haiku_extra: $(DEST_BIN)/$(VIMTARGET) objects/os_haiku.rsrc
+ xres -o $(DEST_BIN)/$(VIMTARGET) objects/os_haiku.rsrc
+ $(INSTALL_DATA) $(SCRIPTSOURCE)/rgb.txt $(DEST_RT)
+ mimeset $(DEST_BIN)/$(VIMTARGET)
+
+###
+### List of g*-links that should be replaced with shell script equivalents.
+### This solves the problem of them from Tracker.
+###
+HAIKU_GLINKS = $(DEST_BIN)/$(GVIMTARGET) \
+ $(DEST_BIN)/$(GVIEWTARGET) \
+ $(DEST_BIN)/$(GVIMDIFFTARGET) \
+ $(DEST_BIN)/$(RGVIMTARGET) \
+ $(DEST_BIN)/$(RGVIEWTARGET)
+###
+### This rule:
+### - Replace gvim link with copy of vim binary.
+### - Replace g*-links with shell script equivalents to solve the problem
+### of calling them from Tracker,
+### - Add icon resources to mentioned g*-link shell scripts
+### - in case gui-less vim.con executable available use it.
+###
+installglinks_haiku: $(HAIKU_GLINKS) install_haiku_extra
+ @catattr -r "BEOS:ICON" $(DEST_BIN)/$(GVIMTARGET) > ~icon.attr
+ for i in $(HAIKU_GLINKS); do \
+ rm $$i ; \
+ echo "#!/bin/sh" > $$i ; \
+ case $$i in \
+ $(DEST_BIN)/$(GVIMTARGET)) \
+ cp $(DEST_BIN)/$(VIMTARGET) $$i ; \
+ if [ -f $(VIMTARGET).con ] ; then \
+ $(STRIP) $(VIMTARGET).con ; \
+ mv $(VIMTARGET).con $(DEST_BIN)/$(VIMTARGET) ; \
+ fi ;; \
+ $(DEST_BIN)/$(GVIEWTARGET)) printf "%s -R %c%c" $(GVIMTARGET) '$$' '*' >> $$i;; \
+ $(DEST_BIN)/$(GVIMDIFFTARGET)) printf "%s -d %c%c" $(GVIMTARGET) '$$' '*' >> $$i;; \
+ $(DEST_BIN)/$(RGVIMTARGET)) printf "%s -Z %c%c" $(GVIMTARGET) '$$' '*' >> $$i;; \
+ $(DEST_BIN)/$(RGVIEWTARGET)) printf "%s -Z -R %c%c" $(GVIMTARGET) '$$' '*' >> $$i;; \
+ *) printf "%s %c%c" $(GVIMTARGET) '$$' '*' >> $$i;; \
+ esac ; \
+ chmod $(BINMOD) $$i ; \
+ addattr -f ~icon.attr -t \'VICN\' BEOS:ICON $$i ; \
+ done
+ addattr -f ~icon.attr -t \'VICN\' BEOS:ICON $(DEST_BIN)/$(VIMNAME)tutor
+ @rm ~icon.attr
+
+###############################################################################
+
### (automatically generated by 'make depend')
### Dependencies:
objects/arabic.o: arabic.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
diff --git a/src/configure.ac b/src/configure.ac
index 3a31f97..4101037 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -114,6 +114,12 @@ case `uname` in
*) BEOS=no; AC_MSG_RESULT(no);;
esac
+AC_MSG_CHECKING(for Haiku)
+case `uname` in
+ Haiku) HAIKU=yes; AC_MSG_RESULT(yes);;
+ *) HAIKU=no; AC_MSG_RESULT(no);;
+esac
+
dnl If QNX is found, assume we don't want to use Xphoton
dnl unless it was specifically asked for (--with-x)
AC_MSG_CHECKING(for QNX)
@@ -1979,7 +1985,11 @@ fi
if test "$enable_channel" = "yes"; then
dnl On Solaris we need the socket and nsl library.
- AC_CHECK_LIB(socket, socket)
+ if test "x$HAIKU" = "xyes"; then
+ AC_CHECK_LIB(network, socket)
+ else
+ AC_CHECK_LIB(socket, socket)
+ fi
AC_CHECK_LIB(nsl, gethostbyname)
AC_MSG_CHECKING(whether compiling with process communication is possible)
AC_TRY_LINK([
@@ -2184,11 +2194,11 @@ else
fi
fi
-test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
+test "x$with_x" = xno -a "x$HAIKU" != "xyes" -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
AC_MSG_CHECKING(--enable-gui argument)
AC_ARG_ENABLE(gui,
- [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/photon/carbon]], , enable_gui="auto")
+ [ --enable-gui[=OPTS] X11 GUI [default=auto] [OPTS=auto/no/gtk2/gnome2/gtk3/motif/athena/neXtaw/haiku/photon/carbon]], , enable_gui="auto")
dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
dnl Do not use character classes for portability with old tools.
@@ -2203,10 +2213,23 @@ SKIP_MOTIF=YES
SKIP_ATHENA=YES
SKIP_NEXTAW=YES
SKIP_PHOTON=YES
+SKIP_HAIKU=YES
SKIP_CARBON=YES
GUITYPE=NONE
-if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
+if test "x$HAIKU" = "xyes"; then
+ SKIP_HAIKU=
+ case "$enable_gui_canon" in
+ no) AC_MSG_RESULT(no GUI support)
+ SKIP_HAIKU=YES ;;
+ yes|"") AC_MSG_RESULT(yes - automatic GUI support) ;;
+ auto) AC_MSG_RESULT(auto - automatic GUI support) ;;
+ haiku) AC_MSG_RESULT(Haiku GUI support) ;;
+ *) AC_MSG_RESULT([Sorry, $enable_gui GUI is not supported])
+ SKIP_HAIKU=YES ;;
+ esac
+
+elif test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then
SKIP_PHOTON=
case "$enable_gui_canon" in
no) AC_MSG_RESULT(no GUI support)
@@ -2370,6 +2393,7 @@ if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
SKIP_ATHENA=YES;
SKIP_NEXTAW=YES;
SKIP_PHOTON=YES;
+ SKIP_HAIKU=YES;
SKIP_CARBON=YES
fi
@@ -2990,6 +3014,11 @@ if test "x$GUITYPE:$enable_fontset" = "xGTK:yes"; then
enable_fontset="no"
fi
+dnl There is no test for the Haiku GUI, if it's selected it's used
+if test -z "$SKIP_HAIKU"; then
+ GUITYPE=HAIKUGUI
+fi
+
if test -z "$SKIP_PHOTON"; then
GUITYPE=PHOTONGUI
fi
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 6721173..fdc6674 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5463,6 +5463,9 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef __BEOS__
"beos",
#endif
+#ifdef __HAIKU__
+ "haiku",
+#endif
#ifdef MACOS
"mac",
#endif
@@ -5640,6 +5643,9 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_GUI_GNOME
"gui_gnome",
#endif
+#ifdef FEAT_GUI_HAIKU
+ "gui_haiku",
+#endif
#ifdef FEAT_GUI_MAC
"gui_mac",
#endif
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 206ead1..9ca1df4 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -14,6 +14,9 @@
#include "vim.h"
#include "version.h"
+#include <sys/stat.h>
+#include <string.h>
+
#ifdef FEAT_FLOAT
# include <float.h>
#endif
@@ -1839,6 +1842,8 @@ write_viminfo(char_u *file, int forceit)
int hidden = FALSE;
#endif
+char* filenameSeparatorPos;
+
if (no_viminfo())
return;
@@ -1846,6 +1851,19 @@ write_viminfo(char_u *file, int forceit)
if (fname == NULL)
return;
+ /* Ensure that configuration folder(for viminfo) exist */
+ filenameSeparatorPos = strrchr(fname, '/');
+ if(filenameSeparatorPos != NULL &&
+ filenameSeparatorPos - (char*)fname > 1) {
+ // > 1 because root directory always exists anyway
+ *filenameSeparatorPos = '\0';
+ //<fname, filenameSparatorPos) is directory path
+ mkdir(fname, S_IRWXU);
+
+ *filenameSeparatorPos = '/';
+ //restore original filename
+ }
+
fp_in = mch_fopen((char *)fname, READBIN);
if (fp_in == NULL)
{
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 439467c..0d8988a 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7740,6 +7740,7 @@ ex_shell(exarg_T *eap UNUSED)
|| (defined(FEAT_GUI_GTK) && defined(FEAT_DND)) \
|| defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_MAC) \
+ || defined(FEAT_GUI_HAIKU) \
|| defined(PROTO)
/*
diff --git a/src/feature.h b/src/feature.h
index 138279e..b211727 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -637,6 +637,14 @@
/* #define FEAT_MBYTE_IME */
# endif
+/*
+ * +multi_byte_ime Haiku input method support.
+ * Requires +multi_byte.
+ */
+#if defined(FEAT_BIG) && defined(FEAT_GUI_HAIKU) && !defined(FEAT_MBYTE_IME)
+ #define FEAT_MBYTE_IME
+# endif
+
#if defined(FEAT_MBYTE_IME) && !defined(FEAT_MBYTE)
# define FEAT_MBYTE
#endif
@@ -742,7 +750,8 @@
|| defined(FEAT_GUI_MSWIN) \
|| ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \
&& defined(HAVE_XPM)) \
- || defined(FEAT_GUI_PHOTON))
+ || defined(FEAT_GUI_PHOTON)\
+ || defined(FEAT_GUI_HAIKU))
# define FEAT_TOOLBAR
#endif
@@ -758,6 +767,7 @@
&& (defined(FEAT_GUI_GTK) \
|| (defined(FEAT_GUI_MOTIF) && defined(HAVE_XM_NOTEBOOK_H)) \
|| defined(FEAT_GUI_MAC) \
+ || defined(FEAT_GUI_HAIKU) \
|| (defined(FEAT_GUI_MSWIN) \
&& (!defined(_MSC_VER) || _MSC_VER > 1020)))
# define FEAT_GUI_TABLINE
@@ -769,7 +779,8 @@
*/
#if defined(FEAT_NORMAL)
# define FEAT_BROWSE_CMD
-# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
+# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
+ || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
# define FEAT_BROWSE
# endif
#endif
@@ -793,6 +804,7 @@
&& defined(HAVE_X11_XPM_H)) \
|| defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_PHOTON) \
+ || defined(FEAT_GUI_HAIKU) \
|| defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_MAC)
# define FEAT_CON_DIALOG
@@ -810,7 +822,8 @@
#if defined(FEAT_GUI_DIALOG) && \
(defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
|| defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
+ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))\
+ || defined(FEAT_GUI_HAIKU)
# define FEAT_GUI_TEXTDIALOG
# ifndef ALWAYS_USE_GUI
# define FEAT_CON_DIALOG
diff --git a/src/gui.c b/src/gui.c
index 87b0839..bfeaa25 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -424,7 +424,7 @@ gui_init_check(void)
gui.menu_width = 0;
# endif
#endif
-#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA))
+#if defined(FEAT_TOOLBAR) && (defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_HAIKU))
gui.toolbar_height = 0;
#endif
#if defined(FEAT_FOOTER) && defined(FEAT_GUI_MOTIF)
@@ -1338,10 +1338,10 @@ gui_position_components(int total_width UNUSED)
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_ATHENA) || defined(FEAT_GUI_HAIKU))
if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
{
-# ifdef FEAT_GUI_ATHENA
+# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_HAIKU)
gui_mch_set_toolbar_pos(0, text_area_y,
gui.menu_width, gui.toolbar_height);
# endif
@@ -1349,6 +1349,13 @@ gui_position_components(int total_width UNUSED)
}
#endif
+# if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_HAIKU))
+ gui_mch_set_tabline_pos(0, text_area_y,
+ gui.menu_width, gui.tabline_height);
+ if (gui_has_tabline())
+ text_area_y += gui.tabline_height;
+#endif
+
text_area_width = gui.num_cols * gui.char_width + gui.border_offset * 2;
text_area_height = gui.num_rows * gui.char_height + gui.border_offset * 2;
@@ -1420,7 +1427,7 @@ gui_get_base_height(void)
# endif
# endif
# if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_MOTIF))
+ || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU))
if (gui_has_tabline())
base_height += gui.tabline_height;
# endif
@@ -1461,6 +1468,10 @@ gui_resize_shell(int pixel_width, int pixel_height)
again:
busy = TRUE;
+#ifdef FEAT_GUI_HAIKU
+ vim_lock_screen();
+#endif
+
/* Flush pending output before redrawing */
out_flush();
@@ -1483,6 +1494,10 @@ again:
|| gui.num_rows != Rows || gui.num_cols != Columns)
shell_resized();
+#ifdef FEAT_GUI_HAIKU
+ vim_unlock_screen();
+#endif
+
gui_update_scrollbars(TRUE);
gui_update_cursor(FALSE, TRUE);
#if defined(FEAT_XIM) && !defined(FEAT_GUI_GTK)
@@ -4248,9 +4263,9 @@ gui_update_scrollbars(
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_ATHENA) || defined(FEAT_GUI_HAIKU))
if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
-# ifdef FEAT_GUI_ATHENA
+# if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_HAIKU)
y += gui.toolbar_height;
# else
# ifdef FEAT_GUI_MSWIN
@@ -4259,7 +4274,7 @@ gui_update_scrollbars(
# endif
#endif
-#if defined(FEAT_GUI_TABLINE) && defined(FEAT_GUI_MSWIN)
+#if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU))
if (gui_has_tabline())
y += gui.tabline_height;
#endif
@@ -4988,9 +5003,10 @@ ex_gui(exarg_T *eap)
}
#if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \
- || defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO)
+ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_HAIKU)) \
+ && defined(FEAT_TOOLBAR)) || defined(PROTO)
/*
- * This is shared between Athena, Motif and GTK.
+ * This is shared between Athena, Haiku, Motif and GTK.
*/
static void gfp_setname(char_u *fname, void *cookie);
diff --git a/src/gui.h b/src/gui.h
index 4769716..8a321e4 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -33,6 +33,10 @@
# include <gtk/gtk.h>
#endif
+#ifdef FEAT_GUI_HAIKU
+# include "gui_haiku.h"
+#endif
+
#ifdef FEAT_GUI_MAC
# include <Types.h>
/*# include <Memory.h>*/
@@ -70,7 +74,7 @@
* GUIs that support dropping files on a running Vim.
*/
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) \
- || defined(FEAT_GUI_GTK)
+ || defined(FEAT_GUI_HAIKU) || defined(FEAT_GUI_GTK)
# define HAVE_DROP_FILE
#endif
@@ -198,6 +202,9 @@ typedef struct GuiScrollbar
scroll_shift is set to the number of shifts
to reduce the count. */
#endif
+#if FEAT_GUI_HAIKU
+ VimScrollBar *id; /* Pointer to real scroll bar */
+#endif
#ifdef FEAT_GUI_MAC
ControlHandle id; /* A handle to the scrollbar */
#endif
@@ -411,7 +418,7 @@ typedef struct Gui
#if defined(FEAT_GUI_TABLINE) \
&& (defined(FEAT_GUI_W32) || defined(FEAT_GUI_MOTIF) \
- || defined(FEAT_GUI_MAC))
+ || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_HAIKU))
int tabline_height;
#endif
@@ -420,7 +427,7 @@ typedef struct Gui
#endif
#if defined(FEAT_TOOLBAR) \
- && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF))
+ && (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_HAIKU))
int toolbar_height; /* height of the toolbar */
#endif
@@ -441,6 +448,14 @@ typedef struct Gui
guicolor_T currSpColor; /* Current special text color */
#endif
+#ifdef FEAT_GUI_HAIKU
+ VimApp *vimApp;
+ VimWindow *vimWindow;
+ VimFormView *vimForm;
+ VimTextAreaView *vimTextArea;
+ int vdcmp; /* Vim Direct Communication Message Port */
+#endif
+
#ifdef FEAT_GUI_MAC
WindowPtr VimWindow;
MenuHandle MacOSHelpMenu; /* Help menu provided by the MacOS */
diff --git a/src/misc1.c b/src/misc1.c
index 3630d7b..03f13cc 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -14,6 +14,10 @@
#include "vim.h"
#include "version.h"
+#if defined(__HAIKU__)
+#include <storage/FindDirectory.h>
+#endif
+
static char_u *vim_version_dir(char_u *vimdir);
static char_u *remove_tail(char_u *p, char_u *pend, char_u *name);
#if defined(FEAT_CMDL_COMPL)
@@ -4214,7 +4218,16 @@ vim_getenv(char_u *name, int *mustfree)
vimruntime = (STRCMP(name, "VIMRUNTIME") == 0);
if (!vimruntime && STRCMP(name, "VIM") != 0)
- return NULL;
+#if defined(__HAIKU__)
+ // special handling for user settings directory...
+ if(STRCMP(name, "BE_USER_SETTINGS") == 0) {
+ static char userSettingsPath[MAXPATHL] = {0};
+ if(B_OK == find_directory(B_USER_SETTINGS_DIRECTORY, 0,
+ false, userSettingsPath, MAXPATHL))
+ return userSettingsPath;
+ } else
+#endif
+ return NULL;
/*
* When expanding $VIMRUNTIME fails, try using $VIM/vim<version> or $VIM.
diff --git a/src/normal.c b/src/normal.c
index 5d0796f..78769e1 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -2647,13 +2647,14 @@ do_mouse(
if (!is_click)
return FALSE;
#endif
-#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN)
+#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)
if (is_click || is_drag)
return FALSE;
#endif
#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON)
+ || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) \
+ || defined(FEAT_GUI_HAIKU)
if (gui.in_use)
{
jump_flags = 0;
diff --git a/src/option.h b/src/option.h
index 13acabf..5d9bc4a 100644
--- a/src/option.h
+++ b/src/option.h
@@ -10,6 +10,8 @@
* option.h: definition of global variables for settable options
*/
+#ifndef _OPTION_H_
+#define _OPTION_H_
/*
* Default values for 'errorformat'.
* The "%f|%l| %m" one is used for when the contents of the quickfix window is
@@ -1185,5 +1187,7 @@ enum
, WV_COUNT /* must be the last one */
};
+#endif //_OPTION_H_
+
/* Value for b_p_ul indicating the global value must be used. */
#define NO_LOCAL_UNDOLEVEL -123456
diff --git a/src/os_unix.c b/src/os_unix.c
index aa3c3e5..fa8751c 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2159,7 +2159,7 @@ mch_settitle(char_u *title, char_u *icon)
if (get_x11_windis() == OK)
type = 1;
#else
-# if defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_GTK)
+# if defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_HAIKU)
if (gui.in_use)
type = 1;
# endif
@@ -2187,7 +2187,7 @@ mch_settitle(char_u *title, char_u *icon)
# endif
set_x11_title(title); /* x11 */
#endif
-#if defined(FEAT_GUI_GTK) \
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_HAIKU)\
|| defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
else
gui_mch_settitle(title, icon);
@@ -4295,7 +4295,7 @@ mch_call_shell(
{
SIGSET_DECL(curset)
-# ifdef __BEOS__
+# if defined(__BEOS__) && USE_THREAD_FOR_INPUT_WITH_TIMEOUT
beos_cleanup_read_thread();
# endif
diff --git a/src/os_unix.h b/src/os_unix.h
index d28aa4d..1c6efd2 100644
--- a/src/os_unix.h
+++ b/src/os_unix.h
@@ -364,6 +364,8 @@ typedef struct dsc$descriptor DESC;
#define DFLT_ERRORFILE "errors.err"
+#ifndef DFLT_RUNTIMEPATH
+
#ifdef VMS
# define DFLT_RUNTIMEPATH "sys$login:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,sys$login:vimfiles/after"
#else
@@ -374,6 +376,8 @@ typedef struct dsc$descriptor DESC;
# endif
#endif
+#endif
+
#ifdef VMS
# ifndef VAX
# define VMS_TEMPNAM /* to fix default .LIS extension */
diff --git a/src/proto.h b/src/proto.h
index 8cfdb12..69fe8d3 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -236,6 +236,9 @@ extern char_u *vimpty_getenv(const char_u *string); /* from pty.c */
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
# ifdef FEAT_GUI_MAC
# include "gui_mac.pro"
# endif
diff --git a/src/pty.c b/src/pty.c
index c07256f..fdd4572 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -348,7 +348,7 @@ OpenPTY(char **ttyn)
static char PtyProto[] = "/dev/ptym/ptyXY";
static char TtyProto[] = "/dev/pty/ttyXY";
# else
-# ifdef __BEOS__
+# if defined(__BEOS__) || defined(__HAIKU__)
static char PtyProto[] = "/dev/pt/XY";
static char TtyProto[] = "/dev/tt/XY";
# else
diff --git a/src/screen.c b/src/screen.c
index 45e7c7c..40fba6a 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -89,6 +89,15 @@
#include "vim.h"
+#ifdef __HAIKU__
+// FIXME!!!
+ int
+gui_mch_is_blink_off(void)
+{
+ return FALSE;
+}
+#endif
+
#define MB_FILLER_CHAR '<' /* character used when a double-width character
* doesn't fit. */
@@ -8574,6 +8583,10 @@ retry:
win_new_shellsize(); /* fit the windows in the new sized shell */
+#ifdef FEAT_GUI_HAIKU
+ vim_lock_screen(); /* be safe, put it here */
+#endif
+
comp_col(); /* recompute columns for shown command and ruler */
/*
@@ -8817,6 +8830,10 @@ give_up:
}
#endif
+#ifdef FEAT_GUI_HAIKU
+ vim_unlock_screen();
+#endif
+
entered = FALSE;
--RedrawingDisabled;
@@ -9675,6 +9692,10 @@ screen_ins_lines(
clip_scroll_selection(-line_count);
#endif
+#ifdef FEAT_GUI_HAIKU
+ vim_lock_screen();
+#endif
+
#ifdef FEAT_GUI
/* Don't update the GUI cursor here, ScreenLines[] is invalid until the
* scrolling is actually carried out. */
@@ -9727,6 +9748,10 @@ screen_ins_lines(
}
}
+#ifdef FEAT_GUI_HAIKU
+ vim_unlock_screen();
+#endif
+
screen_stop_highlight();
windgoto(cursor_row, 0);
@@ -9896,6 +9921,10 @@ screen_del_lines(
clip_scroll_selection(line_count);
#endif
+#ifdef FEAT_GUI_HAIKU
+ vim_lock_screen();
+#endif
+
#ifdef FEAT_GUI
/* Don't update the GUI cursor here, ScreenLines[] is invalid until the
* scrolling is actually carried out. */
@@ -9956,6 +9985,10 @@ screen_del_lines(
}
}
+#ifdef FEAT_GUI_HAIKU
+ vim_unlock_screen();
+#endif
+
screen_stop_highlight();
#ifdef FEAT_WINDOWS
diff --git a/src/structs.h b/src/structs.h
index 3fdfb5f..a3f0ab1 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3037,6 +3037,13 @@ struct VimMenu
HMENU submenu_id; /* If this is submenu, add children here */
HWND tearoff_handle; /* hWnd of tearoff if created */
#endif
+#if FEAT_GUI_HAIKU
+ BMenuItem *id; /* Id of menu item */
+ BMenu *submenu_id; /* If this is submenu, add children here */
+# ifdef FEAT_TOOLBAR
+ BPictureButton *button;
+# endif
+#endif
#ifdef FEAT_GUI_MAC
/* MenuHandle id; */
/* short index; */ /* the item index within the father menu */
diff --git a/src/term.c b/src/term.c
index a9c2c57..e9c2311 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1314,6 +1314,11 @@ termgui_mch_get_rgb(guicolor_T color)
# define DEFAULT_TERM (char_u *)"beos-ansi"
#endif
+#ifdef __HAIKU__
+# undef DEFAULT_TERM
+# define DEFAULT_TERM (char_u *)"xterm"
+#endif
+
#ifndef DEFAULT_TERM
# define DEFAULT_TERM (char_u *)"dumb"
#endif
diff --git a/src/ui.c b/src/ui.c
index ad29190..9de4d2e 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -3122,7 +3122,7 @@ mouse_find_win(int *rowp, int *colp UNUSED)
#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \
|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_PHOTON) || defined(PROTO)
+ || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_HAIKU) || defined(PROTO)
/*
* Translate window coordinates to buffer position without any side effects
*/
diff --git a/src/version.c b/src/version.c
index cf91feb..9da8cde 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1287,6 +1287,9 @@ list_version(void)
MSG_PUTS(_("with X11-Athena GUI."));
# endif
# else
+# ifdef FEAT_GUI_HAIKU
+ MSG_PUTS(_("with Haiku GUI."));
+# else
# ifdef FEAT_GUI_PHOTON
MSG_PUTS(_("with Photon GUI."));
# else
@@ -1304,6 +1307,7 @@ list_version(void)
# endif
# endif
# endif
+# endif
# endif
# endif
# endif
diff --git a/src/vim.h b/src/vim.h
index de26c63..b219e65 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -115,6 +115,7 @@
|| defined(FEAT_GUI_ATHENA) \
|| defined(FEAT_GUI_MAC) \
|| defined(FEAT_GUI_W32) \
+ || defined(FEAT_GUI_HAIKU) \
|| defined(FEAT_GUI_PHOTON)
# define FEAT_GUI_ENABLED /* also defined with NO_X11_INCLUDES */
# if !defined(FEAT_GUI) && !defined(NO_X11_INCLUDES)
@@ -255,6 +256,11 @@
# include "os_beos.h"
#endif
+#ifdef __HAIKU__
+# include "os_haiku.h"
+# define __ARGS(x) x
+#endif
+
#if (defined(UNIX) || defined(VMS)) \
&& (!defined(MACOS_X) || defined(HAVE_CONFIG_H))
# include "os_unix.h" /* bring lots of system header files */
@@ -2072,6 +2078,9 @@ typedef struct VimClipboard
int_u format; /* Vim's own special clipboard format */
int_u format_raw; /* Vim's raw text clipboard format */
# endif
+# ifdef FEAT_GUI_HAIKU
+ /* no clipboard at the moment. TODO???? */
+# endif
} VimClipboard;
#else
typedef int VimClipboard; /* This is required for the prototypes. */
@@ -2111,7 +2120,7 @@ typedef enum
* been seen at that stage. But it must be before globals.h, where error_ga
* is declared. */
#if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \
- && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) && !defined(PROTO)
+ && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC) && !defined(PROTO) && !defined(FEAT_GUI_HAIKU)
# define mch_errmsg(str) fprintf(stderr, "%s", (str))
# define display_errors() fflush(stderr)
# define mch_msg(str) printf("%s", (str))
--
2.10.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment