Implement common emacs bindings (closes #3)
This commit is contained in:
parent
6382f10dae
commit
9dd2f06160
|
@ -413,7 +413,7 @@ namespace tgcli {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CloseCommand : Command {
|
public class CloseCommand : Command {
|
||||||
public CloseCommand() : base("c", "^E", "closes a chat", "", 0) { }
|
public CloseCommand() : base("c", "^D", "closes a chat", "", 0) { }
|
||||||
|
|
||||||
public override void Handler(List<string> inputParams) {
|
public override void Handler(List<string> inputParams) {
|
||||||
if (currentChatId == 0) {
|
if (currentChatId == 0) {
|
||||||
|
@ -486,7 +486,7 @@ namespace tgcli {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UnreadsCommand : Command {
|
public class UnreadsCommand : Command {
|
||||||
public UnreadsCommand() : base("u", "^U", "displays unread chat", "[all]", -1) { }
|
public UnreadsCommand() : base("u", "", "displays unread chat", "[all]", -1) { }
|
||||||
|
|
||||||
public override void Handler(List<string> inputParams) {
|
public override void Handler(List<string> inputParams) {
|
||||||
var unreads = GetUnreadChats(inputParams.Count == 1 && inputParams[0].Equals("all"));
|
var unreads = GetUnreadChats(inputParams.Count == 1 && inputParams[0].Equals("all"));
|
||||||
|
|
|
@ -289,22 +289,11 @@ namespace tgcli {
|
||||||
// InsertToInputLine("⏎ ");
|
// InsertToInputLine("⏎ ");
|
||||||
// ScreenUpdate();
|
// ScreenUpdate();
|
||||||
// return;
|
// return;
|
||||||
case ConsoleKey.D when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
|
||||||
HandleCommand(currentChatId == 0 ? "q" : "c");
|
|
||||||
ScreenUpdate();
|
|
||||||
return;
|
|
||||||
case ConsoleKey.Q when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
case ConsoleKey.Q when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
HandleCommand("q");
|
HandleCommand("q");
|
||||||
ScreenUpdate();
|
ScreenUpdate();
|
||||||
return;
|
return;
|
||||||
case ConsoleKey.E when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
|
||||||
HandleCommand("c");
|
|
||||||
ScreenUpdate();
|
|
||||||
return;
|
|
||||||
case ConsoleKey.U when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
|
||||||
HandleCommand("u");
|
|
||||||
ScreenUpdate();
|
|
||||||
return;
|
|
||||||
case ConsoleKey.O when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
case ConsoleKey.O when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
SetInputLine(currentInputLine switch {
|
SetInputLine(currentInputLine switch {
|
||||||
"/o " => "/os ",
|
"/o " => "/os ",
|
||||||
|
@ -314,10 +303,30 @@ namespace tgcli {
|
||||||
});
|
});
|
||||||
ScreenUpdate();
|
ScreenUpdate();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// standard terminal commands
|
||||||
case ConsoleKey.L when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
case ConsoleKey.L when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
HandleCommand("cl");
|
HandleCommand("cl");
|
||||||
ScreenUpdate();
|
ScreenUpdate();
|
||||||
return;
|
return;
|
||||||
|
case ConsoleKey.D when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
|
HandleCommand(currentChatId == 0 ? "q" : "c");
|
||||||
|
ScreenUpdate();
|
||||||
|
return;
|
||||||
|
|
||||||
|
// input navigation
|
||||||
|
case ConsoleKey.U when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
|
SetInputLine("");
|
||||||
|
ScreenUpdate();
|
||||||
|
return;
|
||||||
|
case ConsoleKey.A when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
|
currentInputPos = 0;
|
||||||
|
ScreenUpdate();
|
||||||
|
return;
|
||||||
|
case ConsoleKey.E when key.Modifiers.HasFlag(ConsoleModifiers.Control):
|
||||||
|
currentInputPos = currentInputLine.Length;
|
||||||
|
ScreenUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SpecialKeys.Contains(key.Key)) {
|
if (!SpecialKeys.Contains(key.Key)) {
|
||||||
|
|
Loading…
Reference in a new issue