Skip to content

Commit 2fbdf10

Browse files
committed
I hope final
1 parent 7199353 commit 2fbdf10

22 files changed

+149
-173
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
PythonVoiceCodingPlugin is a Sublime Text 3 plugin meant to enhance user experience
88
when coding python 3 by voice.
99

10-
![](doc/gif/big0.gif)
10+
![](doc/gif/big2.gif)
1111

1212
## Motivation
1313

1414
The project was inspired by [Gustav Wengel's article](https://medium.com/bambuu/state-of-voice-coding-2017-3d2ff41c5015) on the state of voice coding and my personal experiences
15-
with [Caster](https://github.com/dictation-toolbox/Caster). Despite the excellent work put behind this trully awesome dragonfly based toolkit, I felt there were cases we could do slightly better:)
15+
with [Caster](https://github.com/dictation-toolbox/Caster). Despite the excellent work put behind this trully awesome [dragonfly](https://github.com/t4ngo/dragonfly) based toolkit, I felt there were cases we could do slightly better:)
1616

1717
In particular, navigation through the code sometimes felt a little bit too mechanistic. Say for instance you want to go to some location or select some text. For the most part ,you are describing what actions
1818
need to be taken to get there. What if you could instead simply describe (syntactically) what you want to select?
@@ -47,11 +47,14 @@ I want to be honest. This is not exactly the best code ever written. It is far f
4747
* is partly customizable. If you find yourself using certain commands with some given parameters often and want a shorthand smaller command, you can always follow my commented banana example:)
4848

4949

50-
As I said, far from perfect but nonetheless an out-of-the-box solution which I hope to be helpful ,especially for beginners to get up to speed , and a step towards the right direction. I hope you enjoy using it as much as I have enjoyed coding it:)
50+
As I said, far (really far) from perfect but nonetheless an out-of-the-box solution which I hope to be helpful ,especially for beginners to get up to speed , and a step towards the right direction. I hope you enjoy using it as much as I have enjoyed coding it:)
51+
52+
Needless to say, while coding PythonVoiceCodingPlugin , PythonVoiceCodingPlugin was used :)
5153

5254
## Release and Version
5355

54-
Currently in preparation of the initial 0.0.0 release , probably between 5-10/11 :)
56+
The code is available on [github](https://github.com/mpourmpoulis/PythonVoiceCodingPlugin)
57+
along with its initial release (0.0.0)!
5558

5659

5760

@@ -213,5 +216,5 @@ Many thanks to all of the developers that have put their time and effort behind
213216
* Caster
214217

215218

216-
needless to say, while coding PythonVoiceCodingPlugin I used PythonVoiceCodingPlugin :)
219+
217220

application/application.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def respond_to_query(self,interface,query_description):
6060
self.state["alternatives"] = alternatives
6161
interface.push_action(DisplayRegionsAction("alternatives",alternatives,"Alternatives:\n"))
6262
interface.push_action(HighlightCleverAction(alternatives,"alternatives",result))
63+
6364
elif isinstance(s,InsertionQuery):
6465
output = s.writing_locations_text
6566
selections = s.optional_selection
@@ -81,6 +82,7 @@ def respond_to_query(self,interface,query_description):
8182
if items:
8283
interface.push_action(DisplayNiceAction(items,True))
8384
self.state["collection"] = items
85+
self.history.append(("collect"))
8486
if selections:
8587
interface.push_action(SelectionAction(selections))
8688

bundles/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Grammar bundles
2+
13
This folder contains my grammar and other related stuff
24

35
For the time being I only release bundles for Caster 0.5.11, these are in the Caster folder.

doc/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44

55
Here we will briefly go over the commands offered.
66

7-
Before we get started, a small general remark: virtually every command starts with the keyword smart!
8-
This was chosen in order to minimize chances of collision with other commands on your system.
7+
Before we get started, a small general remark:
8+
```
9+
tip: if you do not know what to say, say smart :P
10+
```
11+
12+
because virtually every command starts with the keyword smart!
913

1014
```python
1115
"smart <big_roi> [<big_roi_sub_index>]"
1216

1317
"smart <color> [alternative]"
1418
```
1519

16-
however, because for a variety of commands, ommitting the keyword smart makes them more convenient and easier to speak
20+
This was chosen in order to minimize chances of collision with other commands on your system. However, because for a variety of commands, ommitting the keyword smart makes them more convenient and easier to speak
1721
you may find the smart keyword in brackets
1822

1923
```python
@@ -24,7 +28,7 @@ you may find the smart keyword in brackets
2428
"[smart] paste <color> back"
2529
```
2630

27-
if there are conflicts with other commands, trying to remove those brackets. furthermore, I I think it is best not to put brackets in cases where I haven't.
31+
if there are conflicts with other commands, try to remove those brackets (making smart not optional). Furthermore, I I think it is best not to put brackets in cases where I haven't.
2832

2933
After the small remark let's get started!
3034

@@ -79,6 +83,8 @@ usually followed by an integer. Beware the difference between up and above! As a
7983

8084
![](./gif/arg5.gif)
8185

86+
87+
8288
* in certain cases you can combine these two approaches:)
8389

8490
![](./gif/big5.gif)

doc/SelectBigROI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
These commands are responsible for selecting "big" regions of interest. By "big" we refer to things like "if condition" or "assignment right" in contrast to say the first entry of a dictionary.
44

5-
![](./gif/big0.gif)
5+
![](./gif/big2.gif)
66

77

88
In particular, the currently offered "big roi´s" are :

library/BracketMatcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import token
44

55
from PythonVoiceCodingPlugin.third_party.astmonkey import transformers
6-
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens as asttokens
6+
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens
77

88
from PythonVoiceCodingPlugin.library import build_tree,get_source_region,nearest_node_from_offset,previous_token,next_token
99

@@ -52,8 +52,6 @@ def _match(self,atok):
5252
self.level_index[index] = []
5353
self.level[index].append((c,candidate))
5454
self.level_index[index].append(c.start)
55-
# print(candidate,stack,"sicklep")
56-
# print(" leaving mods all brackets")
5755

5856

5957

library/LCA.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,9 @@ def __call__(self,first_node,second_node,include_depth = False):
4848

4949
def get_field_with_respect_to(self,node,parent_node):
5050
index = bisect.bisect_left(self.field_history[parent_node],(self.visits[node][0],))
51-
# print(" initial index ease",index)
5251
index = index if index < len(self.field_history[parent_node]) and \
5352
self.field_history[parent_node][index][0] == self.visits[node][0] else index-1
54-
# print("LCA",self.field_history[parent_node],parent_node, index,self.visits[node][0],
55-
# self.field_history[parent_node][index][0] == self.visits[node][0],"\n")
5653
y = self.field_history[parent_node][index]
57-
# print("LCA returning ",y[1],y[2],"\n")
5854
return (y[1],y[2])
5955

6056
def visit_time(self, node):

library/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from itertools import chain
33

44
from PythonVoiceCodingPlugin.third_party.astmonkey import transformers
5-
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens as asttokens
5+
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens
66

77
def make_flat(x):
88
return list(chain.from_iterable(x))

library/higher.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ast
22
import token
33

4-
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens as asttokens
4+
from PythonVoiceCodingPlugin.third_party.asttokens import asttokens
55

66
from PythonVoiceCodingPlugin.library import previous_token,next_token
77
from PythonVoiceCodingPlugin.library.modification import ModificationHandler
@@ -12,41 +12,36 @@
1212

1313
def filter_asynchronous(atok,m = None, timestamp = 0):
1414
m = m if m else ModificationHandler(atok.text)
15-
candidates = [x for x in atok.tokens if x.type== 52 and x.string=="async"]
15+
candidates = [x for x in atok.tokens if x.string=="async"]
1616
for c in candidates:
17-
y = next_token(c)
17+
y = next_token(atok,c)
1818
# async_stmt: 'async' (funcdef | with_stmt | for_stmt)
19-
if y and y.type==52 and y.string in ["def","for","with"]:
19+
if y and y.string in ["def","for","with"]:
2020
m.modify_from(timestamp,(c.startpos,y.startpos),"","async_"+y.string)
2121
return m
2222

2323

2424
def filter_await(atok,m = None, timestamp = 0):
2525
m = m if m else ModificationHandler(atok.text)
26-
candidates = [x for x in atok.tokens if x.type== 52 and x.string=="await"]
26+
candidates = [x for x in atok.tokens if x.string=="await"]
2727
for c in candidates:
2828
m.modify_from(timestamp,(c.startpos,c.endpos),"yield from","await")
2929
return m
3030

3131
def filter_fstrings(atok,m = None, timestamp = 0):
3232
m = m if m else ModificationHandler(atok.text)
33-
candidates = [x for x in atok.tokens if x.type== 52 and x.string=="f"]
33+
candidates = [x for x in atok.tokens if x.string=="f"]
3434
for c in candidates:
35-
y = next_token(c)
35+
y = next_token(atok,c)
3636
if y and y.type==token.STRING:
37-
m.modify_from(timestamp,(c.startpos,c.endpos),"","fstring")
37+
m.modify_from(timestamp,(c.startpos,y.endpos),y.string,"fstring")
3838
return m
3939

4040
def filter_everything(atok, m = None, timestamp = 0):
41-
print(m)
4241
m = m if m else ModificationHandler(atok.text)
43-
print(" inside everything after initialization",m)
4442
m = filter_asynchronous(atok,m, timestamp)
45-
print("1",m)
4643
m = filter_fstrings(atok,m, timestamp)
47-
print("2",m)
4844
m = filter_await(atok,m, timestamp)
49-
print(m)
5045
return m
5146

5247

library/info.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ def get_elif_condition(root):
117117
else None
118118
)
119119

120+
def get_comprehension_condition(root):
121+
return (
122+
root.ifs if match_node(root,(ast.comprehension)) else None
123+
)
124+
120125
def get_return_value(root):
121126
return (
122127
root.value if match_node(root,(ast.Return, ast.Yield,ast.YieldFrom )) else None

0 commit comments

Comments
 (0)