Skip to content

Commit

Permalink
Added scaffolding to support partial tokenisation of a document.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjpettet committed Apr 9, 2022
1 parent 7b6b941 commit 9fbb9ce
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/About Window/WinAbout.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ End
#tag Events CanvasIcon
#tag Event
Sub Paint(g As Graphics, areas() As Rect)
#Pragma Unused areas

g.DrawPicture(AboutIcon, 0, 0)
End Sub
#tag EndEvent
Expand Down
16 changes: 16 additions & 0 deletions src/Demo Windows/Utilities/MarkdownKit/WinMarkdownKit.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Begin DemoWindow WinMarkdownKit
PanelCount = 2
Panels = ""
Scope = 0
SelectedPanelIndex= 0
TabIndex = 2
TabPanelIndex = 0
TabStop = False
Expand Down Expand Up @@ -231,24 +232,36 @@ Begin DemoWindow WinMarkdownKit
Begin XUITabBar TabBar
AllowAutoDeactivate= True
AllowDragReordering= False
AllowFocus = False
AllowFocusRing = True
AllowTabs = False
AvailableTabSpace= 0.0
Backdrop = 0
DraggingTabLeftEdgeXOffset= 0
Enabled = True
HasLeftBorder = False
HasLeftMenuButton= False
HasRightBorder = False
HasRightMenuButton= False
Height = 28
Index = -2147483648
IsDraggingTab = False
Left = 650
LeftMenuButtonIcon= 0
LockBottom = False
LockedInPosition= False
LockLeft = False
LockRight = True
LockTop = True
MouseDragX = 0
MouseDragY = 0
MouseMoveX = 0
MouseMoveY = 0
RightMenuButtonIcon= 0
Scope = 0
ScrollPosX = 0
SelectedTabIndex= 0
TabCount = 0
TabIndex = 1
TabPanelIndex = 0
TabStop = True
Expand Down Expand Up @@ -283,6 +296,7 @@ Begin DemoWindow WinMarkdownKit
Top = 594
Transparent = False
Underline = False
Value = False
Visible = True
VisualState = 0
Width = 100
Expand Down Expand Up @@ -406,6 +420,8 @@ End
#tag Events TabBar
#tag Event , Description = 54686520746162206174207468652073706563696669656420696E64657820776173206A7573742073656C65637465642E
Sub DidSelectTab(tab As XUITabBarItem, index As Integer)
#Pragma Unused index

Panel.SelectedPanelIndex = tab.Tag
End Sub
#tag EndEvent
Expand Down
3 changes: 3 additions & 0 deletions src/Demo Windows/Utilities/WinSemanticVersion.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ End
#tag Events LabelSemverLink
#tag Event
Function MouseDown(x As Integer, y As Integer) As Boolean
#Pragma Unused x
#Pragma Unused y

System.GotoURL(Me.Text)
End Function
#tag EndEvent
Expand Down
6 changes: 6 additions & 0 deletions src/Demo Windows/Utilities/WinTOMLKit.xojo_window
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ End
#tag Events LabelTOMLLink
#tag Event
Function MouseDown(x As Integer, y As Integer) As Boolean
#Pragma Unused x
#Pragma Unused y

System.GotoURL(Me.Text)
End Function
#tag EndEvent
Expand All @@ -157,6 +160,9 @@ End
#tag Events LabelKTekinayLink
#tag Event
Function MouseDown(x As Integer, y As Integer) As Boolean
#Pragma Unused x
#Pragma Unused y

System.GotoURL(Me.Text)
End Function
#tag EndEvent
Expand Down
8 changes: 7 additions & 1 deletion src/XUI/XUICodeEditor/Formatters/XUICEFormatter.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ Protected Interface XUICEFormatter
End Function
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
#tag Method, Flags = &h0, Description = 546F6B656E69736573206120706F7274696F6E206F6620616E206172726179206F66206C696E65732E
Sub Tokenise(lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer)

End Sub
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
Sub TokeniseAll(lines() As XUICELine)

End Sub
#tag EndMethod

#tag Method, Flags = &h0, Description = 52657475726E7320616E206172726179206F6620616C6C20746F6B656E2074797065732075736564206279207468697320666F726D61747465722E
Function TokenTypes() As String()

Expand Down
19 changes: 15 additions & 4 deletions src/XUI/XUICodeEditor/Formatters/XUICEMarkdownFormatter.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,29 @@ Implements MarkdownKit.MKRenderer,XUICEFormatter
End Function
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E697365732065766572797468696E6720696E20606C696E6573602E
#tag Method, Flags = &h0, Description = 546F6B656E69736573206120706F7274696F6E206F6620606C696E6573602E
Sub Tokenise(lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer)
/// Tokenises everything in `lines`.
/// Tokenises a portion of `lines`.
///
/// Note that we tokenise all lines, even though this method is passed the visible line numbers.
/// Part of the XUIFormatter interface.

#Pragma Warning "TODO: Actually just parse the passed lines."

#Pragma Unused firstVisibleLineNumber
#Pragma Unused lastVisibleLineNumber

TokeniseAll(lines)

End Sub
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
Sub TokeniseAll(lines() As XUICELine)
/// Tokenises an array of lines.
///
/// Part of the `XUICEFormatter` interface.

// Parse the entire contents to an AST.
If mParser = Nil Then mParser = New MarkdownKit.MKParser
mDoc = mParser.ParseLines(lines)
Expand All @@ -151,8 +164,6 @@ Implements MarkdownKit.MKRenderer,XUICEFormatter

// Walk the AST.
Call VisitDocument(mDoc)


End Sub
#tag EndMethod

Expand Down
16 changes: 13 additions & 3 deletions src/XUI/XUICodeEditor/Formatters/XUICETextFormatter.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,29 @@ Implements XUICEFormatter
End Function
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
#tag Method, Flags = &h0, Description = 546F6B656E69736573206120706F7274696F6E206F6620606C696E6573602E
Sub Tokenise(lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer)
/// Tokenises an array of lines.
/// Tokenises a portion of `lines`.
///
/// Note that we tokenise all lines, even though this method is passed the visible line numbers.
/// Part of the XUICEFormatter interface.

#Pragma Unused firstVisibleLineNumber
#Pragma Unused lastVisibleLineNumber

TokeniseAll(lines)
End Sub
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
Sub TokeniseAll(lines() As XUICELine)
/// Tokenises an array of lines.
///
/// Part of the XUICEFormatter interface.

For Each line As XUICELine In lines
TokeniseLine(line)
Next line

End Sub
#tag EndMethod

Expand Down
16 changes: 13 additions & 3 deletions src/XUI/XUICodeEditor/Formatters/XUICEWrenFormatter.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -1002,16 +1002,27 @@ Implements XUICEFormatter
End Function
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E697365732065766572797468696E6720696E205B6C696E65735D2E
#tag Method, Flags = &h0, Description = 546F6B656E69736573206120706F7274696F6E206F6620606C696E6573602E
Sub Tokenise(lines() As XUICELine, firstVisibleLineNumber As Integer, lastVisibleLineNumber As Integer)
/// Tokenises everything in [lines].
/// Tokenises a portion of `lines`.
///
/// Note that we tokenise all lines, even though this method is passed the visible line numbers.
/// Part of the XUICEFormatter interface.

#Pragma Unused firstVisibleLineNumber
#Pragma Unused lastVisibleLineNumber

TokeniseAll(lines)

End Sub
#tag EndMethod

#tag Method, Flags = &h0, Description = 546F6B656E6973657320616E206172726179206F66206C696E65732E
Sub TokeniseAll(lines() As XUICELine)
/// Tokenises an array of lines.
///
/// Part of the XUICEFormatter interface.

If lines.Count = 0 Then Return

// =============
Expand All @@ -1029,7 +1040,6 @@ Implements XUICEFormatter
// PARSE
// =============
ParseSimple

End Sub
#tag EndMethod

Expand Down
3 changes: 2 additions & 1 deletion src/XUI/XUICodeEditor/XUICELineManager.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,8 @@ Protected Class XUICELineManager

If Owner = Nil Or Owner.Formatter = Nil Then Return

Owner.Formatter.Tokenise(Lines, 1, Lines.Count)
' Owner.Formatter.Tokenise(Lines, 1, Lines.Count)
Owner.Formatter.TokeniseAll(Lines)

Owner.NeedsFullRedraw = True
End Sub
Expand Down

0 comments on commit 9fbb9ce

Please sign in to comment.