summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilip Szczepański <jazz2rulez@gmail.com>2015-09-24 22:36:29 +0000
committerFilip Szczepański <jazz2rulez@gmail.com>2015-09-24 22:36:29 +0000
commit47e6eed7c987721b05b2b8cc27d0b017f92ff23a (patch)
treeea4628378a7b1a4bc98ef328d58ba1c4884a3317
parente601bd5fe8cc6525b45cd243462cd093281843d7 (diff)
Add Haiku support.
-rw-r--r--src/Makefile2
-rw-r--r--src/file.cc13
-rw-r--r--src/ncurses_ui.cc6
-rw-r--r--src/string.cc7
-rw-r--r--src/string.hh1
5 files changed, 27 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile
index bd5e871e..f3b32238 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -28,6 +28,8 @@ os := $(shell uname)
ifeq ($(os),Darwin)
LIBS += -lncurses -lboost_regex-mt
+else ifeq ($(os),Haiku)
+ LIBS += -lncursesw -lboost_regex -lnetwork -lbe
else ifneq (,$(findstring CYGWIN,$(os)))
LIBS += -lncursesw -lboost_regex -ldbghelp
else
diff --git a/src/file.cc b/src/file.cc
index 9810a3d5..2e67f872 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -20,6 +20,12 @@
#include <mach-o/dyld.h>
#endif
+#if defined(__HAIKU__)
+#include <app/Application.h>
+#include <app/Roster.h>
+#include <storage/Path.h>
+#endif
+
namespace Kakoune
{
@@ -488,6 +494,13 @@ String get_kak_binary_path()
String path = canonical_path;
free(canonical_path);
return path;
+#elif defined(__HAIKU__)
+ BApplication app("application/x-vnd.kakoune");
+ app_info info;
+ status_t status = app.GetAppInfo(&info);
+ kak_assert(status == B_OK);
+ BPath path(&info.ref);
+ return path.Path();
#else
# error "finding executable path is not implemented on this platform"
#endif
diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc
index cdcf5d50..9dfca1ad 100644
--- a/src/ncurses_ui.cc
+++ b/src/ncurses_ui.cc
@@ -21,6 +21,8 @@
#include <termios.h>
#include <unistd.h>
+constexpr char control(char c) { return c & 037; }
+
namespace Kakoune
{
@@ -506,12 +508,12 @@ Key NCursesUI::get_key()
if (c > 0 and c < 27)
{
- if (c == CTRL('l'))
+ if (c == control('l'))
{
redrawwin(m_window);
redraw();
}
- if (c == CTRL('z'))
+ if (c == control('z'))
{
raise(SIGTSTP);
return Key::Invalid;
diff --git a/src/string.cc b/src/string.cc
index e0f3525d..22d4e609 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -148,6 +148,13 @@ InplaceString<15> to_string(int val)
return res;
}
+InplaceString<23> to_string(long int val)
+{
+ InplaceString<23> res;
+ res.m_length = sprintf(res.m_data, "%li", val);
+ return res;
+}
+
InplaceString<23> to_string(size_t val)
{
InplaceString<23> res;
diff --git a/src/string.hh b/src/string.hh
index d15baa34..eb98eb03 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -278,6 +278,7 @@ struct Hex { size_t val; };
inline Hex hex(size_t val) { return {val}; }
InplaceString<15> to_string(int val);
+InplaceString<23> to_string(long int val);
InplaceString<23> to_string(size_t val);
InplaceString<23> to_string(Hex val);
InplaceString<23> to_string(float val);