- Enabled Scintilla editor

This commit is contained in:
ccremers 2007-01-29 16:32:35 +00:00
parent df62d65d5c
commit 33df1ccb5b
3 changed files with 55 additions and 8 deletions

View File

@ -4,9 +4,17 @@
Scyther 1.0-beta6
New features:
Big new features:
* [Gui] Added Mac support (added universal binary)
* [Gui] Switched to Scintilla editor component, providing undo
and line numbering.
Other new features:
* [Backend] Scyther now detects when a read event cannot match
with a send event. This significantly helps in reducing errors
in the protocol descriptions.
* [Language] Added claim parameter for Reachable claim;
Reachable,R means that role R should be trusted (as well as the
actor), but not any other claim. This can be useful for showing

View File

@ -6,6 +6,17 @@
import wx
import os.path
# Use Scintilla editor?
useStc = True # It looks nicer!
#useStc = False # It is sometimes buggy!
# Test Scintilla and if it fails, get rid of it
if useStc:
try:
import wx.stc as stc
except:
useStc = False
#---------------------------------------------------------------------------
""" Import scyther-gui components """
@ -75,6 +86,24 @@ class MainWindow(wx.Frame):
self.firstCommand()
def GetText(self):
"""
Interface for both types of editor
"""
if useStc:
return self.control.GetText()
else:
return self.control.GetValue()
def SetText(self,txt):
"""
Interface for both types of editor
"""
if useStc:
self.control.SetText(txt)
else:
self.control.SetValue(txt)
def CreateInteriorWindowComponents(self):
''' Create "interior" window components. In this case it is just a
simple multiline text control. '''
@ -92,10 +121,19 @@ class MainWindow(wx.Frame):
# Top: input
self.top = wx.Notebook(self,-1)
self.control = wx.TextCtrl(self.top, style=wx.TE_MULTILINE)
if useStc:
# Scintilla layout with line numbers
self.control = stc.StyledTextCtrl(self.top)
self.control.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.control.SetMarginWidth(1, 30)
else:
# Simpler default
self.control = wx.TextCtrl(self.top, style=wx.TE_MULTILINE)
if self.load:
textfile = open(os.path.join(self.dirname, self.filename), 'r')
self.control.SetValue(textfile.read())
self.SetText(textfile.read())
os.chdir(self.dirname)
textfile.close()
self.top.AddPage(self.control,"Protocol description")
@ -189,14 +227,14 @@ class MainWindow(wx.Frame):
def OnSave(self, event):
textfile = open(os.path.join(self.dirname, self.filename), 'w')
textfile.write(self.control.GetValue())
textfile.write(self.GetText())
textfile.close()
def OnOpen(self, event):
if self.askUserForFilename(style=wx.OPEN,
**self.defaultFileDialogOptions()):
textfile = open(os.path.join(self.dirname, self.filename), 'r')
self.control.SetValue(textfile.read())
self.SetText(textfile.read())
textfile.close()
def OnSaveAs(self, event):
@ -206,7 +244,8 @@ class MainWindow(wx.Frame):
os.chdir(self.dirname)
def RunScyther(self, mode):
s = Scytherthread.ScytherRun(self,mode)
spdl = self.GetText()
s = Scytherthread.ScytherRun(self,mode,spdl)
def OnVerify(self, event):
self.RunScyther("verify")

View File

@ -444,11 +444,11 @@ class ResultWindow(wx.Frame):
class ScytherRun(object):
def __init__(self,mainwin,mode):
def __init__(self,mainwin,mode,spdl):
self.mainwin = mainwin
self.mode = mode
self.spdl = mainwin.control.GetValue()
self.spdl = spdl
self.verified = False
self.options = mainwin.settings.ScytherArguments(mode)
self.main()