aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2014-08-13 20:05:17 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2014-08-13 20:05:17 -0400
commita6d0ada40989f79ee9e0e17192bc8d771ad385d7 (patch)
tree6bc2d68e3afffa7c993efdebe7de35b510bebeb1
parentabe812c69f14fe91179f0f683aef702280fa37bb (diff)
downloadtextadept-a6d0ada40989f79ee9e0e17192bc8d771ad385d7.tar.gz
textadept-a6d0ada40989f79ee9e0e17192bc8d771ad385d7.zip
Separate ^H from Backspace in the terminal version.
Also have libtermkey take care of saving and restoring termios.
-rw-r--r--doc/manual.md1
-rw-r--r--modules/textadept/keys.lua4
-rw-r--r--src/cdk.patch21
-rw-r--r--src/textadept.c25
4 files changed, 31 insertions, 20 deletions
diff --git a/doc/manual.md b/doc/manual.md
index 6d5ab8b6..18862919 100644
--- a/doc/manual.md
+++ b/doc/manual.md
@@ -1645,6 +1645,7 @@ made to CDK are in *src/cdk.patch* and listed as follows:
* The `baseName` and `dirName` functions in *cdk.c* recognize Window's '\'
directory separator.
* Deactivated the `deleteFileCB` function in *fselect.c*.
+* Removed some of CDK's initial screen handling code.
[CDK]: http://invisible-island.net/cdk/
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index ba2aac5e..c844bea6 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -602,8 +602,8 @@ elseif CURSES then
keys.mA, keys.mE = buffer.vc_home_extend, buffer.line_end_extend
keys.mU, keys.mD = buffer.page_up_extend, buffer.page_down_extend
keys.cma, keys.cme = buffer.document_start, buffer.document_end
- keys.cd, keys.md = buffer.clear, utils.delete_word
- keys.ck = utils.cut_to_eol
+ keys.cd, keys.ch = buffer.clear, buffer.delete_back
+ keys.md, keys.ck = utils.delete_word, utils.cut_to_eol
end
-- Modes.
diff --git a/src/cdk.patch b/src/cdk.patch
index 0ccbb9ea..b9fc42b9 100644
--- a/src/cdk.patch
+++ b/src/cdk.patch
@@ -287,6 +287,27 @@ diff -r 9d0780ddcbab cdk_version.h
+#endif
+
+#endif /* CDK_VERSION_H */
+diff -r ea979bb3ae11 cdkscreen.c
+--- a/cdkscreen.c Wed Aug 13 13:55:58 2014 -0400
++++ b/cdkscreen.c Wed Aug 13 16:14:54 2014 -0400
+@@ -180,17 +180,6 @@
+ ALL_SCREENS *item;
+ CDKSCREEN *screen = 0;
+
+- /* initialization, for the first time */
+- if (all_screens == 0)
+- {
+- /* Set up basic curses settings. */
+-#ifdef HAVE_SETLOCALE
+- setlocale (LC_ALL, "");
+-#endif
+- noecho ();
+- cbreak ();
+- }
+-
+ if ((item = typeMalloc (ALL_SCREENS)) != 0)
+ {
+ if ((screen = typeCalloc (CDKSCREEN)) != 0)
diff -r 9d0780ddcbab entry.c
--- a/entry.c 2013-06-16 09:12:32.000000000 -0400
+++ b/entry.c 2013-12-17 16:52:52.969973100 -0500
diff --git a/src/textadept.c b/src/textadept.c
index 1cc906b8..0812db16 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -51,7 +51,7 @@
#include "windowman.h"
#include "cdk_int.h"
#if !_WIN32
-#include "termkey.h"
+#include "termkey-internal.h"
#endif
#endif
@@ -151,7 +151,6 @@ static GtkEntryCompletion *command_entry_completion;
// curses window.
static struct WindowManager *wm;
#if !_WIN32
-static struct termios term;
TermKey *ta_tk; // global for CDK use
#endif
#define SS(view, msg, w, l) scintilla_send_message(view, msg, w, l)
@@ -423,9 +422,6 @@ static int lfind_focus(lua_State *L) {
if (findbox) return 0; // already active
wresize(scintilla_get_window(focused_view), LINES - 4, COLS);
findbox = initCDKScreen(newwin(2, 0, LINES - 3, 0)), eraseCDKScreen(findbox);
-#if !_WIN32
- tcsetattr(0, TCSANOW, &term);
-#endif
int b_width = max(strlen(button_labels[0]), strlen(button_labels[1])) +
max(strlen(button_labels[2]), strlen(button_labels[3])) + 3;
int o_width = max(strlen(option_labels[0]), strlen(option_labels[1])) +
@@ -583,9 +579,6 @@ static int lce_focus(lua_State *L) {
#elif CURSES
if (command_entry) return 0; // already active
CDKSCREEN *screen = initCDKScreen(newwin(1, 0, LINES - 2, 0));
-#if !_WIN32
- tcsetattr(0, TCSANOW, &term);
-#endif
command_entry = newCDKEntry(screen, LEFT, TOP, NULL, NULL, A_NORMAL, '_',
vMIXED, 0, 0, 256, FALSE, FALSE);
bindCDKObject(vENTRY, command_entry, KEY_TAB, c_keypress, NULL);
@@ -2396,9 +2389,8 @@ int main(int argc, char **argv) {
gtk_init(&argc, &argv);
#elif CURSES
#if !_WIN32
- struct termios oldterm;
- tcgetattr(0, &oldterm); // save old terminal settings
- ta_tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS);
+ ta_tk = termkey_new(0, 0);
+ ta_tk->c0[0x08].sym = TERMKEY_SYM_UNKNOWN; // prevent Backspace to ^H mapping
#endif
setlocale(LC_CTYPE, ""); // for displaying UTF-8 characters properly
initscr(); // raw()/cbreak() and noecho() are taken care of in libtermkey
@@ -2477,12 +2469,10 @@ int main(int argc, char **argv) {
#if !_WIN32
stderr = freopen("/dev/null", "w", stderr); // redirect stderr
- // Ignore some termios (from GNU Nano).
- tcgetattr(0, &term);
- term.c_iflag &= ~IEXTEN, term.c_iflag &= ~IXON;
- term.c_oflag &= ~OPOST;
- term.c_lflag &= ~ISIG;
- tcsetattr(0, TCSANOW, &term);
+ // Prevent ^C from generating SIGINT. TERMKEY_FLAG_CTRLC is ineffective since
+ // initscr() overrides it.
+ struct termios term;
+ tcgetattr(0, &term), term.c_lflag &= ~ISIG, tcsetattr(0, TCSANOW, &term);
// Set terminal resize handler.
struct sigaction act;
memset(&act, 0, sizeof(struct sigaction));
@@ -2557,7 +2547,6 @@ int main(int argc, char **argv) {
endwin();
#if !_WIN32
termkey_destroy(ta_tk);
- tcsetattr(0, TCSANOW, &oldterm); // restore old terminal settings
#endif
#endif