Skip to content

Commit 58b59c1

Browse files
committed
A lot of stuff together
1 parent 8198fe9 commit 58b59c1

13 files changed

+83
-20
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
* PopUpErrorAction has been added in order to inform the user in cases where to cannot parse the source code.
1212

13+
* Sublime settings file has been added, from which you can turn on or off, showing the main result when it is not visible as well as the pop-ups with error information.
14+
1315
### Fixed
1416

1517
* fixed the empty brackets bug in the repair modulebugs with ":" addressed, needs more testing and a subsequent bug
@@ -28,7 +30,11 @@
2830

2931
* fixed a bug in the above/below argument command, which occasionally caused of by one errors.
3032

31-
* in the info module, fixed a bug in the get_body function where ast.IfExp was missing for some reason.
33+
* in the info module, fixed a bug in the get_body function where ast.IfExp was missing for some reason
34+
35+
* Yet another forwarding bug in the argument module:(
36+
37+
* fix a bug in the big region of interest module which caused off by one error in the above below command, when the original selection was in an empty line.
3238

3339
### Changed
3440

@@ -60,6 +66,8 @@
6066

6167
* In the same spirit, the query module has been modified and has a new attribute in order to store the above exception. The application module checks if this attribute HUD stored exception and displays an error through the PopUpErrorAction!
6268

69+
* The interface module has been modified to accept settings in its constructor.
70+
6371
## [0.0.3] - 2019-11-18
6472

6573
important patch

doc/SelectArgument.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,28 @@ Choice("vertical_direction",{
103103
```
104104
and ndir is an interger specifying how many lines (relative to the current) up or down your roi is.
105105

106+
106107
But why both "above" and "up"? The difference lies in that above only counts "interesting lines", that is(physical) lines containing function calls. The following example should clarify this:
107108

108109
![](./gif/arg5.gif)
109110

110-
Though if we want to be more precise, we count lines that contain the beginning of function calls! this is important because logical lines can extend over multiple "physical" lines. The last example in the gif contains such an example, physical lines still determine the line to which above/below refer and result and alternatives from that physical line will be prioritized, but alternatives will also be offered from the whole logical line!
111+
Though if we want to be more precise, we count lines that contain the beginning of function calls! this is important because logical lines can extend over multiple "physical" lines. The last example in the gif contains such an example,but to give you a better idea:
112+
113+
![](./gif/arg9.gif)
114+
115+
so you can see that
116+
* physical lines still determine the line to which above/below refer
117+
* result and alternatives from that physical line are being prioritized, but
118+
* The whole logical line is scanned for alternatives !
119+
120+
In a more complex scenario, if there are multiple functional calls in the physical line and you up for using an ordinal adjective, in order to to preserve sanity, the main result will be decided by taking into consideration the order of lexical appearance:
121+
122+
![](./gif/arg10.gif)
123+
124+
125+
Finally, even though the argument query was originally designed to operate on a single logical line, make things more consistent, an exception was made for the case when the physical line that you are targeting contains more than one logical lines. In such a case, all the logical lines are processed in the monitor similar to the previous case, with important distinction that both the result and the alternatives must come from this physical line, where as in the previous case either one of them can come from other physical lines, if no suitable candidate is found.
126+
127+
![](./gif/arg11.gif)
111128

112129

113130

doc/SelectBigROI.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ Sub indexing functionality has been expanded to include picking up parts of stri
177177

178178
![](./gif/big10.gif)
179179

180+
We can pick up parts from the URL, individual words or letters, or part of a camel or snake case. this feature is still immatur and needs more work, but I am planning to improve and also expand it with the ability to select a whole range.
181+
182+
Also something that was kind of missing,you can now select a subset of an arithmetic expression :
183+
184+
![](./gif/big12.gif)
185+
186+
Once again you need to pay attention to operator precedence and as you can see there are some edge cases that need to be fixed.
187+
180188
Finally, we clarify one more thing! What about relative vertical offsets when using above? We know that these abstract vertical keywords only count interesting lines, but what do we count as interesting here? To stay compatible with all of the above, we count all lines containing our desired big region of interest regardless of whether we can extract or not from them information with the sub index! As an example:
181189

182190
![](./gif/big9.gif)

doc/gif/big12.gif

256 KB
Loading

interface/common/actions.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ class SelectionAction(InterfaceAction):
1313
def __init__(self, region):
1414
self.data={"region":region}
1515

16-
def execute(self,view,sublime,**kwargs):
16+
def execute(self,view,settings,sublime,**kwargs):
1717
region = self.data["region"]
1818
if region:
1919
view.sel().clear()
2020
if not isinstance(region,list):
2121
region = [region]
2222
for r in region:
2323
view.sel().add(sublime.Region(r[0],r[1]))
24-
view.show(sublime.Region(region[0][0],region[0][1]))
24+
if settings.get("show_visible",False):
25+
view.show(sublime.Region(region[0][0],region[0][1]))
26+
2527

2628

2729

@@ -213,11 +215,13 @@ class PopUpErrorAction(InterfaceAction):
213215
"""docstring for DisplayErrorAction"""
214216
def __init__(self, text):
215217
self.text = text
216-
def execute(self,view, sublime,**kwargs):
218+
def execute(self,view,settings, sublime,**kwargs):
219+
if not settings.get("show_error",False):
220+
return
217221
final_text = "<p></p><h>Something is off!</h>" + "<p>" + html.escape(self.text) + "</p>"
218222
print(" inside final text processing ",final_text)
219223
def on_hide():
220-
view.show_popup(final_text,max_width=1024, max_height=10000, flags= sublime.COOPERATE_WITH_AUTO_COMPLETE)
224+
view.show_popup(final_text,max_width=1024, max_height=10000, flags= sublime.HIDE_ON_MOUSE_MOVE_AWAY)
221225
view.show_popup(final_text,max_width=1024, max_height=10000,
222226
flags= sublime.COOPERATE_WITH_AUTO_COMPLETE,on_hide = on_hide)
223227
print(view.is_popup_visible())

interface/interface.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
class Interface():
66
"""docstring for Interface"""
7-
def __init__(self,view,window,edit,sublime):
7+
def __init__(self,view,window,edit,sublime,settings):
88
self.view = view
99
self.window = window
1010
self.edit = edit
1111
self.sublime = sublime
1212
self.actions = []
13+
self.settings = settings
1314

1415
def get_view_information(self):
1516
return ViewInformation(self.view,self.sublime)
@@ -24,7 +25,7 @@ def respond_to_query(self,query_description):
2425
application = Application.get_application(self.view.id())
2526
application.respond_to_query(self,query_description)
2627
parameters = {
27-
"view":self.view,"window":self.window,"edit":self.edit,"sublime":self.sublime
28+
"view":self.view,"window":self.window,"edit":self.edit,"sublime":self.sublime,"settings":self.settings,
2829
}
2930
for action in self.actions:
3031
action.execute(**parameters)

library/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def split_string(s,even_letters = True):
294294
second_attempt = [x for x in re.split("[_]",s) if not x.isspace()]
295295
if len(second_attempt) > 1:
296296
return second_attempt
297-
# https://stackoverflow.com/questions/29916065/how-to-do-camelcase-split-in-python Jossef Harush
297+
# https://stackoverflow.com/questions/29916065/how-to-do-camelcase-split-in-python answer from Jossef Harush
298298
third_attempt = re.sub('([A-Z][a-z]+)', r' \1', re.sub('([A-Z]+)', r' \1', s)).split()
299299
if len(third_attempt) > 1:
300300
return third_attempt

library/modification.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ def get_timestamp(self):
146146
return len(self.history)
147147

148148
def forward(self,value,start_time = 0,end_time = 0):
149-
print(" value is", value,"over")
150-
print(value)
151149
if value is None:
152150
return None
153151
end_time = end_time if end_time!=0 else len(self.history)

library/partial.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def partially_parse(code, m = None, atok = None,rethrow_exception = False):
5656
print(" go to the field\n",m.current_code)
5757
print(" error was\n",str(e),"\n",e)
5858
if rethrow_exception :
59-
raise e_first
59+
raise e
6060
return None,None,None,None
6161

6262
###############################
@@ -66,15 +66,13 @@ def line_partial(code,offset):
6666
atok = asttokens.ASTTokens(parse=False, source_text=code)
6767
origin = atok.get_token_from_offset(offset)
6868
left, right = expand_to_line_or_statement(atok,origin)
69-
print( left, right )
7069
m = ModificationHandler(code)
7170
m.modify_from(0,(0, left.startpos),"")
7271
if right.string == ":":
7372
m.modify_from(0,(right.endpos,len(code)+1),"pass")
7473
else:
7574
m.modify_from(0,(right.endpos,len(code)+1),"")
7675
m.update()
77-
print("history is",m.history)
7876
return partially_parse(m.current_code,m)
7977

8078
################################################################################################

python_voice_coding_plugin.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sublime
55
import sublime_plugin
66

7+
settings = {}
78
# making sure our dependencies are in the path
89
sys.path.insert(0,os.path.join(os.path.dirname(__file__), 'third_party'))
910

@@ -12,16 +13,25 @@
1213
# removing our dependencies from the path so as not to interfere with other packages
1314
sys.path.remove(os.path.join(os.path.dirname(__file__), 'third_party'))
1415

16+
17+
def plugin_loaded():
18+
global settings
19+
settings = sublime.load_settings("python_voice_coding_plugin.sublime-settings")
20+
21+
22+
1523
class PythonVoiceCodingPluginCommand(sublime_plugin.TextCommand):
1624
def run(self, edit,arg):
1725
self.action_one(edit,arg)
1826

1927
def action_one(self, edit,arg):
28+
global settings
2029
interface = Interface(
2130
sublime = sublime,
2231
view = self.view,
2332
window = sublime.active_window(),
24-
edit = edit
33+
edit = edit,
34+
settings = settings
2535
)
2636
interface.respond_to_query(arg)
2737

0 commit comments

Comments
 (0)