From 47e6eed7c987721b05b2b8cc27d0b017f92ff23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Szczepa=C5=84ski?= Date: Thu, 24 Sep 2015 22:36:29 +0000 Subject: [PATCH] Add Haiku support. --- src/Makefile | 2 ++ src/file.cc | 13 +++++++++++++ src/ncurses_ui.cc | 6 ++++-- src/string.cc | 7 +++++++ src/string.hh | 1 + 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 #endif +#if defined(__HAIKU__) +#include +#include +#include +#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 #include +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);