|
|
@ -133,8 +133,8 @@ class InteractiveInterpreterControl(TextEditorControl): |
|
|
|
_block = System.IO.StringWriter() |
|
|
|
_block = System.IO.StringWriter() |
|
|
|
|
|
|
|
|
|
|
|
[getter(Interpreter)] |
|
|
|
[getter(Interpreter)] |
|
|
|
_interpreter as Boo.Lang.Interpreter.InteractiveInterpreter |
|
|
|
_interpreter = InterpreterWrapper() |
|
|
|
|
|
|
|
|
|
|
|
_codeCompletionWindow as CodeCompletionWindow |
|
|
|
_codeCompletionWindow as CodeCompletionWindow |
|
|
|
|
|
|
|
|
|
|
|
[property(CompletionWindowImageProvider, value is not null)] |
|
|
|
[property(CompletionWindowImageProvider, value is not null)] |
|
|
@ -148,10 +148,8 @@ class InteractiveInterpreterControl(TextEditorControl): |
|
|
|
_blockKeys = false |
|
|
|
_blockKeys = false |
|
|
|
|
|
|
|
|
|
|
|
def constructor(): |
|
|
|
def constructor(): |
|
|
|
self._interpreter = Boo.Lang.Interpreter.InteractiveInterpreter( |
|
|
|
self._interpreter.LinePrinted += self.print |
|
|
|
RememberLastValue: true, |
|
|
|
self._interpreter.Cleared += self.cls |
|
|
|
Print: self.print) |
|
|
|
|
|
|
|
self._interpreter.SetValue("cls", cls) |
|
|
|
|
|
|
|
self._lineHistory = LineHistory(CurrentLineChanged: _lineHistory_CurrentLineChanged) |
|
|
|
self._lineHistory = LineHistory(CurrentLineChanged: _lineHistory_CurrentLineChanged) |
|
|
|
self.Document.HighlightingStrategy = GetBooHighlighting() |
|
|
|
self.Document.HighlightingStrategy = GetBooHighlighting() |
|
|
|
self.EnableFolding = false |
|
|
|
self.EnableFolding = false |
|
|
@ -178,19 +176,19 @@ class InteractiveInterpreterControl(TextEditorControl): |
|
|
|
|
|
|
|
|
|
|
|
def Eval(code as string): |
|
|
|
def Eval(code as string): |
|
|
|
try: |
|
|
|
try: |
|
|
|
_interpreter.LoopEval(code) |
|
|
|
_interpreter.RunCommand(code) |
|
|
|
ensure: |
|
|
|
ensure: |
|
|
|
_state = InputState.SingleLine |
|
|
|
_state = InputState.SingleLine |
|
|
|
|
|
|
|
|
|
|
|
private def ConsumeCurrentLine(): |
|
|
|
private def ConsumeCurrentLine(): |
|
|
|
text as string = CurrentLineText # was accessing Control.text member |
|
|
|
text as string = CurrentLineText # was accessing Control.text member |
|
|
|
_lineHistory.Add(text) |
|
|
|
_lineHistory.Add(text) |
|
|
|
print("") |
|
|
|
print("") |
|
|
|
return text |
|
|
|
return text |
|
|
|
|
|
|
|
|
|
|
|
private def GetLastLineSegment(): |
|
|
|
private def GetLastLineSegment(): |
|
|
|
return self.Document.GetLineSegment(self.Document.LineSegmentCollection.Count) |
|
|
|
return self.Document.GetLineSegment(self.Document.LineSegmentCollection.Count) |
|
|
|
|
|
|
|
|
|
|
|
private def SingleLineInputState(): |
|
|
|
private def SingleLineInputState(): |
|
|
|
code = ConsumeCurrentLine() |
|
|
|
code = ConsumeCurrentLine() |
|
|
|
if code[-1:] in ":", "\\": |
|
|
|
if code[-1:] in ":", "\\": |
|
|
@ -199,39 +197,39 @@ class InteractiveInterpreterControl(TextEditorControl): |
|
|
|
_block.WriteLine(code) |
|
|
|
_block.WriteLine(code) |
|
|
|
else: |
|
|
|
else: |
|
|
|
Eval(code) |
|
|
|
Eval(code) |
|
|
|
|
|
|
|
|
|
|
|
private def BlockInputState(): |
|
|
|
private def BlockInputState(): |
|
|
|
code = ConsumeCurrentLine() |
|
|
|
code = ConsumeCurrentLine() |
|
|
|
if 0 == len(code): |
|
|
|
if 0 == len(code): |
|
|
|
Eval(_block.ToString()) |
|
|
|
Eval(_block.ToString()) |
|
|
|
else: |
|
|
|
else: |
|
|
|
_block.WriteLine(code) |
|
|
|
_block.WriteLine(code) |
|
|
|
|
|
|
|
|
|
|
|
def print(msg): |
|
|
|
def print(msg): |
|
|
|
AppendText("${msg}\r\n") |
|
|
|
AppendText("${msg}\r\n") |
|
|
|
|
|
|
|
|
|
|
|
def prompt(): |
|
|
|
def prompt(): |
|
|
|
AppendText((">>> ", "... ")[_state]) |
|
|
|
AppendText((">>> ", "... ")[_state]) |
|
|
|
|
|
|
|
|
|
|
|
def ClearLine(): |
|
|
|
def ClearLine(): |
|
|
|
segment = GetLastLineSegment() |
|
|
|
segment = GetLastLineSegment() |
|
|
|
self.Document.Replace(segment.Offset + 4, |
|
|
|
self.Document.Replace(segment.Offset + 4, |
|
|
|
self.CurrentLineText.Length, |
|
|
|
self.CurrentLineText.Length, |
|
|
|
"") |
|
|
|
"") |
|
|
|
|
|
|
|
|
|
|
|
def AppendText(text as string): |
|
|
|
def AppendText(text as string): |
|
|
|
segment = GetLastLineSegment() |
|
|
|
segment = GetLastLineSegment() |
|
|
|
self.Document.Insert(segment.Offset + segment.TotalLength, text) |
|
|
|
self.Document.Insert(segment.Offset + segment.TotalLength, text) |
|
|
|
MoveCaretToEnd() |
|
|
|
MoveCaretToEnd() |
|
|
|
|
|
|
|
|
|
|
|
def MoveCaretToEnd(): |
|
|
|
def MoveCaretToEnd(): |
|
|
|
segment = GetLastLineSegment() |
|
|
|
segment = GetLastLineSegment() |
|
|
|
newOffset = segment.Offset + segment.TotalLength |
|
|
|
newOffset = segment.Offset + segment.TotalLength |
|
|
|
MoveCaretToOffset(newOffset) |
|
|
|
MoveCaretToOffset(newOffset) |
|
|
|
|
|
|
|
|
|
|
|
def MoveCaretToOffset(offset as int): |
|
|
|
def MoveCaretToOffset(offset as int): |
|
|
|
self.ActiveTextAreaControl.Caret.Position = self.Document.OffsetToPosition(offset) |
|
|
|
self.ActiveTextAreaControl.Caret.Position = self.Document.OffsetToPosition(offset) |
|
|
|
|
|
|
|
|
|
|
|
override def InitializeTextAreaControl(newControl as TextAreaControl): |
|
|
|
override def InitializeTextAreaControl(newControl as TextAreaControl): |
|
|
|
super(newControl) |
|
|
|
super(newControl) |
|
|
|
newControl.TextArea.DoProcessDialogKey += HandleDialogKey |
|
|
|
newControl.TextArea.DoProcessDialogKey += HandleDialogKey |
|
|
@ -332,8 +330,3 @@ class InteractiveInterpreterControl(TextEditorControl): |
|
|
|
|
|
|
|
|
|
|
|
def GetBooHighlighting(): |
|
|
|
def GetBooHighlighting(): |
|
|
|
return HighlightingManager.Manager.FindHighlighter("Boo") |
|
|
|
return HighlightingManager.Manager.FindHighlighter("Boo") |
|
|
|
|
|
|
|
|
|
|
|
static def InstallDefaultSyntaxModeProvider(): |
|
|
|
|
|
|
|
HighlightingManager.Manager.AddSyntaxModeFileProvider( |
|
|
|
|
|
|
|
FileSyntaxModeProvider(Path.GetDirectoryName(Application.ExecutablePath))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|