|
8 | 8 | import com.intellij.openapi.util.Pair; |
9 | 9 | import com.intellij.util.Consumer; |
10 | 10 | import com.jetbrains.idear.GoogleHelper; |
| 11 | +import com.jetbrains.idear.WordToNumberConverter; |
11 | 12 | import com.jetbrains.idear.actions.ExecuteVoiceCommandAction; |
12 | 13 | import com.jetbrains.idear.actions.recognition.SurroundWithNoNullCheckRecognizer; |
13 | 14 | import com.jetbrains.idear.ide.IDEService; |
@@ -49,7 +50,7 @@ public ASRControlLoop(CustomLiveSpeechRecognizer recognizer) { |
49 | 50 | public static final String EDITOR = "editor"; |
50 | 51 | public static final String PROJECT = "project"; |
51 | 52 | public static final String SELECTION = "selection"; |
52 | | - public static final String EXPAND = "expand"; |
| 53 | + public static final String EXPAND = "grow"; |
53 | 54 | public static final String SHRINK = "shrink"; |
54 | 55 | public static final String PRESS = "press"; |
55 | 56 | public static final String DELETE = "delete"; |
@@ -128,25 +129,28 @@ private void applyAction(String c) { |
128 | 129 | // TODO(kudinkin): extract to action |
129 | 130 | ideService.invokeAction("Idear.WhereAmI"); |
130 | 131 | } else if (c.startsWith("focus")) { |
131 | | - if (c.endsWith("editor")) { |
| 132 | + if (c.endsWith(EDITOR)) { |
132 | 133 | pressKeystroke(KeyEvent.VK_ESCAPE); |
133 | | - } else if (c.endsWith("project")) { |
| 134 | + } else if (c.endsWith(PROJECT)) { |
134 | 135 | pressKeystroke(KeyEvent.VK_ALT, KeyEvent.VK_1); |
| 136 | + } else if(c.endsWith("symbols")) { |
| 137 | + ideService.invokeAction("AceJumpAction"); |
| 138 | + ideService.type(("" + recognizeNumber()).toCharArray()); |
135 | 139 | } |
136 | | - } else if (c.startsWith("grow")) { |
| 140 | + } else if (c.startsWith(EXPAND)) { |
137 | 141 | pressKeystroke(KeyEvent.VK_CONTROL, KeyEvent.VK_W); |
138 | | - } else if (c.startsWith("shrink")) { |
| 142 | + } else if (c.startsWith(SHRINK)) { |
139 | 143 | pressKeystroke(KeyEvent.VK_CONTROL, KeyEvent.VK_SHIFT, KeyEvent.VK_W); |
140 | 144 | } else if (c.startsWith("press")) { |
141 | 145 | if (c.contains("delete")) { |
142 | 146 | pressKeystroke(KeyEvent.VK_DELETE); |
143 | 147 | } else if (c.contains("return")) { |
144 | 148 | pressKeystroke(KeyEvent.VK_ENTER); |
145 | | - } else if (c.contains("escape")) { |
| 149 | + } else if (c.contains(ESCAPE)) { |
146 | 150 | pressKeystroke(KeyEvent.VK_ESCAPE); |
147 | | - } else if (c.contains("tab")) { |
| 151 | + } else if (c.contains(TAB)) { |
148 | 152 | pressKeystroke(KeyEvent.VK_TAB); |
149 | | - } else if (c.contains("undo")) { |
| 153 | + } else if (c.contains(UNDO)) { |
150 | 154 | pressKeystroke(KeyEvent.VK_CONTROL, KeyEvent.VK_Z); |
151 | 155 | } |
152 | 156 | } else if (c.startsWith("following")) { |
@@ -207,7 +211,7 @@ private void applyAction(String c) { |
207 | 211 |
|
208 | 212 | private void pressKeystroke(final int... keys) { |
209 | 213 | ServiceManager.getService(IDEService.class) |
210 | | - .pressKeystroke(keys); |
| 214 | + .type(keys); |
211 | 215 | } |
212 | 216 |
|
213 | 217 | private void run(SurroundWithNoNullCheckRecognizer rec, String c, DataContext dataContext) { |
@@ -313,6 +317,15 @@ private void pauseSpeech() { |
313 | 317 | } |
314 | 318 | } |
315 | 319 |
|
| 320 | + private int recognizeNumber() { |
| 321 | + String result; |
| 322 | + while(true) { |
| 323 | + result = getResultFromRecognizer(); |
| 324 | + if(result.startsWith("jump ")) |
| 325 | + return WordToNumberConverter.getNumber(result.substring(5)); |
| 326 | + } |
| 327 | + } |
| 328 | + |
316 | 329 | // Helpers |
317 | 330 |
|
318 | 331 | public synchronized void say(String something) { |
|
0 commit comments