Initial implementation of remote debugging through ssh.

[DEVELOPMENT ENVIRONMENT]
* NEW: Initial implementation of remote debugging through ssh.
* NEW: Update French translation.
This commit is contained in:
gambas 2022-02-02 21:23:18 +01:00
parent 9280365122
commit b1c053d577
27 changed files with 8226 additions and 7674 deletions

File diff suppressed because it is too large Load diff

View file

@ -34,7 +34,7 @@ Component=gb.util.web
Description="Integrated Development Environment for Gambas"
Authors="Benoît Minisini\nFabien Bodard\nCharlie Reinl\nJosé Luis Redrejo\nRobert Rowe\nTobias Boege"
Arguments=[["-L"],["-t","/home/benoit/gambas/git/master/app/src/gambas3"],["--help"]]
Environment=" GB_NO_JIT=1\nGB_GUI=gb.gtk3\n GTK_DEBUG=interactive"
Environment=" GB_NO_JIT=1\nGB_GUI=gb.qt5\n GTK_DEBUG=interactive"
TabSize=2
Translate=1
Language=en

View file

@ -2,7 +2,6 @@
Static Public SpecialMethods As String[] = ["_attach", "_call", "_compare", "_get", "_init", "_new", "_next", "_property", "_put", "_unknown", "_exit", "_ready", "_read", "_write"]
Static Private $cTypeName As New Collection
Static Private $cNameType As New Collection(gb.IgnoreCase)

View file

@ -1,12 +1,14 @@
' Gambas module file
Private Const DEBUG_REMOTE As Boolean = False
Public Startup As String
Public ProcessId As Integer
Public ProcessFiles As Integer
Public ProcessMemory As Long
Public Enum ACTION_RUN, ACTION_RUN_WITH, ACTION_STEP, ACTION_FORWARD, ACTION_RETURN_FROM, ACTION_RUN_REMOTE
Public Enum ACTION_RUN, ACTION_RUN_WITH, ACTION_STEP, ACTION_FORWARD, ACTION_RETURN_FROM, ACTION_RUN_EXTERN
Private Const STATE_LAST As Integer = -1
Private Const STATE_STOP As Integer = 0
@ -18,7 +20,6 @@ Private $bTest As Boolean
Private $iState As Integer
Private $hProcess As Process
Private $hObserver As Observer
'Private $bRunRemote As Boolean
Private $sPosClass As String
Private $iPosLine As Integer
@ -52,13 +53,21 @@ Private $hBrowser As Process
Private $hTimerShowConsole As Timer
Private $bRemote As Boolean
Private $sRemoteLink As String
Private $hTimerRemote As Timer
Private $bExtern As Boolean
Private $sExternLink As String
Private $hTimerExtern As Timer
Private $hTimerWatch As Timer
Private $sBuffer As String
Private $sRemoteDebuggerHelper As String
Private $bRemote As Boolean
Private $hRemoteFifo As Process
Private $sRemoteBuffer As String
Private $bRemoteFifoAuth As Boolean
Private $bProcessAuth As Boolean
Private $bProcessIgnoreNextNewLine As Boolean
Public Sub Init()
$sFifo = Debug.Begin()
@ -106,7 +115,7 @@ Private Sub SetState(iState As Integer)
'bDebug = $iState <> STATE_STOP And $iState <> STATE_STARTING
Action["run-remote"].Enabled = iState = STATE_STOP
Action["run-extern"].Enabled = iState = STATE_STOP
Action["pause"].Enabled = iState = STATE_RUNNING
bEnable = iState <> STATE_RUNNING And iState <> STATE_STARTING
Action["forward"].Enabled = bEnable
@ -149,10 +158,11 @@ Public Sub Pause()
If $iState <> STATE_RUNNING Then Return
' If Project.UseTerminal Then
' If $iProcessId Then Signal.Send($iProcessId, Signal.SIGUSR2)
' Else
If ProcessId Then Signal.Send(ProcessId, Signal.SIGUSR2)
If $bRemote Then
WriteCommand("p" & CStr(ProcessId))
Else
If ProcessId Then Debug.Signal(ProcessId)
Endif
End
@ -187,7 +197,28 @@ End
Public Sub Process_Read()
Dim sData As String
$hTimerShowConsole.Restart
If $bRemote Then
sData = Read #$hProcess, Lof($hProcess)
If DEBUG_REMOTE Then Debug Quote(sData)
If $bProcessAuth Then
If $bProcessIgnoreNextNewLine And If sData Begins "\r\n" Then
sData = Mid$(sData, 3)
$bProcessIgnoreNextNewLine = False
If Not sData Then Return
Endif
FOutput.Insert(sData, True)
Endif
Endif
End
Public Sub Process_Prompt((Prompt) As String, (Answer) As String)
$bProcessAuth = True
$bProcessIgnoreNextNewLine = True
End
@ -204,18 +235,6 @@ Public Sub TimerShowConsole_Timer()
End
' Public Sub Process_Read()
'
' Dim sData As String
'
' sData = Read #Last, -4096
' Insert(sData)
'
' End
'
Private Sub Translate(sErr As String) As String
If InStr(sErr, " ") Then Return Tr$(sErr)
@ -223,7 +242,6 @@ Private Sub Translate(sErr As String) As String
End
Public Sub MakeMessage(sErr As String) As String
Dim aErr As String[]
@ -286,6 +304,8 @@ Public Sub Debug_Read(Data As String)
$bStart = True
Signal
Return
Else If Not Data Then
Return
Endif
aData = Split(Data, "\t")
@ -316,7 +336,7 @@ Public Sub Debug_Read(Data As String)
$hTimerWatch.Delay = 1000
$hTimerWatch.Start
TimerWatch_Timer
FDebugInfo.UpdateProcessId()
FDebugInfo.UpdateProcessInfo(ProcessId, ProcessFiles, ProcessMemory)
Endif
Endif
@ -463,6 +483,18 @@ Public Sub Debug_Read(Data As String)
End Select
Case "i"
sVar = Mid$(aData[0], 2)
If Not sVar Then
$hTimerWatch.Stop
Else
aData = Split(sVar)
Try ProcessFiles = CInt(aData[0])
Try ProcessMemory = CLong(aData[1])
FDebugInfo.UpdateProcessInfo(-1, ProcessFiles, ProcessMemory)
Endif
End Select
End
@ -478,6 +510,8 @@ Public Sub Process_Kill()
Dim sMsg As String
Dim bTest As Boolean
If $bRemote And If DEBUG_REMOTE Then Debug
bTest = $bTest
If bTest Then
@ -508,7 +542,7 @@ Public Sub Process_Kill()
If bTest Then
FDebugInfo.StopTest(MTest.TEST_FAIL)
Else
FMain.ShowInfo(Subst(("The program has returned\nthe value: &1"), $hProcess.Value))
FDebugButton.SetMessage(Subst(("The program has returned the value &1."), $hProcess.Value))
Endif
Else
If bTest Then FDebugInfo.StopTest(MTest.TEST_SUCCESS)
@ -522,7 +556,6 @@ Public Sub Process_Kill()
End
Private Sub AfterStop()
Dim hForm As Object
@ -534,6 +567,11 @@ Private Sub AfterStop()
Debug.Stop
If $hRemoteFifo Then
Try $hRemoteFifo.Kill
$hRemoteFifo.Wait(0.5)
Endif
If $sPipeError Then
$hPipeError.Close
$sPipeError = ""
@ -570,12 +608,12 @@ Private Sub AfterStop()
If Not $bConsole Then FMain.ShowDebug(False, True)
FDebugInfo.UpdateView
If $bRemote Then
$hTimerRemote.Stop
$hTimerRemote = Null
Try Kill $sRemoteLink
If $bExtern Then
$hTimerExtern.Stop
$hTimerExtern = Null
Try Kill $sExternLink
FDebugInfo.StopWaitForRemote
$bRemote = False
$bExtern = False
Endif
' FOR EACH hForm IN $cShow
@ -748,8 +786,13 @@ End
Private Sub WriteCommand(sCmd As String)
'Error "---> "; sCmd
Debug.Write(sCmd)
If $hRemoteFifo Then
If DEBUG_REMOTE Then Debug "---> "; sCmd
Print #$hRemoteFifo, sCmd
'Flush #$hRemoteFifo
Else
Debug.Write(sCmd)
Endif
End
@ -949,6 +992,14 @@ Private Sub Start(sCmd As String)
Dim iPos As Integer
Dim I As Integer
Dim aProg As String[]
Dim sRemoteServer As String
Dim sRemoteFolder As String
Dim sRemoteUser As String
Dim aRemoteCmd As String[]
Dim sRemotePassword As String
Dim hCopyProcess As Process
Dim sFifo As String
Dim sRemoteDebuggerHelper As String
If Project.Running Then Return
@ -956,7 +1007,68 @@ Private Sub Start(sCmd As String)
$bConsole = Action["console"].Value
If Project.Compile() Then Return
$bRemote = Project.Config["/Debug/Remote"]
If $bRemote Then
If Project.MakeExecutable(True, True) Then Return
' Create the debugger helper
sRemoteDebuggerHelper = CreateDebuggerHelper()
If Not sRemoteDebuggerHelper Then Return
sRemoteServer = Project.Config["/Debug/RemoteServer"]
sRemoteFolder = Project.Config["/Debug/RemoteDirectory"]
sRemoteUser = Project.Config["/Debug/RemoteUser"]
Try sRemotePassword = Desktop.Passwords[Project.Name &/ "RemoteDebug"]
' Create the remote directory and the remote fifo
Project.SetMessage(("Initialize remote debugging..."))
If sRemoteFolder = "~" Then
sRemoteFolder = "/home" &/ sRemoteUser
Else If sRemoteFolder Begins "~/" Then
sRemoteFolder = "/home" &/ sRemoteUser &/ Mid$(sRemoteFolder, 3)
Endif
sFifo = sRemoteFolder &/ ".remote."
aExec = ["ssh", "-q", "-o", "StrictHostKeyChecking=no", sRemoteUser & "@" & sRemoteServer,
"mkdir -p " & Shell(sRemoteFolder) & " && " &
"rm -f " & Shell(sFifo & "in") & " " & Shell(sFifo & "out") & " && " &
"mkfifo " & Shell(sFifo & "in") & " " & Shell(sFifo & "out")]
$sRemoteBuffer = aExec.Join(" ")
hCopyProcess = Exec aExec For Input Output As "RemoteProcess"
hCopyProcess.Expect("password:", sRemotePassword)
hCopyProcess.Wait
If hCopyProcess.Value Then
FMain.ShowErrorWithOutput(("Unable to initialize remote debugging."), $sRemoteBuffer)
Return
Endif
' Copy the executable to the remote server
$sRemoteBuffer = ""
hCopyProcess = Exec ["scp", "-q", "-o", "StrictHostKeyChecking=no", Project.GetExecPath(), sRemoteDebuggerHelper, sRemoteUser & "@" & sRemoteServer & ":" & sRemoteFolder] For Input Output As "RemoteProcess"
hCopyProcess.Expect("password:", sRemotePassword)
hCopyProcess.Wait
If hCopyProcess.Value Then
FMain.ShowErrorWithOutput(("Unable to copy executable to the remote server."), $sRemoteBuffer)
Return
Endif
Project.SetMessage(("OK"), True)
Else
If Project.Compile() Then Return
sFifo = $sFifo
Endif
ClearOutput
@ -997,6 +1109,7 @@ Private Sub Start(sCmd As String)
FDebugInfo.OnProjectDebug
aEnv = Project.Environment.Copy()
If $bRemote Then Try aEnv.Insert(Project.Config["/Debug/RemoteEnvironment"])
I = 0
While I < aEnv.Count
If aEnv[I] Begins " " Then
@ -1012,7 +1125,7 @@ Private Sub Start(sCmd As String)
If $bTest Then
aExec = [System.Path &/ "bin/gbx" & System.Version, "-g", "-f", $sFifo, "-T", GetTestSuite(), File.Dir(SConv(Project.Path))]
aExec = [System.Path &/ "bin/gbx" & System.Version, "-g", "-f", sFifo, "-T", GetTestSuite(), File.Dir(SConv(Project.Path))]
$hProcess = FDebugInfo.GetTestTerminal().Exec(aExec, aEnv)
$hProcess.Term.Echo = True
@ -1022,20 +1135,13 @@ Private Sub Start(sCmd As String)
If Project.Profiling Then FProfile.CleanProfileFiles
' If Project.Environment And If Project.Environment.Count Then
'
' sExec = Project.Environment.Join(" ")
' sExec &= " exec " & Shell$(System.Path &/ "bin/gbx" & System.Version) & " -g -f " & Shell$(File.Dir(SConv(Project.Path)))
'
' For Each sArg In Project.Arguments
' sExec &= " " & Shell$(sArg)
' Next
'
' $hProcess = Shell sExec For Read Write As "Process"
'
' Else
aExec = [System.Path &/ "bin/gbx" & System.Version, "-g", "-f", $sFifo]
If $bRemote Then
aExec = ["gbr" & System.Version]
Else
aExec = [System.Path &/ "bin/gbx" & System.Version]
Endif
aExec.Insert(["-g", "-f", sFifo])
If Startup Then
aExec.Add("-s")
@ -1072,10 +1178,14 @@ Private Sub Start(sCmd As String)
Endif
aExec.Add(File.Dir(SConv(Project.Path)))
If $bRemote Then
aExec.Add(sRemoteFolder &/ File.Name(Project.GetExecPath()))
Else
aExec.Add(File.Dir(SConv(Project.Path)))
Endif
If Project.CurrentArgument Then
aExec.Add("--")
If Project.CurrentArgument And If Project.CurrentArgument.Count Then
If Not $bRemote Then aExec.Add("--")
aExec.Insert(Project.CurrentArgument)
Endif
@ -1091,8 +1201,15 @@ Private Sub Start(sCmd As String)
aExec.Insert(["valgrind", "--tool=memcheck", "--num-callers=50"], 0)
Endif
'If Project.UseTerminal Then aExec.Insert(["/usr/bin/Terminal", "--hold", "--disable-server", "-x"], 0)
If $bRemote Then
aRemoteCmd = ["ssh", "-q", "-t", "-o", "StrictHostKeyChecking=no", sRemoteUser & "@" & sRemoteServer]
aRemoteCmd.Insert(aEnv)
aEnv.Clear
aExec.Insert(aRemoteCmd, 0)
Endif
If Project.UseTerminal Then
sTitle = Project.Name & " (" & ("Output terminal") & ")"
@ -1162,13 +1279,29 @@ Private Sub Start(sCmd As String)
End Select
If sProg Then
If $bRemote Then
$bRemoteFifoAuth = False
$hRemoteFifo = Exec ["ssh", "-q", "-t", "-o", "StrictHostKeyChecking=no", sRemoteUser & "@" & sRemoteServer, sRemoteFolder &/ File.Name($sRemoteDebuggerHelper)] For Input Output As "RemoteFifo"
$hRemoteFifo.Term.Echo = False
$hRemoteFifo.Expect("password:", sRemotePassword)
If DEBUG_REMOTE Then Debug aExec.Join(" ")
$bProcessAuth = False
$hProcess = Exec aExec With aEnv For Input Output As "Process"
$hProcess.Expect("password:", sRemotePassword)
Else If sProg Then
$hProcess = Exec aExec With aEnv As "Process"
Else
'$hProcess = Exec aExec With aEnv For Input Output As "Process"
$hProcess = FOutput.GetTerminal().Exec(aExec, aEnv)
$hProcess.Term.Echo = True
$hObserver = New Observer($hProcess, True) As "Process"
Endif
If $sPipeError Then
@ -1209,7 +1342,7 @@ Private Sub Start(sCmd As String)
End
Public Sub RunRemote()
Public Sub RunExtern()
Dim hForm As Object
Dim sDir As String
@ -1219,18 +1352,18 @@ Public Sub RunRemote()
sDir = File.Dir(Temp$())
$sRemoteLink = "/tmp/gambas-" & Project.Name & ".debug"
$sExternLink = "/tmp/gambas-" & Project.Name & ".debug"
Try hStat = Stat($sRemoteLink)
Try hStat = Stat($sExternLink)
If hStat And If IsDir(hStat.Link) Then
FMain.ShowErrorWith(("Unable to start remote debugging."), ("Another remote debugging is active."))
FMain.ShowErrorWith(("Unable to start extern debugging."), ("Another extern debugging is active."))
Return
Endif
Try Kill $sRemoteLink
Try Link sDir To $sRemoteLink
Try Kill $sExternLink
Try Link sDir To $sExternLink
If Error Then
FMain.ShowErrorWith(("Unable to start remote debugging."))
FMain.ShowErrorWith(("Unable to start extern debugging."))
Return
Endif
@ -1254,7 +1387,7 @@ Public Sub RunRemote()
$sCmdStart &= "g"
$bRemote = True
$bExtern = True
$bStart = True
Project.Running = True
@ -1280,9 +1413,9 @@ Public Sub RunRemote()
Return
Endif
$hTimerRemote = New Timer As "TimerRemote"
$hTimerRemote.Delay = 500
$hTimerRemote.Start
$hTimerExtern = New Timer As "TimerExtern"
$hTimerExtern.Delay = 500
$hTimerExtern.Start
'
' 'If Project.Profiling Then FProfile.CleanProfileFiles
'
@ -1292,7 +1425,7 @@ Public Sub RunRemote()
'
End
Public Sub TimerRemote_Timer()
Public Sub TimerExtern_Timer()
Dim sPath As String
Dim hLock As File
@ -1342,7 +1475,7 @@ Public Sub Command(sCmd As String, Optional iNewState As Integer = STATE_LAST)
'IF NOT Project.Running THEN RETURN
'WAIT
If Not $hProcess And If Not $bRemote Then Return
If Not $hProcess And If Not $bExtern Then Return
'IF bResult THEN
' $cCommand.Add(sPrefix & sCmd)
@ -1370,7 +1503,7 @@ Private Sub Signal()
'PRINT "Signal"
If $bStart Then
If $bRemote Then FDebugInfo.StopWaitForRemote
If $bExtern Then FDebugInfo.StopWaitForRemote
'PRINT "START Debug.Write: "; $sCmdStart
WriteCommand($sCmdStart)
$bStart = False
@ -1504,9 +1637,9 @@ Public Sub SetBalloon(hCtrl As Control, Optional X As Integer = -1, Y As Integer
End
Public Sub IsRemote() As Boolean
Public Sub IsExtern() As Boolean
Return $bRemote
Return $bExtern
End
@ -1522,6 +1655,13 @@ Public Sub TimerWatch_Timer()
Return
Endif
If $bRemote Then
WriteCommand("i" & CStr(ProcessId))
Return
Endif
sDir = "/proc" &/ CStr(ProcessId)
If Not IsDir(sDir) Then
$hTimerWatch.Stop
@ -1544,6 +1684,96 @@ Public Sub TimerWatch_Timer()
Next
Endif
FDebugInfo.UpdateProcessInfo()
FDebugInfo.UpdateProcessInfo(-1, ProcessFiles, ProcessMemory)
End
Public Sub RemoteProcess_Read()
Dim sData As String
sData = Read #Last, Lof(Last)
If DEBUG_REMOTE Then Debug Quote(sData)
$sRemoteBuffer &= sData
End
Public Sub RemoteProcess_Error(sData As String)
If DEBUG_REMOTE Then Debug Quote(sData)
$sRemoteBuffer &= sData
End
Public Sub RemoteProcess_Kill()
If DEBUG_REMOTE Then Debug
End
Public Sub RemoteFifo_Prompt((Prompt) As String, (Answer) As String)
$bRemoteFifoAuth = True
End
Public Sub RemoteFifo_Read()
Dim sData As String
Dim iPos As Integer
sData = Read #Last, Lof(Last)
If Not $bRemoteFifoAuth Then Return
sData = Replace(sData, "\r", "")
If DEBUG_REMOTE Then Debug Quote(sData)
Do
iPos = InStr(sData, "\n")
If iPos Then
Debug_Read(Left(sData, iPos))
sData = Mid$(sData, iPos + 1)
Else
Debug_Read(sData)
Break
Endif
Loop
End
Public Sub RemoteFifo_Kill()
If DEBUG_REMOTE Then Debug
$hRemoteFifo = Null
End
Private Sub CreateDebuggerHelper() As String
Dim sDir As String
Dim sOutput As String
Dim sPath As String
If Not $sRemoteDebuggerHelper Then
sDir = File.Dir(Temp$()) &/ "remote-debugger-helper"
Mkdir sDir
Mkdir sDir &/ ".src"
Copy "debugger/Main.module" To sDir &/ ".src/Main.module"
Copy "debugger/_project" To sDir &/ ".project"
Shell "cd " & Shell(sDir) & " && gbc3 -gt -j1 2>&1 && gba3 2>&1" To sOutput
sPath = sDir &/ "remote-debugger-helper.gambas"
If Not Exist(sPath) Then
FMain.ShowErrorWithOutput(("Unable to generate the remote debugger helper."), sOutput)
Return
Endif
$sRemoteDebuggerHelper = sPath
Endif
Return $sRemoteDebuggerHelper
End

View file

@ -110,7 +110,24 @@ End
Public Sub dwgStatus_Draw()
Try Project.ActiveForm.PaintStatus()
Dim W As Integer
Dim X As Integer
Dim DS As Integer
If $sMessage Then
DS = Desktop.Scale
Paint.Font.Grade = -1
'Paint.Font.Bold = True
W = Paint.TextSize($sMessage).W + DS * 3
X = dwgStatus.W - W - DS \ 2
Paint.Rectangle(X, DS \ 2, W, dwgStatus.H - DS, DS * 2)
Paint.Background = Color.LightBackground
Paint.Fill
Paint.Background = Color.TextForeground
Paint.DrawText($sMessage, X, DS \ 2, W, dwgStatus.H - DS, Align.Center)
Else
Try Project.ActiveForm.PaintStatus()
Endif
End
@ -122,15 +139,9 @@ Public Sub SetMessage(Optional sText As String, bAdd As Boolean)
$sMessage = sText
Endif
dwgStatus.Refresh
If $sMessage Then
lblMessage.Text = $sMessage
lblMessage.Show
dwgStatus.Hide
If Project.NoWait = 0 Then Wait
Else
lblMessage.Hide
dwgStatus.Show
dwgStatus.Refresh
Endif
If Not $sMessage Then

View file

@ -68,22 +68,12 @@
MoveScaled(113,0,1,5)
}
{ Panel2 Panel
MoveScaled(120,1,1,3)
}
{ lblMessage Label
MoveScaled(122,1,11,3)
Visible = False
Expand = True
Alignment = Align.Right
MoveScaled(117,1,3,3)
}
{ dwgStatus DrawingArea
MoveScaled(135,1,6,3)
Visible = False
MoveScaled(124,1,17,3)
Expand = True
}
{ Panel1 Panel
MoveScaled(143,1,1,3)
}
{ timMessage #Timer
#MoveScaled(102,1)
Delay = 10000

View file

@ -1335,59 +1335,50 @@ Public Sub OnProjectDebug()
End
' Public Sub UpdateProcessId(iId As Integer)
'
' btnDebugProcess.Text = Subst(("Process &1"), iId)
'
' End
Public Sub UpdateProcessId()
Public Sub UpdateProcessInfo(iProcessId As Integer, iProcessFiles As Integer, iProcessMemory As Long)
If Design.IsRemote() Then
picProcess.Picture = Picture["icon:/small/connect"]
Else
picProcess.Picture = Picture["icon:/small/exec"]
Endif
If Design.ProcessId = 0 Then
If iProcessId >= 0 Then
lblProcessId.Hide
If Design.IsExtern() Then
picProcess.Picture = Picture["icon:/small/connect"]
Else
picProcess.Picture = Picture["icon:/small/exec"]
Endif
Else
lblProcessId.Show
lblProcessId.Text = Subst(("Process &1"), Design.ProcessId)
UpdateProcessInfo
If iProcessId = 0 Then
lblProcessId.Hide
Else
lblProcessId.Show
lblProcessId.Text = Subst(("Process &1"), iProcessId)
Endif
Endif
End
Public Sub UpdateProcessInfo()
If Design.ProcessId = 0 Then
If iProcessId = 0 Then
panProcessFiles.Hide
panProcessMemoryRead.Hide
Else
If Design.ProcessFiles < 0 Then
If iProcessFiles < 0 Then
panProcessFiles.Hide
Else
panProcessFiles.Show
lblProcessFiles.Text = CStr(Design.ProcessFiles)
lblProcessFiles.Text = CStr(iProcessFiles)
Endif
If Design.ProcessMemory < 0 Then
If iProcessMemory < 0 Then
panProcessMemory.Hide
Else
panProcessMemory.Show
lblProcessMemory.Text = File.FormatSize(Design.ProcessMemory, True)
lblProcessMemory.Text = File.FormatSize(iProcessMemory, True)
Endif
Endif
End

View file

@ -251,7 +251,7 @@
MoveScaled(1,10,18,5)
Foreground = Color.LightForeground
AutoResize = True
Text = ("Waiting for remote process") & "..."
Text = ("Waiting for extern process") & "..."
Alignment = Align.Center
}
}

View file

@ -0,0 +1,97 @@
' Gambas class file
Public Sub Run() As Boolean
Return Not Me.ShowModal()
End
Public Sub btnRemoteDebugging_Click()
panRemoteDebugging.Enabled = btnRemoteDebugging.Value
End
Public Sub btnCancel_Click()
Me.Close
End
Public Sub Form_Open()
btnRemoteDebugging.Value = Project.Config["/Debug/Remote"]
txtRemoteServer.Text = Project.Config["/Debug/RemoteServer"]
txtRemoteUser.Text = Project.Config["/Debug/RemoteUser"]
txtRemoteDirectory.Text = Project.Config["/Debug/RemoteDirectory"]
Try txtRemotePassword.Text = Desktop.Passwords[Project.Name &/ "RemoteDebug"]
choEnv.Environment = Project.Config["/Debug/RemoteEnvironment"]
End
Public Sub txtRemotePassword_Click()
txtRemotePassword.Password = Not txtRemotePassword
End
Public Sub btnInsertEnv_Click()
choEnv.Insert()
End
Public Sub btnRemoveEnv_Click()
choEnv.RemoveCurrent()
End
Public Sub btnMoveUpEnv_Click()
choEnv.MoveUpCurrent
End
Public Sub btnMoveDownEnv_Click()
choEnv.MoveDownCurrent
End
Public Sub choEnv_Select()
btnRemoveEnv.Enabled = choEnv.Current >= 0
btnMoveDownEnv.Enabled = btnRemoveEnv.Enabled
btnMoveUpEnv.Enabled = btnRemoveEnv.Enabled
End
Public Sub btnOK_Click()
If btnRemoteDebugging.Value Then
If Not Trim(txtRemoteServer.Text) Or If Not Trim(txtRemoteUser.Text) Or If Not Trim(txtRemoteDirectory.Text) Then
Message.Warning("Remote server, user and folder are required.")
Return
Endif
Endif
Project.Config["/Debug/Remote"] = btnRemoteDebugging.Value
Project.Config["/Debug/RemoteServer"] = txtRemoteServer.Text
Project.Config["/Debug/RemoteUser"] = txtRemoteUser.Text
Project.Config["/Debug/RemoteDirectory"] = txtRemoteDirectory.Text
Try Desktop.Passwords[Project.Name &/ "RemoteDebug"] = txtRemotePassword.Text
Project.Config["/Debug/RemoteEnvironment"] = choEnv.Environment
Project.Config.Save()
Me.Close(True)
End

View file

@ -0,0 +1,165 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,69,72)
Text = ("Remote debugging")
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ HBox19 HBox
MoveScaled(1,1,55,4)
{ Label32 Label
MoveScaled(0,0,31,4)
Font = Font["Bold"]
Expand = True
Text = ("Activate remote debugging")
}
{ btnRemoteDebugging SwitchButton
MoveScaled(45,0,8,4)
Animated = True
}
}
{ panRemoteDebugging VBox
MoveScaled(1,6,63,60)
Enabled = False
Expand = True
Spacing = True
{ HBox20 HBox
MoveScaled(0,0,56,4)
Spacing = True
Indent = True
{ Label33 Label
MoveScaled(0,0,20,4)
Text = ("Protocol")
}
{ Label34 Label
MoveScaled(44,0,8,4)
Alignment = Align.Center
Border = Border.Raised
Text = ("SSH")
}
}
{ HBox21 HBox
MoveScaled(0,5,56,4)
Spacing = True
Indent = True
{ Label35 Label
MoveScaled(0,0,20,4)
Text = ("Server")
}
{ txtRemoteServer TextBox
MoveScaled(30,0,24,4)
Expand = True
}
}
{ HBox2 HBox
MoveScaled(0,10,56,4)
Spacing = True
Indent = True
{ Label1 Label
MoveScaled(0,0,20,4)
Text = ("User")
}
{ txtRemoteUser TextBox
MoveScaled(30,0,24,4)
Expand = True
}
}
{ HBox3 HBox
MoveScaled(0,15,56,4)
Spacing = True
Indent = True
{ Label2 Label
MoveScaled(0,0,20,4)
Text = ("Password")
}
{ txtRemotePassword ButtonBox
MoveScaled(30,0,24,4)
Expand = True
Picture = Picture["icon:/small/watch"]
Password = True
}
}
{ HBox23 HBox
MoveScaled(0,20,56,4)
Spacing = True
Indent = True
{ Label37 Label
MoveScaled(0,0,20,4)
Text = ("Directory")
}
{ txtRemoteDirectory TextBox
MoveScaled(30,0,24,4)
Expand = True
}
}
{ Label3 Label
MoveScaled(0,26,36,3)
Font = Font["Bold"]
Text = ("Remote environment")
}
{ Panel3 Panel
MoveScaled(2,30,41,27)
Expand = True
Arrangement = Arrange.Vertical
Border = Border.Plain
{ choEnv EnvChooser
MoveScaled(5,3,16,16)
Expand = True
}
{ Separator2 Separator
MoveScaled(10,21,15,0)
}
{ HBox4 HBox
MoveScaled(4,22,36,4)
Background = Color.TextBackground
{ btnInsertEnv ToolButton
MoveScaled(0,0,11,4)
AutoResize = True
Text = Shortcut(("Add"), "A")
Picture = Picture["icon:/small/add"]
}
{ btnRemoveEnv ToolButton
MoveScaled(12,0,12,4)
Enabled = False
AutoResize = True
Text = Shortcut(("Remove"), "R")
Picture = Picture["icon:/small/remove"]
}
{ btnMoveUpEnv ToolButton
MoveScaled(24,0,4,4)
Enabled = False
Picture = Picture["icon:/small/up"]
}
{ btnMoveDownEnv ToolButton
MoveScaled(28,0,4,4)
Enabled = False
Picture = Picture["icon:/small/down"]
}
}
}
}
{ HBox1 HBox
MoveScaled(1,67,67,4)
Spacing = True
{ btnRemoteCheck Button
MoveScaled(0,0,26,4)
Enabled = False
AutoResize = True
Text = ("Check remote server")
}
{ Spring1 Spring
MoveScaled(27,1,4,2)
}
{ btnOK Button
MoveScaled(34,0,15,4)
Text = ("OK")
Default = True
}
{ btnCancel Button
MoveScaled(50,0,15,4)
Text = ("Cancel")
Cancel = True
}
}
}

View file

@ -53,20 +53,12 @@ Public Sub Clear()
End
Public Sub Insert(sText As String, Optional bCurrent As Boolean)
Public Sub Insert(sText As String, Optional bNoReplace As Boolean)
If chkCharset.Value Then
Try sText = DConv$(sText)
Endif
If chkCharset.Value Then Try sText = DConv$(sText)
If Not bCurrent Then
'edtOutput.Line = edtOutput.Lines.Count
'edtOutput.Goto(edtOutput.Lines.Count, 10000)
Endif
'If Not Action["console"].Value Then Action["console"].Value = True
trmOutput.Print(Replace(sText, "\n", "\r\n"))
If Not bNoReplace Then sText = Replace(sText, "\n", "\r\n")
trmOutput.Print(sText)
End

View file

@ -3152,6 +3152,7 @@ Public Sub panToolBar_Configure()
UpdateMenu
UpdateDiffAction
UpdateRemote
Project.UpdateLockedAction(Me)
If $sModule Then
@ -4013,3 +4014,9 @@ Public Sub btnDiffNext_Click()
If Y >= 0 Then $hEditor.Goto($hEditor.Column, Y)
End
Public Sub UpdateRemote()
Action[".run-me", Me].Picture = Project.GetDebuggerIcon(panToolbar.Size)
End

View file

@ -1661,6 +1661,7 @@ Private Sub DrawDropFrame()
H = .DefaultHeight
End With
$hCtrlFrame = Null
DrawFrame(hParent, X - $hDropTarget.Grid(W \ 2), Y - $hDropTarget.Grid(H \ 2), W, H, True)
End
@ -4110,6 +4111,7 @@ Public Sub tlbForm_Configure()
'Action[".show-class"].Picture = Project.GetFileIcon(File.SetExt(Path, "class"), 16)
UpdateMenu
UpdateDiffAction
UpdateRemote
End
@ -4655,3 +4657,9 @@ Private Function DiffMode_Read() As Boolean
Return $bDiffMode
End
Public Sub UpdateRemote()
Action[".run-me", Me].Picture = Project.GetDebuggerIcon(tlbForm.Size)
End

View file

@ -0,0 +1,281 @@
' Gambas class file
Export
Inherits UserControl
Property Environment As String[]
Property Read Current As Integer
Event Select
Event Activate
Private tvwEnv As TableView
Private $aEnv As String[]
Public Sub _new()
tvwEnv = New TableView(Me) As "tvwEnv"
tvwEnv.Grid = True
tvwEnv.Border = False
tvwEnv.Header = GridView.Horizontal
tvwEnv.Mode = Select.Single
tvwEnv.AddColumn("")
tvwEnv.AddColumn(("Variable"), Desktop.Scale * 16)
tvwEnv.AddColumn(("Value"))
tvwEnv.Rows.Resizable = False
End
Private Sub IsEnvDisabled(Row As Integer) As Boolean
Return $aEnv[Row] Begins " "
End
Public Sub tvwEnv_Click()
Dim iRow As Integer
If tvwEnv.Column Then
tvwEnv.Edit
Else
Try iRow = Key.Code
If Not Error Then
Stop Event
Return
Endif
iRow = tvwEnv.Row
If IsEnvDisabled(iRow) Then
$aEnv[iRow] = Mid$($aEnv[iRow], 2)
Else
$aEnv[iRow] = " " & $aEnv[iRow]
Endif
tvwEnv[iRow, 0].Refresh
Endif
End
Public Sub tvwEnv_Data(Row As Integer, Column As Integer)
Dim sEnv As String = $aEnv[Row]
Dim aEnv As String[]
If Column = 0 Then Return
If sEnv Begins " " Then
tvwEnv.Data.Foreground = Color.LightForeground
sEnv = Mid$(sEnv, 2)
Endif
aEnv = Scan(sEnv, "*=*")
Try tvwEnv.Data.Text = aEnv[Column - 1]
End
Public Sub tvwEnv_Draw(X As Integer, Y As Integer, Width As Integer, Height As Integer, Row As Integer, Column As Integer)
If Column Then Return
X += (Width - 16) \ 2
Y += (Height - 16) \ 2
'Y += (gvwComponent.Rows.Height - gvwComponent.Padding * 2 - 16) \ 2
Width = 16
Height = 16
Style.PaintBox(X - 2, Y - 2, Width + 4, Height + 4)
If Not IsEnvDisabled(Row) Then
Paint.DrawPicture(Picture["img/16/checked.png"], X, Y)
Endif
End
Public Sub tvwEnv_Hide()
UpdateEnv
End
Private Sub UpdateEnv()
tvwEnv.Rows.Count = $aEnv.Count
tvwEnv.Columns[0].Width = Desktop.Scale * 4
tvwEnv.Columns[0].Resizable = False
tvwEnv.Columns[1].Width = -1
tvwEnv.Refresh
End
Public Sub tvwEnv_Insert()
If Key.Normal Then
Raise Activate
Else If Key.Control Then
Insert
Endif
End
Public Sub tvwEnv_Save(Row As Integer, Column As Integer, Value As String)
Dim sEnv As String = $aEnv[Row]
Dim aEnv As String[]
Dim bDisabled As Boolean
If Column = 0 Then Return
If sEnv Begins " " Then
bDisabled = True
sEnv = Mid$(sEnv, 2)
Endif
aEnv = Scan(sEnv, "*=*")
If Column = 1 Then
sEnv = Trim(Value) & "=" & aEnv[1]
Else
sEnv = aEnv[0] & "=" & Value
Endif
If bDisabled Then sEnv = " " & sEnv
$aEnv[Row] = sEnv
If Column = 1 Then tvwEnv.Columns[1].Width = -1
End
Public Sub tvwEnv_Select()
Raise Select
' btnRemoveEnv.Enabled = tvwEnv.Row >= 0
' btnMoveDownEnv.Enabled = btnRemoveEnv.Enabled
' btnMoveUpEnv.Enabled = btnRemoveEnv.Enabled
End
Private Function Current_Read() As Integer
Return tvwEnv.Row
End
Public Sub Insert(Optional aEnv As String[])
Dim sNewEnv As String
Dim aNewEnv As String[]
Dim iInd As Integer
If Not aEnv Then
If $aEnv.Count >= 255 Then Return
$aEnv.Add("=")
UpdateEnv
tvwEnv.MoveTo($aEnv.Max, 1)
tvwEnv.Columns[1].Width = Max(tvwEnv.Columns[1].Width, Desktop.Scale * 24)
tvwEnv.Edit
Else
For Each sNewEnv In aEnv
aNewEnv = Scan(sNewEnv, "*=*")
For iInd = 0 To $aEnv.Max
aEnv = Scan($aEnv[iInd], "*=*")
If aEnv[0] = aNewEnv[0] Then
aEnv[1] = aNewEnv[1]
$aEnv[iInd] = aEnv[0] & "=" & aEnv[1]
tvwEnv.Refresh
sNewEnv = ""
Break
Endif
Next
If sNewEnv Then
$aEnv.Add(sNewEnv)
UpdateEnv
Endif
Next
Endif
End
Public Sub RemoveCurrent()
If $aEnv.Count = 0 Then Return
If tvwEnv.Row < 0 Then Return
tvwEnv.Save
$aEnv.Remove(tvwEnv.Row)
UpdateEnv
End
Public Sub MoveUpCurrent()
Dim iRow As Integer
iRow = tvwEnv.Row
If iRow < 1 Then Return
tvwEnv.Save()
Swap $aEnv[iRow], $aEnv[iRow - 1]
tvwEnv.Refresh
tvwEnv.MoveTo(iRow - 1, tvwEnv.Column)
End
Public Sub MoveDownCurrent()
Dim iRow As Integer
iRow = tvwEnv.Row
If iRow < 0 Or If iRow >= $aEnv.Max Then Return
tvwEnv.Save()
Swap $aEnv[iRow], $aEnv[iRow + 1]
tvwEnv.Refresh
tvwEnv.MoveTo(iRow + 1, tvwEnv.Column)
End
Private Function Environment_Read() As String[]
Dim iInd As Integer
Dim aEnv As String[]
tvwEnv.Save
aEnv = $aEnv.Copy()
While iInd < aEnv.Count
If Not Trim(Scan(aEnv[iInd], "*=*")[0]) Then
aEnv.Remove(iInd)
Else
Inc iInd
Endif
Wend
Return aEnv
End
Private Sub Environment_Write(Value As String[])
If Not Value Then
$aEnv = New String[]
Else
$aEnv = Value.Copy()
Endif
UpdateEnv
End

View file

@ -1363,6 +1363,7 @@ Public Sub OnProjectChange()
UpdateGlobalLayout
UpdateMenu
UpdateRemote
'If $bInOpenExtern Then Return
@ -1488,8 +1489,10 @@ Public Sub Action_Activate((Key) As String) As Boolean
Project.Run(False, Design.ACTION_RUN)
Case "run-with"
If Not FArguments.Run() Then Project.Run(False, Design.ACTION_RUN_WITH)
Case "run-extern"
Project.Run(False, Design.ACTION_RUN_EXTERN)
Case "run-remote"
Project.Run(False, Design.ACTION_RUN_REMOTE)
If Not FDebugRemote.Run() Then UpdateRemote
Case "test"
Project.Test()
Case "test-suite"
@ -2258,6 +2261,12 @@ Public Sub ShowErrorWith(sTitle As String, Optional sMsg As String, Optional sKe
End
Public Sub ShowErrorWithOutput(sTitle As String, sOutput As String, Optional sKey As String)
ShowMessage("<b>" & sTitle & "</b>\n\n<font size=\"-1\"><tt>" & Html(sOutput) & "</tt></font>", "error", sKey)
End
Public Sub ShowWarning(sMsg As String, Optional sKey As String)
ShowMessage(sMsg, "warning", sKey)
@ -3328,3 +3337,14 @@ Public Sub btnVcAddAll_Click()
FMain.mnuAddVersionAll_Click()
End
Private Sub UpdateRemote()
Dim hForm As Object
Action["start"].Picture = Project.GetDebuggerIcon(tlbMain.Size)
For Each hForm In Project.Files
Try hForm.UpdateRemote()
Next
End

View file

@ -265,14 +265,22 @@
Picture = Picture["icon:/small/play"]
Shortcut = "F5"
}
{ mnuDebugExtern Menu
Action = "run-extern"
Text = ("Debug extern process") & "..."
Picture = Picture["icon:/small/connect"]
}
{ Menu49 Menu
}
{ Menu45 Menu
Action = "run-with"
Text = ("Run with") & "..."
Text = ("Program arguments") & "..."
Picture = Picture["icon:/small/text"]
}
{ mnuRemoteDebug Menu
{ mnuDebugRemote Menu
Action = "run-remote"
Text = ("Run remotely")
Picture = Picture["icon:/small/connect"]
Text = ("Remote debugging") & "..."
Picture = Picture["icon:/small/network"]
}
{ Menu14 Menu
}
@ -1270,8 +1278,8 @@
{ btnRunRemote ToolButton
MoveScaled(104,4,4,4)
Visible = False
ToolTip = ("Run remotely")
Action = "run-remote"
ToolTip = ("Extern debugging")
Action = "run-extern"
Picture = Picture["icon:/small/connect"]
}
}
@ -1840,11 +1848,16 @@
Shortcut = ""
Picture = "icon:/small/eject"
}
{ Action run-remote
Text = "Run remotely"
{ Action run-extern
Text = "Debug extern process"
Shortcut = ""
Picture = "icon:/small/connect"
}
{ Action run-remote
Text = "Remote debugging"
Shortcut = ""
Picture = "icon:/small/network"
}
{ Action run-that
Text = "Run this class"
Shortcut = ""
@ -1966,7 +1979,7 @@
{ Toolbars
{ Toolbar main
Text = ""
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,exec,translate,archive,install,project,property,control,console,find,help,compile,compile-all,test,start,pause,stop,step,forward,return,until,find-project,go-back,go-forward,browse-project,open-terminal,send-mail,publish,farm,gui,menu-file,menu-edit,menu-project,menu-debug,menu-view,menu-tool,menu-help,version-control,run-with,run-remote"
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,exec,translate,archive,install,project,property,control,console,find,help,compile,compile-all,test,start,pause,stop,step,forward,return,until,find-project,go-back,go-forward,browse-project,open-terminal,send-mail,publish,farm,gui,menu-file,menu-edit,menu-project,menu-debug,menu-view,menu-tool,menu-help,version-control,run-with,run-extern"
Default = "new-project,open-project,save-project,save-project-as,project-property,option,|,exec,translate,|,compile,compile-all,test,start,pause,stop,step,forward,return,until,-,find-project,go-back,go-forward,version-control"
}
}

View file

@ -248,7 +248,7 @@ End
Public Sub SelectImage((sPropertyType) As String, sImage As String) As String
Return FSelectIcon.Run(sImage, FSelectIcon.SELECT_STOCK + FSelectIcon.SELECT_IMAGE + FSelectIcon.SELECT_SVGIMAGE + FSelectIcon.SELECT_PUBLIC, ["normal", "huge"])
Return FSelectIcon.Run(sImage, FSelectIcon.SELECT_STOCK + FSelectIcon.SELECT_IMAGE + FSelectIcon.SELECT_SVGIMAGE + FSelectIcon.SELECT_PUBLIC, ["medium", "huge"])
End

View file

@ -867,6 +867,7 @@ End
Public Sub Form_Open()
Me.Center
btnClose.Raise
End
@ -1957,3 +1958,9 @@ Public Sub cmbHighlight_Click()
End
Public Sub Form_Resize()
btnClose.Move(Me.ClientW - btnClose.W - Desktop.Scale, Me.ClientH - btnClose.H - Desktop.Scale)
End

View file

@ -1142,12 +1142,8 @@
{ HBox46 HBox
MoveScaled(1,60,66,4)
Spacing = True
Indent = True
{ Spring2 Spring
MoveScaled(8,0,5,4)
}
{ btnInstallFont Button
MoveScaled(23,0,39,4)
MoveScaled(2,0,39,4)
AutoResize = True
Text = ("Install Gambas fonts for code edition") & "..."
}
@ -1181,7 +1177,7 @@
Mode = PictureBox.Fill
}
{ sldBackgroundBrightness Slider
MoveScaled(5,0,59,4)
MoveScaled(5,0,34,4)
Expand = True
MaxValue = 255
Step = 16
@ -1284,18 +1280,22 @@
{ HBox8 HBox
MoveScaled(0,62,66,4)
Spacing = True
Indent = True
{ Spring5 Spring
MoveScaled(8,0,5,4)
}
{ btnInstallIconTheme Button
MoveScaled(27,0,39,4)
MoveScaled(1,0,39,4)
AutoResize = True
Text = ("Install Gambas icon theme") & "..."
}
}
Index = 0
}
{ btnClose Button
MoveScaled(0,0,20,4)
Visible = False
Ignore = True
AutoResize = True
Text = ("Close")
Picture = Picture["icon:/medium/close"]
}
}
# Gambas Action File 3.0

View file

@ -237,6 +237,8 @@ Public NoWait As Integer
Public OpenFileIgnoreUnknown As Boolean
Private $hRemoteDebugIcon As Image
' If GetFileIcon() has been called on an added file
'Private $bLastAdded As Boolean
@ -2668,13 +2670,13 @@ Public Sub Run(Optional bCompileAll As Boolean, Optional iAction As Integer, Opt
Case Design.ACTION_RETURN_FROM
Design.ReturnFrom
Case Design.ACTION_RUN_REMOTE
Design.RunRemote
Case Design.ACTION_RUN_EXTERN
Design.RunExtern
Case Else
If sStartup Then Design.Startup = sStartup
If iAction = Design.ACTION_RUN Then Project.CurrentArgument = Null
Design.Run
Design.Run()
Design.Startup = ""
End Select
@ -7162,3 +7164,23 @@ Public Sub GrepQuote(sStr As String) As String
End
Public Sub GetDebuggerIcon(sSize As String) As Picture
Dim W As Integer
If Not Config Or If Not Config["/Debug/Remote"] Then Return Picture["icon:/" & sSize & "/play"]
W = Stock.GetSize(sSize)
If Not $hRemoteDebugIcon Or If $hRemoteDebugIcon.W <> W Then
$hRemoteDebugIcon = Picture["icon:/" & sSize & "/play"].Copy().Image
$hRemoteDebugIcon.Brightness(1)
$hRemoteDebugIcon.Colorize(&HC0A600)
Endif
Return $hRemoteDebugIcon.Picture
End

View file

@ -28,6 +28,7 @@ Public Sub Form_Open()
Settings.Read(Me)
Project.SetEditorFont(lstArg)
btnRun.Picture = Project.GetDebuggerIcon("small")
FillList
'lstArg.Index = lstArg.Find(FromArgs(Project.CurrentArgument))

View file

@ -2,7 +2,7 @@
{ Form Form
MoveScaled(0,0,112,38)
Text = ("Run with arguments")
Text = ("Program arguments")
Arrangement = Arrange.Vertical
Spacing = True
Margin = True

View file

@ -8,8 +8,6 @@ Private $sIcon As String
Private $bCanInitComponents As Boolean
Private $aEnv As String[]
Private $aComponents As String[]
Private $aLibraries As String[]
@ -51,12 +49,6 @@ Public Sub _new()
Dim hBorder As Border
tvwEnv.AddColumn("")
tvwEnv.AddColumn(("Variable"), Desktop.Scale * 16)
tvwEnv.AddColumn(("Value"))
tvwEnv.Rows.Resizable = False
hBorder = Border("style:none;bottom-style:solid;padding:" & CStr(Desktop.Scale \ 2) & ";")
hBorder.Color = Color.LightForeground
gvwLibrary.Rows.Border = hBorder
@ -172,28 +164,13 @@ End
Private Sub InitEnvironment()
$aEnv = Project.Environment.Copy()
UpdateEnv
choEnv.Environment = Project.Environment.Copy()
End
Private Sub SaveEnvironment()
Dim iInd As Integer
Dim aEnv As String[]
tvwEnv.Save
aEnv = $aEnv.Copy()
While iInd < $aEnv.Count
If Not Trim(Scan($aEnv[iInd], "*=*")[0]) Then
aEnv.Remove(iInd)
Else
Inc iInd
Endif
Wend
Project.Environment = aEnv
Project.Environment = choEnv.Environment
End
@ -650,164 +627,20 @@ Public Sub btnReset_Click()
End
Private Sub IsEnvDisabled(Row As Integer) As Boolean
Return $aEnv[Row] Begins " "
End
Public Sub tvwEnv_Click()
Dim iRow As Integer
If tvwEnv.Column Then
tvwEnv.Edit
Else
Try iRow = Key.Code
If Not Error Then
Stop Event
Return
Endif
iRow = tvwEnv.Row
If IsEnvDisabled(iRow) Then
$aEnv[iRow] = Mid$($aEnv[iRow], 2)
Else
$aEnv[iRow] = " " & $aEnv[iRow]
Endif
tvwEnv[iRow, 0].Refresh
Endif
End
Public Sub tvwEnv_Draw(X As Integer, Y As Integer, Width As Integer, Height As Integer, Row As Integer, Column As Integer)
If Column Then Return
X += (Width - 16) \ 2
Y += (Height - 16) \ 2
'Y += (gvwComponent.Rows.Height - gvwComponent.Padding * 2 - 16) \ 2
Width = 16
Height = 16
Style.PaintBox(X - 2, Y - 2, Width + 4, Height + 4)
If Not IsEnvDisabled(Row) Then
Paint.DrawPicture(Picture["img/16/checked.png"], X, Y)
Endif
End
Public Sub tvwEnv_Data(Row As Integer, Column As Integer)
Dim sEnv As String = $aEnv[Row]
Dim aEnv As String[]
If Column = 0 Then Return
If sEnv Begins " " Then
tvwEnv.Data.Foreground = Color.LightForeground
sEnv = Mid$(sEnv, 2)
Endif
aEnv = Scan(sEnv, "*=*")
Try tvwEnv.Data.Text = aEnv[Column - 1]
End
Public Sub tvwEnv_Save(Row As Integer, Column As Integer, Value As String)
Dim sEnv As String = $aEnv[Row]
Dim aEnv As String[]
Dim bDisabled As Boolean
If Column = 0 Then Return
If sEnv Begins " " Then
bDisabled = True
sEnv = Mid$(sEnv, 2)
Endif
aEnv = Scan(sEnv, "*=*")
If Column = 1 Then
sEnv = Trim(Value) & "=" & aEnv[1]
Else
sEnv = aEnv[0] & "=" & Value
Endif
If bDisabled Then sEnv = " " & sEnv
$aEnv[Row] = sEnv
If Column = 1 Then tvwEnv.Columns[1].Width = -1
End
Public Sub tvwEnv_Insert()
If Key.Normal Then
btnOK.Value = True
Else If Key.Control Then
btnInsertEnv_Click
Endif
End
Public Sub btnInsertEnv_Click()
If $aEnv.Count >= 255 Then Return
$aEnv.Add("=")
UpdateEnv
tvwEnv.MoveTo($aEnv.Max, 1)
tvwEnv.Columns[1].Width = Max(tvwEnv.Columns[1].Width, Desktop.Scale * 24)
tvwEnv.Edit
choEnv.Insert()
End
Public Sub mnuInsertEnv_Click()
Dim sNewEnv As String = Last.Tag
Dim iInd As Integer
Dim aNewEnv As String[]
Dim aEnv As String[]
If Not sNewEnv Then Return
For Each sNewEnv In Split(sNewEnv)
aNewEnv = Scan(sNewEnv, "*=*")
For iInd = 0 To $aEnv.Max
aEnv = Scan($aEnv[iInd], "*=*")
If aEnv[0] = aNewEnv[0] Then
aEnv[1] = aNewEnv[1]
$aEnv[iInd] = aEnv[0] & "=" & aEnv[1]
tvwEnv.Refresh
sNewEnv = ""
Break
Endif
Next
If sNewEnv Then
$aEnv.Add(sNewEnv)
UpdateEnv
Endif
Next
choEnv.Insert(Split(sNewEnv))
End
Public Sub btnRemoveEnv_Click()
If $aEnv.Count = 0 Then Return
If tvwEnv.Row < 0 Then Return
tvwEnv.Save
$aEnv.Remove(tvwEnv.Row)
UpdateEnv
End
' Public Sub cmbTranslate_Click()
'
' If cmbTranslate.Index = 0 Then
@ -1432,16 +1265,6 @@ Finally
End
Private Sub UpdateEnv()
tvwEnv.Rows.Count = $aEnv.Count
tvwEnv.Columns[0].Width = Desktop.Scale * 4
tvwEnv.Columns[0].Resizable = False
tvwEnv.Columns[1].Width = -1
tvwEnv.Refresh
End
Public Sub lstReferences_Add()
Dim sPath As String
@ -1464,46 +1287,24 @@ End
Public Sub btnMoveUpEnv_Click()
Dim iRow As Integer
iRow = tvwEnv.Row
If iRow < 1 Then Return
tvwEnv.Save()
Swap $aEnv[iRow], $aEnv[iRow - 1]
tvwEnv.Refresh
tvwEnv.MoveTo(iRow - 1, tvwEnv.Column)
choEnv.MoveUpCurrent()
End
Public Sub btnMoveDownEnv_Click()
Dim iRow As Integer
iRow = tvwEnv.Row
If iRow < 0 Or If iRow >= $aEnv.Max Then Return
tvwEnv.Save()
Swap $aEnv[iRow], $aEnv[iRow + 1]
tvwEnv.Refresh
tvwEnv.MoveTo(iRow + 1, tvwEnv.Column)
choEnv.MoveDownCurrent()
End
Public Sub tvwEnv_Select()
Public Sub choEnv_Select()
btnRemoveEnv.Enabled = tvwEnv.Row >= 0
btnRemoveEnv.Enabled = choEnv.Current >= 0
btnMoveDownEnv.Enabled = btnRemoveEnv.Enabled
btnMoveUpEnv.Enabled = btnRemoveEnv.Enabled
End
Public Sub tvwEnv_Hide()
UpdateEnv
End
Public Sub btnWarning_Click()
btnCheckPrefix.Enabled = btnWarning.Value
@ -1521,3 +1322,15 @@ Public Sub lvwExclude_Select()
lvwRequire.UnSelectAll
End
Public Sub btnRemoveEnv_Click()
choEnv.RemoveCurrent()
End
Public Sub choEnv_Activate()
btnOK.Value = True
End

View file

@ -140,7 +140,7 @@
Count = 7
Border = True
Index = 0
Text = ("General")
Text = ("Description")
Picture = Picture["icon:/large/gambas"]
{ Panel4 VBox
MoveScaled(0,0,88,65)
@ -532,13 +532,9 @@
Expand = True
Arrangement = Arrange.Vertical
Border = Border.Plain
{ tvwEnv TableView
MoveScaled(2,2,65,20)
{ choEnv EnvChooser
MoveScaled(5,3,16,16)
Expand = True
Border = False
Mode = Select.Single
Padding = 4
Header = GridView.Horizontal
}
{ Separator2 Separator
MoveScaled(28,24,15,0)

View file

@ -275,7 +275,6 @@ End
Public Sub Form_Hide()
'Settings.Write(Me)
Settings["/FWelcome/SortRecent"] = $iSort
Settings["/FWelcome/Filter"] = txtFilter.Text
@ -460,3 +459,4 @@ Public Sub MediaPlayer_End()
'$hWelcome.NoTear = True
End

View file

@ -0,0 +1,84 @@
' Gambas module file
Class Debug
Private $hRemoteInput As File
Private $hRemoteOutput As File
Public Sub Main()
Dim sDir As String = Application.Path
Component.Load("gb.debug")
$hRemoteOutput = Open Pipe sDir &/ ".remote.out" For Write
$hRemoteInput = Open Pipe sDir &/ ".remote.in" For Read Watch
End
Public Sub Application_Read()
Dim sData As String
' Dim hFile As File
Line Input sData
' hFile = Open "/tmp/" & Application.Name & ".log" For Append
' Print #hFile, sData
' Close #hFile
If sData Begins "p" Then
Debug.Signal(CInt(Mid$(sData, 2)))
Return
Else If sData Begins "i" Then
GetInfo(CInt(Mid$(sData, 2)))
Return
Endif
Print #$hRemoteOutput, sData
End
Public Sub File_Read()
Dim sData As String = Read #Last, Lof(Last)
Print sData;
Flush
End
Private Sub GetInfo(iProcessId As Integer)
Dim sDir As String
Dim iProcessFiles As Integer
Dim iProcessMemory As Long
Dim aMaps As String[]
Dim sMap As String
Dim iPos As Integer
sDir = "/proc" &/ CStr(iProcessId)
If Not IsDir(sDir) Then
Print "i"
Return
Endif
Try iProcessFiles = Dir(sDir &/ "fd").Count
If Error Then iProcessFiles = -1
iProcessMemory = 0
Try aMaps = Split(Trim(File.Load(sDir &/ "smaps_rollup")), "\n")
If aMaps Then
For Each sMap In aMaps
If sMap Begins "Pss:" Then
sMap = LTrim(Mid$(sMap, 5))
iPos = InStr(sMap, " ")
iProcessMemory = CInt(Left(sMap, iPos - 1)) * 1024
Break
Endif
Next
Endif
Print "i"; iProcessFiles; ","; iProcessMemory
Flush
End

View file

@ -0,0 +1,7 @@
# Gambas Project File 3.0
Startup=Main
Version=0.0.1
TabSize=2
Language=en_US
KeepDebugInfo=0
Packager=1