diff --git a/app/src/gambas3/.src/Exported/TextEditor.class b/app/src/gambas3/.src/Exported/TextEditor.class index 1d6e967e1..9c7cafffa 100644 --- a/app/src/gambas3/.src/Exported/TextEditor.class +++ b/app/src/gambas3/.src/Exported/TextEditor.class @@ -14,6 +14,10 @@ Private $hLabelTimer As Timer Private $hObserver As Observer Private $iLastLine As Integer = -1 +Private $bLabelBottom As Boolean +Private $iLabelX As Integer +Private $iLabelY As Integer + Static Private $sFindPrefix As String Static Private $aFind As Integer[] @@ -205,6 +209,30 @@ Public Sub Label_MouseDown() End +Private Sub MoveMessageLabel() + + Dim X As Integer + Dim Y As Integer + + If Not $hLabel Then Return + If Not $hLabel.Visible Then Return + + If $bLabelBottom Then + X = 0 + Y = Container(Me.Proxy).ClientH - $hLabel.H + Else + X = $iLabelX + Y = $iLabelY + Endif + + X = Me.ScreenX + X - $hLabel.Parent.ScreenX + Y = Me.ScreenY + Y - $hLabel.Parent.ScreenY + + If (Y + $hLabel.H) > $hLabel.Parent.ClientH Then Y -= $hLabel.H + Me.LineHeight + $hLabel.Move(X, Y) + +End + Public Sub ShowMessageLabel(sStr As String, Optional X As Integer, Y As Integer, iStyle As Integer) @@ -231,19 +259,19 @@ Public Sub ShowMessageLabel(sStr As String, Optional X As Integer, Y As Integer, $hLabel.Background = Color.Merge(Me.Styles[iStyle].Color, Style.BackgroundOf(Me), 0.3) $hLabel.Text = " " & Replace(Replace(sStr, "
", " "), "
", " ") & " "
- If IsMissing(X) Then X = 0
- If IsMissing(Y) Then Y = Container(Me.Proxy).ClientH - $hLabel.H
-
- X = Me.ScreenX + X - $hLabel.Parent.ScreenX
- Y = Me.ScreenY + Y - $hLabel.Parent.ScreenY
-
- If (Y + $hLabel.H) > $hLabel.Parent.ClientH Then Y -= $hLabel.H + Me.LineHeight
- $hLabel.Move(X, Y)
+ If IsMissing(X) And If IsMissing(Y) Then
+ $bLabelBottom = True
+ Else
+ $bLabelBottom = False
+ $iLabelX = X
+ $iLabelY = Y
+ Endif
$hLabel.Show
$hLabel.Raise
- $hLabelTimer.Stop
- $hLabelTimer.Start
+ MoveMessageLabel
+
+ $hLabelTimer.Restart
Me.SetFocus
End
@@ -312,3 +340,9 @@ Public Sub FindStrings(sPrefix As String) As Integer[]
Return $aFind
End
+
+Public Sub Editor_Arrange()
+
+ MoveMessageLabel
+
+End
diff --git a/app/src/gambas3/.src/FMain.class b/app/src/gambas3/.src/FMain.class
index 3d40803d5..4f59c09ce 100644
--- a/app/src/gambas3/.src/FMain.class
+++ b/app/src/gambas3/.src/FMain.class
@@ -1291,6 +1291,7 @@ Public Sub OnProjectChange()
'Action["breakerr"].Value = Project.BreakOnError
OnRefreshComponents
UpdateRunButton
+
'UpdateTranslate
'RefreshInfo
'IF $bHidden THEN HideAll
@@ -2837,15 +2838,18 @@ End
Public Sub OnVersionControlChange()
- If Not VersionControl.Enabled Then
- mnuVersionControl.Hide
- Else
- mnuVersionControl.Show
+ Action["version-control"].Visible = VersionControl.Enabled
+
+ If VersionControl.Enabled Then
mnuVersionControl.Text = ("Version control") & " (" & VersionControl.Name & ")"
btnVersionControl.Text = VersionControl.Name
UpdateBranchMenu
Endif
+ mnuVersionControlWith.Children.Clear
+ VersionControl.InitControlProjectMenu(mnuVersionControlWith)
+ mnuVersionControlWith.Visible = mnuVersionControlWith.Children.Count
+
End
Public Sub mnuVcBranchSet_Click()
diff --git a/app/src/gambas3/.src/FMain.form b/app/src/gambas3/.src/FMain.form
index 191fecda3..e3f68dbbb 100644
--- a/app/src/gambas3/.src/FMain.form
+++ b/app/src/gambas3/.src/FMain.form
@@ -178,8 +178,9 @@
}
}
{ mnuVersionControl Menu
+ Action = "version-control"
Text = ("Version control")
- Picture = Picture["icon:/small/calendar"]
+ Picture = Picture["icon:/small/record"]
{ mnuVcCommit Menu
Action = "vc-commit"
Text = ("Commit") & "..."
@@ -205,6 +206,10 @@
Text = ("Branch")
}
}
+ { mnuVersionControlWith Menu
+ Text = ("Put under version control")
+ Picture = Picture["icon:/small/record"]
+ }
{ mnuPublish Menu
Action = "publish"
Text = ("Publish") & "..."
@@ -1199,7 +1204,7 @@
Border = False
}
{ timSearchProject #Timer
- #MoveScaled(21,8)
+ #MoveScaled(21,9)
Delay = 500
}
}
@@ -1704,6 +1709,7 @@
}
{ Action version-control
Text = "Version control"
+ Shortcut = ""
Picture = "icon:/small/record"
}
}
diff --git a/app/src/gambas3/.src/VersionControl/CVersionControl.class b/app/src/gambas3/.src/VersionControl/CVersionControl.class
index 7d29549cc..f2e724cee 100644
--- a/app/src/gambas3/.src/VersionControl/CVersionControl.class
+++ b/app/src/gambas3/.src/VersionControl/CVersionControl.class
@@ -3,6 +3,7 @@
Create Static
Public Const Name As String = ""
+Public Const LongName As String = ""
Public Const DoNotPush As Boolean = False
Public Sub AddFile((sPath) As String, Optional (bForce) As Boolean)
@@ -88,3 +89,11 @@ End
Public Sub SetBranch((sBranch) As String)
End
+
+Public Sub CanControlProject() As Boolean
+
+End
+
+Public Sub ControlProject() As Boolean
+
+End
diff --git a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class
index 10d786ad0..b844992bd 100644
--- a/app/src/gambas3/.src/VersionControl/CVersionControlGit.class
+++ b/app/src/gambas3/.src/VersionControl/CVersionControlGit.class
@@ -4,6 +4,7 @@ Inherits CVersionControl
Create Static
Public Const Name As String = "Git"
+Public Const LongName As String = "Git"
Public Const DoNotPush As Boolean = True
Private $aConflict As String[] = ["DD", "AU", "UD", "UA", "DU", "AA", "UU"]
@@ -11,22 +12,45 @@ Private $aConflict As String[] = ["DD", "AU", "UD", "UA", "DU", "AA", "UU"]
Private $bHasGit As Boolean
Private $bCheckGit As Boolean
Private $sRoot As String
+Private $bCanControl As Boolean
+Private $bCanInit As Boolean
+
+Private Sub Init()
+
+ If $bCheckGit Then Return
+
+ $bHasGit = System.Exist("git")
+ $bCheckGit = True
+
+End
Public Sub Check() As Boolean
Dim sResult As String
- If Not $bCheckGit Then
- $bHasGit = System.Exist("git")
- $bCheckGit = True
- Endif
+ Init()
If $bHasGit Then
- sResult = VersionControl.Shell("cd " & Shell$(Project.Dir) & " && git rev-parse --show-toplevel")
- If Process.LastValue = 0 Then
- $sRoot = Trim(sResult)
- Return True
+
+ sResult = VersionControl.Shell("cd " & Shell(Project.Dir) & " && git status --porcelain .project")
+
+ If Process.LastValue Then
+ $bCanInit = True
+ $bCanControl = False
+ Else
+ $bCanInit = False
+ $bCanControl = sResult Begins "??"
+
+ If Not $bCanControl Then
+ sResult = VersionControl.Shell("cd " & Shell$(Project.Dir) & " && git rev-parse --show-toplevel")
+ If Process.LastValue = 0 Then
+ $sRoot = Trim(sResult)
+ Return True
+ Endif
+ Endif
+
Endif
+
Endif
End
@@ -205,7 +229,8 @@ Public Sub Commit(sChange As String, bDoNotPush As Boolean) As Boolean
Dim aEnv As String[]
File.Save(sFile, sChange)
- VersionControl.Run(["git", "commit", "-F", sFile, Project.Dir], False, False, VersionControl.LANG_ENV)
+ 'VersionControl.Run(["git", "commit", "-F", sFile, Project.Dir], False, False, VersionControl.LANG_ENV)
+ VersionControl.Shell("cd " & Shell(Project.Dir) & " && git commit -F " & Shell$(sFile) & " .", Project.Dir)
If Process.LastValue Then Return True
If Not bDoNotPush Then
@@ -280,3 +305,28 @@ Public Sub UpdatePath(sPath As String, Optional sPath2 As String)
End
+Public Sub CanControlProject() As Boolean
+
+ Return $bCanControl Or $bCanInit
+
+End
+
+Public Sub ControlProject() As Boolean
+
+ If Not CanControlProject() Then Return True
+
+ If $bCanInit Then
+
+ If Message.Warning(("A new Git repository will be created for this project."), ("OK"), ("Cancel")) = 2 Then Return
+
+ VersionControl.Shell("cd " & Shell(Project.Dir) & " && git init && git add .")
+ If Process.LastValue Then Return True
+
+ Else
+
+ VersionControl.Shell("cd " & Shell(Project.Dir) & " && git add .")
+
+ Endif
+
+
+End
diff --git a/app/src/gambas3/.src/VersionControl/CVersionControlSubversion.class b/app/src/gambas3/.src/VersionControl/CVersionControlSubversion.class
index 441f1c28d..57634e930 100644
--- a/app/src/gambas3/.src/VersionControl/CVersionControlSubversion.class
+++ b/app/src/gambas3/.src/VersionControl/CVersionControlSubversion.class
@@ -4,12 +4,14 @@ Inherits CVersionControl
Create Static
Public Const Name As String = "Svn"
+Public Const LongName As String = "Subversion"
Private $sRealDir As String
Private $bHasSVN As Boolean
Private $bCheckSVN As Boolean
Private $sSvnVersion As String
Private $bSvn17 As Boolean
+Private $bCanControl As Boolean
Private Sub SvnPath$(sPath As String) As String
@@ -19,18 +21,13 @@ Private Sub SvnPath$(sPath As String) As String
End
-Public Sub Check() As Boolean
+Private Sub Init()
- Dim sResult As String
-
- Shell "readlink -f " & Shell$(Project.Dir) To $sRealDir
- $sRealDir = Trim($sRealDir)
+ If $bCheckSVN Then Return
+
+ $bHasSVN = System.Exist("svn")
+ $bCheckSVN = True
- If Not $bCheckSVN Then
- $bHasSVN = System.Exist("svn")
- $bCheckSVN = True
- Endif
-
If $bHasSVN Then
If Not $sSvnVersion Then
@@ -38,12 +35,45 @@ Public Sub Check() As Boolean
$sSvnVersion = Trim($sSvnVersion)
$bSvn17 = Comp($sSvnVersion, "1.7", gb.Natural) >= 0
Endif
+
+ Endif
+End
+
+
+Public Sub Check() As Boolean
+
+ Dim sResult As String
+ Dim sDir As String
+
+ Shell "readlink -f " & Shell$(Project.Dir) To $sRealDir
+ $sRealDir = Trim($sRealDir)
+
+ Init()
+
+ If $bHasSVN Then
+
+ $bCanControl = False
+
If $bSvn17 Then
sResult = VersionControl.Shell("svn status " & Shell$(SvnPath$($sRealDir) &/ ".project") & " 2>&1")
If Process.LastValue = 0 And If sResult Not Like "svn:*W155007*:*" And If sResult Not Like "svn:*W155010*:*" Then Return True
Else
- Return Exist($sRealDir &/ ".svn")
+ If Exist($sRealDir &/ ".svn") Then Return True
+ Endif
+
+ If $bSvn17 Then
+ sDir = $sRealDir
+ Do
+ sDir = File.Dir(sDir)
+ If Exist(sDir &/ ".svn") Then
+ $bCanControl = True
+ Break
+ Endif
+ If sDir = "/" Then Break
+ Loop
+ Else
+ $bCanControl = Exist($sRealDir &/ "../.svn")
Endif
Endif
@@ -330,3 +360,15 @@ Public Sub UpdatePath(sPath As String, Optional sPath2 As String)
End
+Public Sub CanControlProject() As Boolean
+
+ Return $bCanControl
+
+End
+
+Public Sub ControlProject() As Boolean
+
+ If Not $bCanControl Then Return True
+ If VersionControl.Run(["svn", "add", "--parents", SvnPath$($sRealDir)]) Then Return True
+
+End
diff --git a/app/src/gambas3/.src/VersionControl/FVersionError.class b/app/src/gambas3/.src/VersionControl/FVersionError.class
index 3d5092b22..beff963eb 100644
--- a/app/src/gambas3/.src/VersionControl/FVersionError.class
+++ b/app/src/gambas3/.src/VersionControl/FVersionError.class
@@ -1,20 +1,47 @@
' Gambas class file
-Public Sub Run() As Boolean
+Static Private $sText As String
+Static Private $sDetail As String
- Return Not Me.ShowModal()
+Public Sub Run(sText As String, sDetail As String)
+
+ $sText = sText
+ $sDetail = Trim(sDetail)
+
+ Me.ShowModal()
End
Public Sub btnOK_Click()
- Me.Close(TRUE)
-
-End
-
-Public Sub btnCancel_Click()
-
Me.Close
End
+Public Sub Form_Open()
+
+ Dim DS, W, H As Integer
+
+ lblError.Text = $sText
+
+ If $sDetail Then
+
+ Project.SetEditorFont(lblDetail)
+ lblDetail.Text = $sDetail
+
+ DS = Desktop.Scale
+ lblDetail.Padding = DS
+ With lblDetail.Font
+ W = .TextWidth($sDetail)
+ H = .TextHeight($sDetail)
+ End With
+
+ Else
+
+ lblDetail.Hide
+
+ Endif
+
+ Me.Resize(Max(lblDetail.X + W + DS * 4, 48 * DS), lblDetail.Y + H + DS * 8)
+
+End
diff --git a/app/src/gambas3/.src/VersionControl/FVersionError.form b/app/src/gambas3/.src/VersionControl/FVersionError.form
index 030cd8763..d11ffb102 100644
--- a/app/src/gambas3/.src/VersionControl/FVersionError.form
+++ b/app/src/gambas3/.src/VersionControl/FVersionError.form
@@ -1,27 +1,41 @@
# Gambas Form File 3.0
-{ FVersionError Form
- MoveScaled(0,0,64,64)
+{ Form Form
+ MoveScaled(0,0,59,64)
Resizable = False
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
-{ HBox1 HBox
- MoveScaled(1,59,62,4)
- Spacing = True
- { Panel1 Panel
- MoveScaled(4,0,4,4)
+ { HBox2 HBox
+ MoveScaled(1,1,54,8)
+ Spacing = True
+ { PictureBox1 PictureBox
+ MoveScaled(0,0,8,8)
+ Picture = Picture["icon:/huge/error"]
+ Stretch = True
+ }
+ { lblError Label
+ MoveScaled(11,1,37,7)
+ Expand = True
+ }
+ }
+ { lblDetail Label
+ MoveScaled(1,11,54,17)
Expand = True
+ Border = Border.Plain
}
- { btnOK Button
- MoveScaled(29,0,16,4)
- Text = ("OK")
- Default = True
- }
- { btnCancel Button
- MoveScaled(46,0,16,4)
- Text = ("Cancel")
- Cancel = True
+ { HBox1 HBox
+ MoveScaled(1,59,57,4)
+ Spacing = True
+ { Panel1 Panel
+ MoveScaled(4,0,4,4)
+ Expand = True
+ }
+ { btnOK Button
+ MoveScaled(40,0,16,4)
+ Text = ("OK")
+ Default = True
+ Cancel = True
+ }
}
}
-}
diff --git a/app/src/gambas3/.src/VersionControl/VersionControl.module b/app/src/gambas3/.src/VersionControl/VersionControl.module
index e9b38bb75..0bc6b5ae4 100644
--- a/app/src/gambas3/.src/VersionControl/VersionControl.module
+++ b/app/src/gambas3/.src/VersionControl/VersionControl.module
@@ -19,6 +19,8 @@ Private $bAuth As Boolean
Private $sUser As String
Private $sPassword As String
+Private $sLastResult As String
+
'Public (User) As String
'Public Password As String
'Public UseTerminal As Boolean
@@ -71,7 +73,10 @@ Public Sub Shell(sCmd As String, Optional bSilent As Boolean, Optional aEnv As S
If Not bSilent Then Insert(sCmd & "\n")
Shell sCmd With aEnv To sResult
- If Process.LastValue Then Insert(sResult)
+ If Process.LastValue Then
+ $sLastResult = sResult
+ Insert(sResult)
+ Endif
Return sResult
End
@@ -88,6 +93,7 @@ Public Sub Run(aCmd As String[], Optional bIdent As Boolean, Optional bOutput As
$sOutput = ""
$bOutput = bOutput
$dOutput = Now
+ $sLastResult = ""
' If bIdent Then
' 'aCmd.Add("--non-interactive")
@@ -129,6 +135,7 @@ End
Public Sub Process_Error(({Error}) As String)
+ $sLastResult &= {Error}
Insert({Error})
End
@@ -302,7 +309,7 @@ Public Sub Commit(sChange As String, bDoNotPush As Boolean) As Boolean
Dec Application.Busy
If bRes Then
- Message.Error(("The project could not be committed."))
+ FVersionError.Run(("The project could not be committed."), $sLastResult)
Endif
Return bRes
@@ -320,7 +327,7 @@ Public Sub Update()
Dec Application.Busy
If bErr Then
- Message.Error(("Unable to update project from repository."))
+ FVersionError.Run(("Unable to update project from repository."), $sLastResult)
Else
Message.Info(("Project has been updated from repository successfully."))
Endif
@@ -350,7 +357,7 @@ End
Public Sub CheckoutSVN(sPath As String, sDir As String, hEditor As TextEditor)
$hEditor = hEditor
- CVersionControlSubversion.checkout(sPath, sDir)
+ CVersionControlSubversion.Checkout(sPath, sDir)
$hEditor = Null
End
@@ -417,16 +424,42 @@ Public Sub CanControlProject() As Boolean
End
-Public Sub ControlProject()
+Public Sub ControlProject(sType As String)
- ' If CanControlProject() Then
- ' Project.CleanUp
- ' Try Kill Project.Dir &/ ".settings"
- ' Run(["svn", "add", "--parents", SvnPath$($sRealDir)])
- ' Project.Config.Save
- ' Refresh
- ' Project.Refresh
- ' Endif
+ Dim hVC As CVersionControl
+ Dim bErr As Boolean
+
+ Select Case sType
+
+ Case CVersionControlSubversion.Name
+ hVC = CVersionControlSubversion
+
+ Case CVersionControlGit.Name
+ hVC = CVersionControlGit
+
+ Default
+ Return
+
+ End Select
+
+ If Not hVC.CanControlProject() Then Return
+
+ If Message.Question(Subst(("Do you really want to put this project under version control with &1?"), hVC.LongName), ("Yes"), ("No")) = 2 Then Return
+
+ Project.CleanUp
+ Try Kill Project.Dir &/ ".settings"
+
+ bErr = hVC.ControlProject()
+
+ Project.Config.Save
+
+ If Not bErr Then
+ Refresh
+ Project.Refresh
+ FVersionControl.Run()
+ Else
+ FVersionError.Run(("The project could not be put under version control."), $sLastResult)
+ Endif
End
@@ -510,7 +543,36 @@ Public Sub SetBranch(sBranch As String)
Dec Application.Busy
If sCurrent <> sBranch Then
- Message.Error(Subst(("Unable to switch to branch `&1`."), sBranch))
+ FVersionError.Run(Subst(("Unable to switch to branch `&1`."), sBranch), $sLastResult)
Endif
End
+
+Public Sub InitControlProjectMenu(hParent As Menu)
+
+ Dim hMenu As Menu
+ Dim hVC As CVersionControl
+
+ hVC = CVersionControlSubversion
+ GoSub CHECK_CONTROL
+ hVC = CVersionControlGit
+ GoSub CHECK_CONTROL
+ Return
+
+CHECK_CONTROL:
+
+ If hVC.CanControlProject() Then
+ hMenu = New Menu(hParent) As "ControlProject"
+ hMenu.Text = Subst(("With &1"), hVC.LongName)
+ hMenu.Tag = hVC.Name
+ Endif
+
+ Return
+
+End
+
+Public Sub ControlProject_Click()
+
+ ControlProject(Last.Tag)
+
+End