--- a/Viewer.py Tue Apr 10 18:02:40 2007 +0200
+++ b/Viewer.py Wed Apr 11 17:26:07 2007 +0200
@@ -885,11 +885,16 @@
self.Functions = []
self.Jumps = []
self.TextChanged = False
+ self.TextSyntax = "ST"
self.Controler = controler
EVT_KEY_DOWN(self, self.OnKeyDown)
EVT_STC_STYLENEEDED(self, wxID_TEXTVIEWER, self.OnStyleNeeded)
+ EVT_KILL_FOCUS(self, self.OnKillFocus)
+
+ def SetTextSyntax(self, syntax):
+ self.TextSyntax = syntax
def SetKeywords(self, keywords):
self.Keywords = [keyword.upper() for keyword in keywords]
@@ -1046,27 +1051,47 @@
self.CallTipCancel()
key = event.KeyCode()
+ # Code completion
if key == WXK_SPACE and event.ControlDown():
- pos = self.GetCurrentPos()
-
- # Tips
- if event.ShiftDown():
- self.CallTipSetBackground("yellow")
- self.CallTipShow(pos, 'Here will be some help.')
- # Code completion
+ line = self.GetCurrentLine()
+ if line == 0:
+ start_pos = 0
else:
- kw = [key for key in self.Keywords]
-
- kw.sort() # Python sorts are case sensitive
- self.AutoCompSetIgnoreCase(False) # so this needs to match
-
- self.AutoCompShow(0, " ".join(kw))
+ start_pos = self.GetLineEndPosition(line - 1) + 1
+ end_pos = self.GetCurrentPos()
+
+ lineText = self.GetTextRange(start_pos, end_pos).replace("\t", " ")
+ words = lineText.split(" ")
+ words = [word for i, word in enumerate(words) if word != '' or i == len(words) - 1]
+
+ kw = []
+
+ if self.TextSyntax == "IL":
+ if len(words) == 1:
+ kw = self.Keywords
+ elif len(words) == 2:
+ if words[0].upper() in ["CAL", "CALC", "CALNC"]:
+ kw = self.Functions
+ elif words[0].upper() in ["JMP", "JMPC", "JMPNC"]:
+ kw = self.Jumps
+ else:
+ kw = self.Variables
+ else:
+ kw = self.Keywords + self.Variables + self.Functions
+ if len(kw) > 0:
+ kw.sort()
+ self.AutoCompSetIgnoreCase(True)
+ self.AutoCompShow(len(words[-1]), " ".join(kw))
else:
self.TextChanged = False
wxCallAfter(self.RefreshModel)
event.Skip()
+ def OnKillFocus(self, event):
+ self.AutoCompCancel()
+ event.Skip()
+
#-------------------------------------------------------------------------------
# Resource Editor class