Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc126f2

Browse files
committed
Add some Emacs-like keybindings to make FSI usable on Unix
1 parentff37589 commitcc126f2

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

‎src/fsharp/fsi/console.fs‎

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,46 @@ type ReadLineConsole(complete: (string option * string -> seq<string>)) =
413413
(!anchor).PlaceAt(x.Inset,!rendered);
414414
change()
415415
|_->
416-
// Note: If KeyChar=0, the not a proper char, e.g. it could be part of a multi key-press character,
417-
// e.g. e-acute is ' and e with the French (Belgium) IME and US Intl KB.
418-
// Here: skip KeyChar=0 (except for F6 which maps to 0x1A (ctrl-Z?)).
419-
if key.KeyChar<> '\000'|| key.Key= ConsoleKey.F6then
420-
insert(key);
421-
change()
422-
else
423-
// Skip and read again.
424-
read()
416+
match(key.Modifiers, key.KeyChar)with
417+
// Control-A
418+
|(ConsoleModifiers.Control, '\001')->
419+
current:=0;
420+
(!anchor).PlaceAt(x.Inset,0)
421+
change()
422+
// Control-E
423+
|(ConsoleModifiers.Control, '\005')->
424+
current:= input.Length;
425+
(!anchor).PlaceAt(x.Inset,!rendered)
426+
change()
427+
// Control-B
428+
|(ConsoleModifiers.Control, '\002')->
429+
moveLeft()
430+
change()
431+
// Control-f
432+
|(ConsoleModifiers.Control, '\006')->
433+
moveRight()
434+
change()
435+
// Control-P
436+
|(ConsoleModifiers.Control, '\020')->
437+
setInput(history.Previous());
438+
change()
439+
// Control-n
440+
|(ConsoleModifiers.Control, '\016')->
441+
setInput(history.Next());
442+
change()
443+
// Control-d
444+
|(ConsoleModifiers.Control, '\004')->
445+
raise<|new System.IO.EndOfStreamException()
446+
|_->
447+
// Note: If KeyChar=0, the not a proper char, e.g. it could be part of a multi key-press character,
448+
// e.g. e-acute is ' and e with the French (Belgium) IME and US Intl KB.
449+
// Here: skip KeyChar=0 (except for F6 which maps to 0x1A (ctrl-Z?)).
450+
if key.KeyChar<> '\000'|| key.Key= ConsoleKey.F6then
451+
insert(key);
452+
change()
453+
else
454+
// Skip and read again.
455+
read()
425456

426457
andchange()=
427458
changed:=true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp