summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-09-20 19:35:37 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-09-20 19:35:37 +0100
commit217ba625adf239770de119c3885099a652c6ecd2 (patch)
tree974c2efff9a688701d65fc24abba5361d587c74a /src
parent2aaae7473cb457d5c108536cf8539e11f6297ec9 (diff)
Use raw terminal, and handle signals manually
C-c now sends SIGINT to the process group of Kakoune server when used in normal mode. Fixes #30
Diffstat (limited to 'src')
-rw-r--r--src/ncurses.cc21
-rw-r--r--src/normal.cc4
2 files changed, 11 insertions, 14 deletions
diff --git a/src/ncurses.cc b/src/ncurses.cc
index 5ae9d083..15d38d46 100644
--- a/src/ncurses.cc
+++ b/src/ncurses.cc
@@ -211,12 +211,9 @@ void on_term_resize(int)
EventManager::instance().force_signal(0);
}
-static sig_atomic_t ctrl_c_pending = 0;
-
void on_sigint(int)
{
- ctrl_c_pending = 1;
- EventManager::instance().force_signal(0);
+ // do nothing
}
NCursesUI::NCursesUI()
@@ -224,7 +221,7 @@ NCursesUI::NCursesUI()
m_input_callback(); }}
{
initscr();
- cbreak();
+ raw();
noecho();
nonl();
intrflush(stdscr, false);
@@ -403,9 +400,6 @@ bool NCursesUI::is_key_available()
{
check_resize();
- if (ctrl_c_pending)
- return true;
-
timeout(0);
const int c = getch();
if (c != ERR)
@@ -418,17 +412,16 @@ Key NCursesUI::get_key()
{
check_resize();
- if (ctrl_c_pending)
- {
- ctrl_c_pending = false;
- return ctrl('c');
- }
-
const int c = getch();
if (c > 0 and c < 27)
{
if (c == CTRL('l'))
redrawwin(stdscr);
+ if (c == CTRL('z'))
+ {
+ raise(SIGTSTP);
+ return Key::Invalid;
+ }
return ctrl(Codepoint(c) - 1 + 'a');
}
else if (c == 27)
diff --git a/src/normal.cc b/src/normal.cc
index af85b61f..a965b709 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -17,6 +17,8 @@
#include "user_interface.hh"
#include "window.hh"
+#include <signal.h>
+
namespace Kakoune
{
@@ -1389,6 +1391,8 @@ KeyMap keymap =
{ Key::PageUp, { "scroll one page up", scroll<Key::PageUp> } },
{ Key::PageDown, { "scroll one page down", scroll<Key::PageDown> } },
+
+ { ctrl('c'), { "interupt", [](Context&, int) { killpg(getpgrp(), SIGINT); } } },
};
}