Fixes issue ROOT-10285; introduced in 0e90d01afe13c12fafd1002a5bf9fd6f8bc2fbb0.

Defer translation of Ctrl-D to a delete command.

(cherry picked from commit 9d86ce6ae5df200749a70a27956d194a6978e871)
This commit is contained in:
Javier Lopez-Gomez
2019-09-24 10:48:27 +02:00
committed by Axel Naumann
parent fc63a9f205
commit ed3b079e93
3 changed files with 10 additions and 8 deletions

View File

@ -110,6 +110,8 @@ namespace textinput {
EMoveID GetMoveID() const { return fMove;} EMoveID GetMoveID() const { return fMove;}
char GetChar() const { return fChar;} char GetChar() const { return fChar;}
bool isCtrlD() const { return fKind == kCKControl
&& (fChar == 'd'-0x60); }
private: private:
ECommandKind fKind; // discriminator for union ECommandKind fKind; // discriminator for union
union { union {

View File

@ -48,9 +48,8 @@ namespace textinput {
switch (In) { switch (In) {
case 'a' - 0x60: return C(Editor::kMoveFront); case 'a' - 0x60: return C(Editor::kMoveFront);
case 'b' - 0x60: return C(Editor::kMoveLeft); case 'b' - 0x60: return C(Editor::kMoveLeft);
case 'c' - 0x60: case 'c' - 0x60: return C(In, Editor::kCKControl);
return C(In, Editor::kCKControl); case 'd' - 0x60: return C(In, Editor::kCKControl);
case 'd' - 0x60: return C(Editor::kCmdDel);
case 'e' - 0x60: return C(Editor::kMoveEnd); case 'e' - 0x60: return C(Editor::kMoveEnd);
case 'f' - 0x60: return C(Editor::kMoveRight); case 'f' - 0x60: return C(Editor::kMoveRight);
case 'g' - 0x60: return C(Editor::kMoveRight); case 'g' - 0x60: return C(Editor::kMoveRight);

View File

@ -148,6 +148,10 @@ namespace textinput {
fLastKey = in.GetRaw(); // rough approximation fLastKey = in.GetRaw(); // rough approximation
Editor::Command Cmd = fContext->GetKeyBinding()->ToCommand(in); Editor::Command Cmd = fContext->GetKeyBinding()->ToCommand(in);
// Translate Ctrl-D to delete if input line is not empty, as GNU readline does.
if (!fContext->GetLine().empty() && Cmd.isCtrlD())
Cmd = Editor::Command(Editor::kCmdDel);
if (Cmd.GetKind() == Editor::kCKControl if (Cmd.GetKind() == Editor::kCKControl
&& (Cmd.GetChar() == 3 || Cmd.GetChar() == 26)) { && (Cmd.GetChar() == 3 || Cmd.GetChar() == 26)) {
// If there are modifications in the queue, process them now. // If there are modifications in the queue, process them now.
@ -158,11 +162,8 @@ namespace textinput {
std::for_each(fContext->GetDisplays().begin(), std::for_each(fContext->GetDisplays().begin(),
fContext->GetDisplays().end(), fContext->GetDisplays().end(),
[](Display *D) { return D->NotifyWindowChange(); }); [](Display *D) { return D->NotifyWindowChange(); });
} else if (Cmd.GetKind() == Editor::kCKCommand } else if (Cmd.isCtrlD()) {
&& Cmd.GetCommandID() == Editor::kCmdDel && fContext->SetLine(".q"), Redraw();
!fContext->GetLine().length()) {
fContext->SetLine(".q");
Redraw();
fLastReadResult = kRREOF; fLastReadResult = kRREOF;
return; return;
} else { } else {