- Errors now get a nice colour
This commit is contained in:
parent
c63b87c750
commit
6e82d585be
@ -8,7 +8,7 @@ Scyther 1.0-beta6
|
|||||||
|
|
||||||
* [Gui] Added Mac support (added universal binary)
|
* [Gui] Added Mac support (added universal binary)
|
||||||
* [Gui] Switched to Scintilla editor component, providing undo
|
* [Gui] Switched to Scintilla editor component, providing undo
|
||||||
and line numbering.
|
and line numbering, and highlighting of error lines.
|
||||||
|
|
||||||
Other new features:
|
Other new features:
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
""" Import externals """
|
""" Import externals """
|
||||||
import wx
|
import wx
|
||||||
|
import string
|
||||||
|
|
||||||
# Use Scintilla editor?
|
# Use Scintilla editor?
|
||||||
useStc = True # It looks nicer!
|
useStc = True # It looks nicer!
|
||||||
@ -26,6 +27,34 @@ if useStc:
|
|||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def justNumbers(txt):
|
||||||
|
for x in txt:
|
||||||
|
if not x in string.digits:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def lineInError(txt):
|
||||||
|
# First option: square braces
|
||||||
|
x1 = txt.find("[")
|
||||||
|
if x1 >= 0:
|
||||||
|
x2 = txt.find("]")
|
||||||
|
if x2 > x1:
|
||||||
|
nrstring = txt[(x1+1):x2]
|
||||||
|
if justNumbers(nrstring):
|
||||||
|
return int(nrstring)
|
||||||
|
# Alternative: ...line x
|
||||||
|
pref = " line "
|
||||||
|
i = txt.find(pref)
|
||||||
|
if i >= 0:
|
||||||
|
i = i + len(pref)
|
||||||
|
j = i
|
||||||
|
while txt[j] in string.digits:
|
||||||
|
j = j+1
|
||||||
|
if j > i:
|
||||||
|
return int(txt[i:j])
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def selectEditor(parent):
|
def selectEditor(parent):
|
||||||
"""
|
"""
|
||||||
Pick an editor (Scintilla or default) and return the object.
|
Pick an editor (Scintilla or default) and return the object.
|
||||||
@ -43,6 +72,9 @@ class Editor(object):
|
|||||||
# Empty start
|
# Empty start
|
||||||
self.SetText("")
|
self.SetText("")
|
||||||
|
|
||||||
|
def SetErrors(self,errors):
|
||||||
|
pass
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class EditorNormal(Editor):
|
class EditorNormal(Editor):
|
||||||
@ -72,11 +104,34 @@ class EditorStc(Editor):
|
|||||||
# Call parent
|
# Call parent
|
||||||
Editor.__init__(self,parent)
|
Editor.__init__(self,parent)
|
||||||
|
|
||||||
|
# Set variable for error style
|
||||||
|
self.errorstyle = 5
|
||||||
|
self.control.StyleSetSpec(self.errorstyle, "fore:#FFFF0000,back:#FF0000")
|
||||||
|
|
||||||
def GetText(self):
|
def GetText(self):
|
||||||
return self.control.GetText()
|
return self.control.GetText()
|
||||||
|
|
||||||
def SetText(self, txt):
|
def SetText(self, txt):
|
||||||
self.control.SetText(txt)
|
self.control.SetText(txt)
|
||||||
|
|
||||||
|
def SetErrorLine(self,line):
|
||||||
|
line = line - 1 # Start at 0 in stc, but on screen count is 1
|
||||||
|
pos = self.control.GetLineIndentPosition(line)
|
||||||
|
last = self.control.GetLineEndPosition(line)
|
||||||
|
self.control.StartStyling(pos,31)
|
||||||
|
self.control.SetStyling(last-pos,self.errorstyle)
|
||||||
|
|
||||||
|
def ClearErrors(self):
|
||||||
|
self.control.ClearDocumentStyle()
|
||||||
|
|
||||||
|
def SetErrors(self,errors):
|
||||||
|
if errors:
|
||||||
|
for el in errors:
|
||||||
|
nr = lineInError(el)
|
||||||
|
if nr:
|
||||||
|
self.SetErrorLine(nr)
|
||||||
|
else:
|
||||||
|
self.ClearErrors()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -208,8 +208,11 @@ class MainWindow(wx.Frame):
|
|||||||
os.chdir(self.dirname)
|
os.chdir(self.dirname)
|
||||||
|
|
||||||
def RunScyther(self, mode):
|
def RunScyther(self, mode):
|
||||||
|
# Clear errors before verification
|
||||||
|
self.editor.SetErrors(None)
|
||||||
|
# Verify spdl
|
||||||
spdl = self.editor.GetText()
|
spdl = self.editor.GetText()
|
||||||
s = Scytherthread.ScytherRun(self,mode,spdl)
|
s = Scytherthread.ScytherRun(self,mode,spdl,self.editor.SetErrors)
|
||||||
|
|
||||||
def OnVerify(self, event):
|
def OnVerify(self, event):
|
||||||
self.RunScyther("verify")
|
self.RunScyther("verify")
|
||||||
|
@ -444,13 +444,14 @@ class ResultWindow(wx.Frame):
|
|||||||
|
|
||||||
class ScytherRun(object):
|
class ScytherRun(object):
|
||||||
|
|
||||||
def __init__(self,mainwin,mode,spdl):
|
def __init__(self,mainwin,mode,spdl,errorcallback=None):
|
||||||
|
|
||||||
self.mainwin = mainwin
|
self.mainwin = mainwin
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.spdl = spdl
|
self.spdl = spdl
|
||||||
self.verified = False
|
self.verified = False
|
||||||
self.options = mainwin.settings.ScytherArguments(mode)
|
self.options = mainwin.settings.ScytherArguments(mode)
|
||||||
|
self.errorcallback=errorcallback
|
||||||
self.main()
|
self.main()
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
@ -540,6 +541,8 @@ class ScytherRun(object):
|
|||||||
Verification process generated errors. Show them.
|
Verification process generated errors. Show them.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.errorcallback:
|
||||||
|
self.errorcallback(self.scyther.errors)
|
||||||
title = "Scyther errors : %s" % self.mode
|
title = "Scyther errors : %s" % self.mode
|
||||||
errorwin = ErrorWindow(self.mainwin,title,errors=self.scyther.errors)
|
errorwin = ErrorWindow(self.mainwin,title,errors=self.scyther.errors)
|
||||||
errorwin.Center()
|
errorwin.Center()
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user