Есть ли способ использовать ctrl-d для удаления в REPL в Scala? - PullRequest
4 голосов
/ 22 марта 2011

Таким образом, в REPL Scala я могу использовать ctrl- {p, n, a, e} для выполнения предыдущей, следующей, начала и конца строки.Тем не менее, я скоро сойду с ума, если не смогу использовать ctrl-d для удаления вперед.

Можно ли каким-то образом этого добиться?

Я использую Mac.

Обновление

Добавьте следующие строки к принятому ответу, чтобы получить ctrl- {a, e}.Более крупный файл привязок ключей можно найти в репозитории jline2 jline2 на GitHub .

# CTRL-A: move to the beginning of the line
1=MOVE_TO_BEG

# CTRL-E: move the cursor to the end of the line
5=MOVE_TO_END

Update2

Я только что установил Scala 2.9.0.final, и я могу подтвердить, что ctrl-d теперь работает как надо.Это прямое удаление, если это не пустая строка, когда он завершает оболочку.

Ответы [ 2 ]

4 голосов
/ 22 марта 2011

Вот очень минимальный файл свойств привязки клавиш, включая желаемое ^D:

# CTRL-B: move to the previous character
2: PREV_CHAR

# CTRL-D: delete the previous character
4: DELETE_NEXT_CHAR

# CTRL-F: move to the next character
6: NEXT_CHAR

# BACKSPACE, CTRL-H: delete the previous character
# 8 is the ASCII code for backspace and therefor
# deleting the previous character
8: DELETE_PREV_CHAR

# TAB, CTRL-I: signal that console completion should be attempted
9: COMPLETE

# CTRL-J, CTRL-M: newline
10: NEWLINE

# ENTER: newline
13: NEWLINE

# CTRL-N: scroll to the next element in the history buffer
14: NEXT_HISTORY

# CTRL-P: scroll to the previous element in the history buffer
16: PREV_HISTORY

# CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
22: PASTE

# DELETE, CTRL-?: delete the previous character
# 127 is the ASCII code for delete
127: DELETE_PREV_CHAR

Поместите его в файл и вызовите scala следующим образом:

scala -Djline.keybindings=/path/to/keybindings.properties

Или passэто через JAVA_OPTS.Вам нужно будет посмотреть в Интернете, какие существуют сочетания клавиш, и попробовать :keybindings из Scala, чтобы узнать, какие значения по умолчанию (хотя это не будет отражать ваши фактические сочетания клавиш).

3 голосов
/ 22 марта 2011

в REPL Scala 2.9 у вас есть новая команда: keybindings.Это показывает:

scala> :keybindings
Reading jline properties for default key bindings.
Accuracy not guaranteed: treat this as a guideline only.

  1 CTRL-A: move to the beginning of the line
  2 CTRL-B: move to the previous character
  4 CTRL-D: close out the input stream
  5 CTRL-E: move the cursor to the end of the line
  6 CTRL-F: move to the next character
  7 CTRL-G: abort
  8 BACKSPACE, CTRL-H: delete the previous character 8 is the ASCII code for backspace and therefor deleting the previous character
  9 TAB, CTRL-I: signal that console completion should be attempted
 10 CTRL-J, CTRL-M: newline
 11 CTRL-K: erase the current line
 12 CTRL-L: clear screen
 13 ENTER: newline
 14 CTRL-N: scroll to the next element in the history buffer
 15 CTRL-O: move to the previous word
 16 CTRL-P: scroll to the previous element in the history buffer
 18 CTRL-R: redraw the current line
 21 CTRL-U: delete all the characters before the cursor position
 22 CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
 23 CTRL-W: delete the word directly before the cursor
127 DELETE, CTRL-?: delete the next character 127 is the ASCII code for delete

на ноутбуках MacBook, DELETE можно получить с помощью Fn + BACKSPACE.

...