2011-03-21 2 views
4

스칼라 REPL에서, 나는 ctrl- {p, n, a, e}를 사용하여 선의 이전, 다음, 시작 및 끝을 처리 할 수 ​​있습니다. 그러나 ctrl-d를 사용하여 전달 삭제할 수 없다면 곧 나올 것입니다.Scala의 REPL에서 ctrl-d를 정방향 삭제로 사용할 수 있습니까?

어떤 방법으로 이것을 달성 할 수 있습니까?

저는 Mac을 사용하고 있습니다.

업데이트 CTRL- {A, E}를 얻기 위해 허용 대답에 다음 줄을 추가합니다. 더 큰 키 바인딩 파일은 jline2 repo jline2 repo at 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 

갱신 2

난 그냥 스칼라 2.9.0.final 설치하고 난 Ctrl-D를 지금 정상적으로 작동하는지 확인할 수 있습니다. 쉘을 종료 할 때 빈 줄이 아니라면 앞으로 삭제됩니다.

답변

4

여기를 포함하여, 아주 최소한의 키 바인딩 특성 파일의 당신의 ^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 -Djline.keybindings=/path/to/keybindings.properties 

또는 JAVA_OPTS를 통해 전달합니다. 인터넷에 어떤 키 바인딩이 있는지 찾아보고 스칼라에서 :keybindings을 시도하여 기본값이 무엇인지 확인해야합니다 (실제 키 바인딩을 반영하지는 않습니다).

3

의 scala 2.9의 REPL에는 new : 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 

DELETEFn + BACKSPACE을 통해 액세스 할 수 있습니다.