File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -20,18 +20,23 @@ fn get_input() -> String {
20
20
noecho ( ) ;
21
21
22
22
/* Prompt for a character. */
23
- printw ( "Please enter your diff (ENTER / ESC once done):\n " ) ;
23
+ printw ( "Please enter your diff, must start with double quotes (ENTER / ESC once done):\n " ) ;
24
24
let mut input = String :: new ( ) ;
25
+ let mut started = false ;
25
26
loop {
26
27
let ch = getch ( ) ;
27
- // Return if ENTER or ESC
28
- if ch == 10 || ch == 27 {
29
- refresh ( ) ;
30
- break ;
31
- } else {
32
- let c = char:: from_u32 ( ch as u32 ) . expect ( "Invalid char" ) ;
33
- printw ( & format ! ( "{}" , c) ) ;
34
- input. push ( c) ;
28
+ match ch {
29
+ 10 | 27 => break , // Return if ENTER or ESC
30
+ _ => {
31
+ let c = char:: from_u32 ( ch as u32 ) . expect ( "Invalid char" ) ;
32
+ if started || c == '"' {
33
+ printw ( & format ! ( "{}" , c) ) ;
34
+ input. push ( c) ;
35
+ if !started {
36
+ started = true ;
37
+ }
38
+ }
39
+ }
35
40
}
36
41
refresh ( ) ;
37
42
}
You can’t perform that action at this time.
0 commit comments