[DEVELOPMENT ENVIRONMENT]

* OPT: FPatch: Make hunk (un)checking behave more intuitive.
* BUG: FMakePatch: Don't add a patch to the viewer multiple times.



git-svn-id: svn://localhost/gambas/trunk@6785 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Tobias Boege 2014-12-31 18:26:47 +00:00
parent 7dca5a263a
commit 8e1ca6210f
2 changed files with 32 additions and 30 deletions

View file

@ -11,13 +11,8 @@ Public Sub wizMakePatch_BeforeChange()
Select Case wizMakePatch.Index
Case 0
If radArchive.Value Then
wizMakePatch[1].Enabled = True
wizMakePatch[2].Enabled = False
Else
wizMakePatch[1].Enabled = False
wizMakePatch[2].Enabled = True
Endif
wizMakePatch[1].Enabled = radArchive.Value
wizMakePatch[2].Enabled = Not radArchive.Value
Case 1
If Not Exist(fchOld.SelectedPath) Or If IsDir(fchOld.SelectedPath) Then
@ -116,7 +111,7 @@ Public Sub Form_Open()
fchOld.SelectedPath = Project.Config["/FMakePatch/LastArchive", User.Home]
pchOld.Path = Project.Config["/FMakePatch/LastProject", User.Home]
$hViewer = New FPatch(panViewer, False)
$hViewer = New FPatch(panViewer)
End
@ -132,6 +127,7 @@ Public Sub wizMakePatch_Change()
Dim sName As String
If wizMakePatch.Index = 3 Then
$hViewer.Clear()
Try $hViewer.Parse(GetDiff())
If Error Then
Message.Error(("Unable to generate the patch.") & "\n\n" & Error.Text)

View file

@ -1,20 +1,20 @@
' Gambas class file
' (C) 2013, 2014 Tobias Boege <tobias@gambas-buch.de>
' (C) 2013, 2014, almost-2015 Tobias Boege <tobias@gambas-buch.de>
'' Get the edited patch back
Property Read {Patch} As Patch
Private $hPatch As New Patch
Private $hObs As Observer
' Whether we behave like a window or just an embedded control (see FMakePatch, Step #4)
' Whether we behave like a window or just an embedded control (see FMakePatch, Step #4)
Private $bWindowed As Boolean
Public Sub _new(Optional Windowed As Boolean = True)
Public Sub _new()
$bWindowed = Windowed
Panel3.Visible = Windowed
HBox2.Visible = Windowed
$bWindowed = Not Me.Parent
Panel3.Visible = $bWindowed
HBox2.Visible = $bWindowed
End
@ -29,7 +29,7 @@ Public Sub Form_Open()
gvwHunks.Columns[2].Expand = False
gvwHunks.Columns[3].Expand = False
$hObs = New Observer(gvwHunks.Proxy) As "Observer"
$hObs = New Observer(gvwHunks.Proxy, True) As "Observer"
edtPatch.ReadConfig
edtPatch.Flags[Editor.ShowLineNumbers] = True
@ -40,6 +40,7 @@ Private Sub Check(iRow As Integer, bActive As Boolean)
$hPatch[iRow].Active = bActive
gvwHunks[iRow, 0].Picture = If(bActive, Picture["img/16/checked.png"], Picture["img/16/unchecked.png"])
edtPatch.Highlight = IIf($hPatch[gvwHunks.Row].Active, Highlight.Diff, Highlight.Custom)
End
@ -52,7 +53,7 @@ Public Sub Observer_MouseDown()
If .ColumnAt(Mouse.X) = 0 Then
iRow = .RowAt(Mouse.Y)
If iRow >= 0 And .Row >= 0 Then
If iRow >= 0 Then
bSelect = Not $hPatch[.Row].Active
For Each iRow In .Rows.Selection
Check(iRow, bSelect)
@ -84,14 +85,13 @@ Public Sub gvwHunks_Select()
End
Public Sub gvwHunks_Activate()
Dim iRow As Integer = gvwHunks.Row
If iRow >= 0 Then Check(iRow, Not $hPatch[iRow].Active)
End
' Public Sub gvwHunks_Activate()
'
' Dim iRow As Integer = gvwHunks.Row
'
' If iRow >= 0 Then Check(iRow, Not $hPatch[iRow].Active)
'
' End
Public Sub edtPatch_Highlight()
@ -103,17 +103,16 @@ Private Sub RefreshHunks()
Dim iInd As Integer
Dim sToFile As String
'Dim sLineInfo As String
'Dim iAltColor As Integer
' Dim sLineInfo As String
' Dim iAltColor, iJ As Integer
Dim aScan As String[]
'iAltColor = Color.Merge(Color.TextBackground, Color.LightBackground)
' iAltColor = Color.Merge(Color.TextBackground, Color.LightBackground)
gvwHunks.Rows.Height = Max(gvwHunks.Font.Height, 20)
For iInd = gvwHunks.Rows.Count To $hPatch.Count - 1
gvwHunks.Rows.Count = $hPatch.Count
For iInd = 0 To $hPatch.Count - 1
With $hPatch[iInd]
Inc gvwHunks.Rows.Count
gvwHunks[iInd, 0].Picture = Picture["img/16/" & IIf(.Active, "checked.png", "unchecked.png")]
gvwHunks[iInd, 0].Padding = 2
If .ToFile Then
@ -196,6 +195,13 @@ Public Sub txtPath_Click()
End
Public Sub Clear()
$hPatch = New Patch
RefreshHunks()
End
Public Sub Parse(sFile As String)
Inc Application.Busy