Implement commit highlight.
[DEVELOPMENT ENVIRONMENT] * NEW: Implement commit highlight. * OPT: Wait less for version control commands.
This commit is contained in:
parent
d15b8726cb
commit
ef01ebe758
7 changed files with 85 additions and 46 deletions
|
@ -1,7 +1,7 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,50,59)
|
||||
MoveScaled(0,0,79,59)
|
||||
Arrangement = Arrange.Vertical
|
||||
{ panStat Panel
|
||||
MoveScaled(43,5,29,24)
|
||||
|
|
|
@ -78,7 +78,7 @@ Public Sub History((sPath) As String, Optional (sPath2) As String, (bFull) As Bo
|
|||
|
||||
End
|
||||
|
||||
Public Sub HighlightHistory((sText) As String)
|
||||
Public Sub InitHistory((hEditor) As TextEditor)
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ Private $bCanControl As Boolean
|
|||
Private $bCanInit As Boolean
|
||||
Private $bHasRemote As Boolean
|
||||
|
||||
Private $iPadHistory As Integer
|
||||
Private $hHighlightDiff As TextHighlighter
|
||||
' Private $iPadHistory As Integer
|
||||
' Private $hHighlightDiff As TextHighlighter
|
||||
|
||||
Private Sub Init()
|
||||
|
||||
|
@ -497,48 +497,55 @@ Private Sub FormatDate(sDate As String) As String
|
|||
|
||||
End
|
||||
|
||||
Fast Public Sub HighlightHistory(Text As String)
|
||||
Public Sub InitHistory(hEditor As TextEditor)
|
||||
|
||||
Dim iState As Integer
|
||||
Dim iLen As Integer
|
||||
|
||||
iState = TextHighlighter.State
|
||||
iLen = String.Len(Text)
|
||||
|
||||
TextHighlighter.Limit = False
|
||||
|
||||
If $iPadHistory = 0 Then
|
||||
$iPadHistory = Max(Max(String.Len(("Date")), String.Len(("Author"))), String.Len("Commit"))
|
||||
Endif
|
||||
|
||||
TextHighlighter.Alternate = True
|
||||
If Text Begins "commit " Then
|
||||
TextHighlighter.TextAfter = String.PadRight("Commit", $iPadHistory) & " : " & Mid$(Text, 8)
|
||||
TextHighlighter.Add(Highlight.DataType, String.Len(TextHighlighter.TextAfter))
|
||||
'TextHighlighter.Add(Highlight.DataType, String.Len(Text))
|
||||
TextHighlighter.Limit = True
|
||||
Else If Text Begins "Merge: " Then
|
||||
TextHighlighter.TextAfter = String.PadRight("Merge", $iPadHistory) & " : " & Mid$(Text, 8)
|
||||
TextHighlighter.Add(Highlight.Number, String.Len(TextHighlighter.TextAfter))
|
||||
'TextHighlighter.Add(Highlight.DataType, String.Len(Text))
|
||||
TextHighlighter.Limit = True
|
||||
Else If Text Begins "Author: " Then
|
||||
TextHighlighter.TextAfter = String.PadRight(("Author"), $iPadHistory) & " : " & Mid$(Text, 9)
|
||||
TextHighlighter.Add(Highlight.Function, String.Len(TextHighlighter.TextAfter))
|
||||
'TextHighlighter.Add(Highlight.Function, String.Len(Text))
|
||||
Else If Text Begins "Date: " Then
|
||||
TextHighlighter.TextAfter = String.PadRight(("Date"), $iPadHistory) & " : " & FormatDate(Mid$(Text, 7))
|
||||
TextHighlighter.Add(Highlight.Preprocessor, String.Len(TextHighlighter.TextAfter))
|
||||
'TextHighlighter.Add(Highlight.Preprocessor, String.Len(Text))
|
||||
Else
|
||||
TextHighlighter.Alternate = False
|
||||
If Not $hHighlightDiff Then $hHighlightDiff = TextHighlighter["diff"]
|
||||
$hHighlightDiff.Run(Text)
|
||||
'TextHighlighter.Add(Highlight.Normal, iLen)
|
||||
Endif
|
||||
TextHighlighter.Register("highlight/commit_git.highlight")
|
||||
hEditor.Highlight = "commit_git"
|
||||
|
||||
End
|
||||
|
||||
' Fast Public Sub HighlightHistory(Text As String)
|
||||
'
|
||||
' Dim iState As Integer
|
||||
' Dim iLen As Integer
|
||||
'
|
||||
' iState = TextHighlighter.State
|
||||
' iLen = String.Len(Text)
|
||||
'
|
||||
' TextHighlighter.Limit = False
|
||||
'
|
||||
' If $iPadHistory = 0 Then
|
||||
' $iPadHistory = Max(Max(String.Len(("Date")), String.Len(("Author"))), String.Len("Commit"))
|
||||
' Endif
|
||||
'
|
||||
' TextHighlighter.Alternate = True
|
||||
' If Text Begins "commit " Then
|
||||
' TextHighlighter.TextAfter = String.PadRight("Commit", $iPadHistory) & " : " & Mid$(Text, 8)
|
||||
' TextHighlighter.Add(Highlight.DataType, String.Len(TextHighlighter.TextAfter))
|
||||
' 'TextHighlighter.Add(Highlight.DataType, String.Len(Text))
|
||||
' TextHighlighter.Limit = True
|
||||
' Else If Text Begins "Merge: " Then
|
||||
' TextHighlighter.TextAfter = String.PadRight("Merge", $iPadHistory) & " : " & Mid$(Text, 8)
|
||||
' TextHighlighter.Add(Highlight.Number, String.Len(TextHighlighter.TextAfter))
|
||||
' 'TextHighlighter.Add(Highlight.DataType, String.Len(Text))
|
||||
' TextHighlighter.Limit = True
|
||||
' Else If Text Begins "Author: " Then
|
||||
' TextHighlighter.TextAfter = String.PadRight(("Author"), $iPadHistory) & " : " & Mid$(Text, 9)
|
||||
' TextHighlighter.Add(Highlight.Function, String.Len(TextHighlighter.TextAfter))
|
||||
' 'TextHighlighter.Add(Highlight.Function, String.Len(Text))
|
||||
' Else If Text Begins "Date: " Then
|
||||
' TextHighlighter.TextAfter = String.PadRight(("Date"), $iPadHistory) & " : " & FormatDate(Mid$(Text, 7))
|
||||
' TextHighlighter.Add(Highlight.Preprocessor, String.Len(TextHighlighter.TextAfter))
|
||||
' 'TextHighlighter.Add(Highlight.Preprocessor, String.Len(Text))
|
||||
' Else
|
||||
' TextHighlighter.Alternate = False
|
||||
' If Not $hHighlightDiff Then $hHighlightDiff = TextHighlighter["diff"]
|
||||
' $hHighlightDiff.Run(Text)
|
||||
' 'TextHighlighter.Add(Highlight.Normal, iLen)
|
||||
' Endif
|
||||
'
|
||||
' End
|
||||
|
||||
Public Sub GetRoot() As String
|
||||
|
||||
Return $sRoot
|
||||
|
|
|
@ -39,6 +39,8 @@ Public Sub Form_Open()
|
|||
Me.Title = Subst(("'&1' version control"), File.Name(sPath))
|
||||
|
||||
edtChange.ReadConfig
|
||||
|
||||
VersionControl.InitHistory(edtHistory)
|
||||
edtHistory.ReadConfig
|
||||
edtHistory.ShowModified = False
|
||||
edtHistory.Wrap = False
|
||||
|
|
|
@ -89,6 +89,8 @@ Public Sub Form_Open()
|
|||
|
||||
edtJournal.ReadConfig
|
||||
edtDiff.ReadConfig
|
||||
|
||||
VersionControl.InitHistory(edtHistory)
|
||||
edtHistory.ReadConfig
|
||||
edtHistory.ShowModified = False
|
||||
edtHistory.Wrap = False
|
||||
|
|
|
@ -199,7 +199,7 @@ Public Sub Run(aCmd As String[], Optional bIdent As Boolean, Optional bOutput As
|
|||
Insert(sCmd & "\n")
|
||||
|
||||
Do
|
||||
Wait
|
||||
Wait Next
|
||||
|
||||
If $bEnd Then Break
|
||||
|
||||
|
@ -211,7 +211,7 @@ Public Sub Run(aCmd As String[], Optional bIdent As Boolean, Optional bOutput As
|
|||
Break
|
||||
Endif
|
||||
|
||||
Sleep 0.1
|
||||
'Sleep 0.02
|
||||
Loop
|
||||
|
||||
If $bCancel Then Return -1
|
||||
|
@ -539,9 +539,9 @@ Public Sub History(Optional sPath As String, sPath2 As String, bFull As Boolean)
|
|||
|
||||
End
|
||||
|
||||
Public Sub HighlightHistory(sText As String)
|
||||
Public Sub InitHistory(hEditor As TextEditor)
|
||||
|
||||
$hVC.HighlightHistory(sText)
|
||||
$hVC.InitHistory(hEditor)
|
||||
|
||||
End
|
||||
|
||||
|
|
28
app/src/gambas3/highlight/commit_git.highlight
Normal file
28
app/src/gambas3/highlight/commit_git.highlight
Normal file
|
@ -0,0 +1,28 @@
|
|||
commit{Datatype}:
|
||||
limit
|
||||
match /^commit.*?\n/
|
||||
author{Function}:
|
||||
match /^Author:.*?\n/
|
||||
date{Preprocessor}:
|
||||
match /^Date:.*?\n/
|
||||
merge{Number}:
|
||||
match /^Merge:.*?\n/
|
||||
|
||||
diff{Datatype}:
|
||||
limit
|
||||
from /^diff/
|
||||
index{Keyword}:
|
||||
from /^index/
|
||||
file{Keyword}:
|
||||
match /^(\+\+\+|---)/
|
||||
file.path{String}:
|
||||
match /.*?\n/
|
||||
position{Function}:
|
||||
from /^@@/ to @@
|
||||
added{Added}:
|
||||
from /^\+/ to "\n"
|
||||
removed{Removed}:
|
||||
from /^-/ to "\n"
|
||||
normal:
|
||||
from /./ to "\n"
|
||||
|
Loading…
Reference in a new issue