- get rid of control chars in source files (ESC and CTRL-L)
- fix Home and End keys - simplify code - add different strings for Ctrl-arrows, allows to map them to previous/next-word (PuTTY and others have actually several codes depending on mods & ALT, mode & CTRL and even mods & CTRL|ALT, might be even better...). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25391 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f7cc12b389
commit
85b80c5229
@ -72,7 +72,7 @@ CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int codi
|
||||
// system api for code conversion... check if this (which looks a lot like a workaround)
|
||||
// applies to haiku, and if not, get rid of this class and just use the system api directly.
|
||||
if (coding == B_EUC_CONVERSION && state != 0) {
|
||||
const char *end_of_jis = "(B";
|
||||
const char *end_of_jis = "\033(B";
|
||||
strncpy((char *)dst + dstlen, end_of_jis, 3);
|
||||
dstlen += 3;
|
||||
}
|
||||
|
@ -1483,26 +1483,28 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
// Terminal filters RET, ENTER, F1...F12, and ARROW key code.
|
||||
// TODO: Cleanup
|
||||
if (numBytes == 1) {
|
||||
const char *toWrite = NULL;
|
||||
switch (*bytes) {
|
||||
case B_RETURN:
|
||||
if (rawChar == B_RETURN) {
|
||||
char c = 0x0d;
|
||||
fShell->Write(&c, 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_RETURN)
|
||||
toWrite = "\r";
|
||||
break;
|
||||
|
||||
case B_LEFT_ARROW:
|
||||
if (rawChar == B_LEFT_ARROW) {
|
||||
fShell->Write(LEFT_ARROW_KEY_CODE, sizeof(LEFT_ARROW_KEY_CODE) - 1);
|
||||
return;
|
||||
if (mod & B_CONTROL_KEY)
|
||||
toWrite = CTRL_LEFT_ARROW_KEY_CODE;
|
||||
else
|
||||
toWrite = LEFT_ARROW_KEY_CODE;
|
||||
}
|
||||
break;
|
||||
|
||||
case B_RIGHT_ARROW:
|
||||
if (rawChar == B_RIGHT_ARROW) {
|
||||
fShell->Write(RIGHT_ARROW_KEY_CODE, sizeof(RIGHT_ARROW_KEY_CODE) - 1);
|
||||
return;
|
||||
if (mod & B_CONTROL_KEY)
|
||||
toWrite = CTRL_RIGHT_ARROW_KEY_CODE;
|
||||
else
|
||||
toWrite = RIGHT_ARROW_KEY_CODE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1515,8 +1517,10 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_UP_ARROW) {
|
||||
fShell->Write(UP_ARROW_KEY_CODE, sizeof(UP_ARROW_KEY_CODE) - 1);
|
||||
return;
|
||||
if (mod & B_CONTROL_KEY)
|
||||
toWrite = CTRL_UP_ARROW_KEY_CODE;
|
||||
else
|
||||
toWrite = UP_ARROW_KEY_CODE;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1528,30 +1532,26 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
if (rawChar == B_DOWN_ARROW) {
|
||||
fShell->Write(DOWN_ARROW_KEY_CODE, sizeof(DOWN_ARROW_KEY_CODE) - 1);
|
||||
return;
|
||||
if (mod & B_CONTROL_KEY)
|
||||
toWrite = CTRL_DOWN_ARROW_KEY_CODE;
|
||||
else
|
||||
toWrite = DOWN_ARROW_KEY_CODE;
|
||||
}
|
||||
break;
|
||||
|
||||
case B_INSERT:
|
||||
if (rawChar == B_INSERT) {
|
||||
fShell->Write(INSERT_KEY_CODE, sizeof(INSERT_KEY_CODE) - 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_INSERT)
|
||||
toWrite = INSERT_KEY_CODE;
|
||||
break;
|
||||
|
||||
case B_HOME:
|
||||
if (rawChar == B_HOME) {
|
||||
fShell->Write(HOME_KEY_CODE, sizeof(HOME_KEY_CODE) - 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_HOME)
|
||||
toWrite = HOME_KEY_CODE;
|
||||
break;
|
||||
|
||||
case B_END:
|
||||
if (rawChar == B_END) {
|
||||
fShell->Write(END_KEY_CODE, sizeof(END_KEY_CODE) - 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_END)
|
||||
toWrite = END_KEY_CODE;
|
||||
break;
|
||||
|
||||
case B_PAGE_UP:
|
||||
@ -1562,10 +1562,8 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_PAGE_UP) {
|
||||
fShell->Write(PAGE_UP_KEY_CODE, sizeof(PAGE_UP_KEY_CODE) - 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_PAGE_UP)
|
||||
toWrite = PAGE_UP_KEY_CODE;
|
||||
break;
|
||||
|
||||
case B_PAGE_DOWN:
|
||||
@ -1575,10 +1573,8 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
return;
|
||||
}
|
||||
|
||||
if (rawChar == B_PAGE_DOWN) {
|
||||
fShell->Write(PAGE_DOWN_KEY_CODE, sizeof(PAGE_DOWN_KEY_CODE) - 1);
|
||||
return;
|
||||
}
|
||||
if (rawChar == B_PAGE_DOWN)
|
||||
toWrite = PAGE_DOWN_KEY_CODE;
|
||||
break;
|
||||
|
||||
case B_FUNCTION_KEY:
|
||||
@ -1593,6 +1589,10 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (toWrite) {
|
||||
fShell->Write(toWrite, strlen(toWrite));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// input multibyte character
|
||||
if (fEncoding != M_UTF8) {
|
||||
@ -1636,7 +1636,7 @@ void
|
||||
TermView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
entry_ref ref;
|
||||
char *ctrl_l = "";
|
||||
char *ctrl_l = "\x0c";
|
||||
|
||||
// first check for any dropped message
|
||||
if (msg->WasDropped()) {
|
||||
|
@ -48,16 +48,16 @@ F12_KEY,
|
||||
|
||||
char *function_key_char_table [] =
|
||||
{
|
||||
"[11~",
|
||||
"[12~",
|
||||
"[13~",
|
||||
"[14~",
|
||||
"[15~",
|
||||
"[16~",
|
||||
"[17~",
|
||||
"[18~",
|
||||
"[19~",
|
||||
"[20~",
|
||||
"[21~",
|
||||
"[22~",
|
||||
"\033[11~",
|
||||
"\033[12~",
|
||||
"\033[13~",
|
||||
"\033[14~",
|
||||
"\033[15~",
|
||||
"\033[16~",
|
||||
"\033[17~",
|
||||
"\033[18~",
|
||||
"\033[19~",
|
||||
"\033[20~",
|
||||
"\033[21~",
|
||||
"\033[22~",
|
||||
};
|
||||
|
@ -65,16 +65,23 @@
|
||||
|
||||
|
||||
|
||||
#define LEFT_ARROW_KEY_CODE "[D"
|
||||
#define RIGHT_ARROW_KEY_CODE "[C"
|
||||
#define UP_ARROW_KEY_CODE "[A"
|
||||
#define DOWN_ARROW_KEY_CODE "[B"
|
||||
#define LEFT_ARROW_KEY_CODE "\033[D"
|
||||
#define RIGHT_ARROW_KEY_CODE "\033[C"
|
||||
#define UP_ARROW_KEY_CODE "\033[A"
|
||||
#define DOWN_ARROW_KEY_CODE "\033[B"
|
||||
|
||||
#define HOME_KEY_CODE "[@"
|
||||
#define INSERT_KEY_CODE "[2~"
|
||||
#define END_KEY_CODE "[["
|
||||
#define PAGE_UP_KEY_CODE "[5~"
|
||||
#define PAGE_DOWN_KEY_CODE "[6~"
|
||||
#define CTRL_LEFT_ARROW_KEY_CODE "\033[5D"
|
||||
#define CTRL_RIGHT_ARROW_KEY_CODE "\033[5C"
|
||||
#define CTRL_UP_ARROW_KEY_CODE "\033[5A"
|
||||
#define CTRL_DOWN_ARROW_KEY_CODE "\033[5B"
|
||||
|
||||
//#define HOME_KEY_CODE "\033[@"
|
||||
#define HOME_KEY_CODE "\033[1~"
|
||||
#define INSERT_KEY_CODE "\033[2~"
|
||||
//#define END_KEY_CODE "\033[["
|
||||
#define END_KEY_CODE "\033[4~"
|
||||
#define PAGE_UP_KEY_CODE "\033[5~"
|
||||
#define PAGE_DOWN_KEY_CODE "\033[6~"
|
||||
|
||||
//#define IS_DOWN_KEY(x) (info.key_states[(x) / 8] & key_state_table[(x) % 8])
|
||||
#define IS_DOWN_KEY(x) \
|
||||
|
Loading…
Reference in New Issue
Block a user