[DEVELOPMENT ENVIRONMENT]

* NEW: Global search can be cancelled.
* NEW: The IDE does not try to open binary files anymore.
* NEW: Use the new TabStrip.TextFont property.
* NEW: The open project dialog has been redesigned.

[INTERPRETER]
* BUG: String.Left(), String.Mid() and String.Right() now return NULL on 
  truncated UTF-8 substrings.


git-svn-id: svn://localhost/gambas/trunk@3029 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-07-05 22:17:49 +00:00
parent 53560dd374
commit 4eee881fda
22 changed files with 4805 additions and 4841 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -530,7 +530,7 @@ Public Sub ReadConfig()
Dim hButton As ToolButton
Settings.Read(splDebug,, [4, 1])
tabDebug.Font.Grade = - Settings["/TabStripFont", 0]
tabDebug.TextFont = Font[CStr(- Settings["/TabStripFont", 0])]
tbvLocal.Font.Grade = - Settings["/GlobalFont", 0]
tbvObject.Font = tbvLocal.Font
lstStack.Font = tbvLocal.Font

View file

@ -311,7 +311,7 @@ Public Sub ReadConfig()
Dim iSize As Integer
tabTool.Font.Grade = - Settings["/TabStripFont", 0]
tabTool.TextFont = Font[CStr(- Settings["/TabStripFont", 0])]
If Settings["/ToolboxSize", 0] Then
iSize = 24

View file

@ -947,8 +947,8 @@ Public Sub ReadConfig()
tvwProject.Font.Grade = - Settings["/GlobalFont", 0]
lblMessage.Font = tvwProject.Font
tabProperty.Font.Grade = - Settings["/TabStripFont", 0]
wrkProject.Font = tabProperty.Font
tabProperty.TextFont = Font[CStr(- Settings["/TabStripFont", 0])]
wrkProject.Font = tabProperty.TextFont
'wrkProject.Font = tvwProject.Font
'tabProperty.Font = tvwProject.Font
panMessage.Height = lblMessage.Font.Height + lblMessage.Padding * 2 + 2
@ -959,7 +959,7 @@ Public Sub ReadConfig()
mnuStatusBar.Value = bShow
Me.Menus.Visible = Settings["/ShowMenus", True]
btnShowMenu.Visible = Not Me.Menus.Visible
panShowMenu.Visible = Not Me.Menus.Visible
MTheme.InitControl(tvwProject)
@ -1613,16 +1613,22 @@ End
Public Sub mnuHideMenu_Click()
Me.Menus.Hide
btnShowMenu.Show
Settings["/ShowMenus"] = Me.Menus.Visible
If Me.Menus.Visible Then
Me.Menus.Hide
sepMenu.Hide
panShowMenu.Show
Settings["/ShowMenus"] = Me.Menus.Visible
Else
btnShowMenu_Click
Endif
End
Public Sub btnShowMenu_Click()
Me.Menus.Show
btnShowMenu.Hide
sepMenu.Show
panShowMenu.Hide
Settings["/ShowMenus"] = Me.Menus.Visible
End

View file

@ -495,7 +495,27 @@
Shortcut = "Ctrl+I"
}
}
{ Separator7 Separator
{ mnuMenu Menu
{ mnuFile2 Menu
Text = ("&File")
}
{ mnuProject2 Menu
Text = ("&Project")
}
{ mnuDebug2 Menu
Text = ("&Debug")
}
{ mnuView2 Menu
Text = ("&View")
}
{ mnuTools2 Menu
Text = ("&Tools")
}
{ mnuHelp2 Menu
Text = ("&?")
}
}
{ sepMenu Separator
MoveScaled(0,0,13,0)
}
{ ToolBar1 ToolBar
@ -712,12 +732,19 @@
{ Separator8 Separator
MoveScaled(129,0,1,4)
}
{ btnShowMenu ToolButton
MoveScaled(130,0,17,4)
ToolTip = ("Show menu bar")
Action = "hide-menubar"
AutoResize = True
Text = ("Show menu bar")
{ panShowMenu HBox
MoveScaled(133,0,26,4)
Expand = True
{ Panel3 Panel
MoveScaled(4,1,2,3)
Expand = True
}
{ btnShowMenu ToolButton
MoveScaled(9,0,17,4)
ToolTip = ("Show menu bar")
AutoResize = True
Text = ("Show menu bar")
}
}
}
{ Panel1 Panel
@ -977,9 +1004,8 @@
Picture = "icon:/small/help"
}
{ Action hide-menubar
Text = "Show menu bar"
Text = "Hide menubar"
Shortcut = "Ctrl+Alt+M"
Picture = "$ToolButton"
}
{ Action info
Text = "&Properties..."
@ -1187,7 +1213,7 @@
{ Toolbars
{ Toolbar main
Text = ""
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,translate,archive,exec,install,project,property,control,console,compile,compile-all,start,pause,stop,step,forward,return,until,watch,break,find-text,find-project,find,hide-menubar"
Default = "new-project,open-project,save-project,save-project-as,project-property,option,|,translate,exec,|,compile,compile-all,start,pause,stop,step,forward,return,until,watch,break,|,find-text,find-project,find,|,hide-menubar"
List = "new-project,open-project,save-project,save-project-as,project-property,refresh-project,option,shortcut,translate,archive,exec,install,project,property,control,console,compile,compile-all,start,pause,stop,step,forward,return,until,watch,break,find-text,find-project,find"
Default = "new-project,open-project,save-project,save-project-as,project-property,option,|,translate,exec,|,compile,compile-all,start,pause,stop,step,forward,return,until,watch,break,|,find-text,find-project,find,|,$panShowMenu"
}
}

View file

@ -16,6 +16,7 @@ Private $bReplace As Boolean
Private $aBrowse As New CFindResult[]
Private $hFont As Font
Private $aExt As String[] = ["JPG", "JPEG", "BMP", "GIF", "PNG", "ICO", "XPM", "GAMBAS"]
Private $bCancel As Boolean
Private Const GO_FORWARD As Integer = 0
Private Const GO_BACKWARD As Integer = 1
@ -240,9 +241,9 @@ Private Sub GrepFile(hFile As Object) As CFindResult[]
hProcess = Exec aGrep For Read Write As "Grep"
Print #hProcess, sText;
Close #hProcess
While hProcess.State = Process.Running
Wait
Wend
Repeat
Wait 0.01
Until hProcess.State <> Process.Running
For Each sFind In Split($sGrep, "\n", "", True)
aFind = Split(sFind, ":")
@ -426,6 +427,17 @@ Public Sub AddFound(hResult As CFindResult)
End
Private Sub EnableGUI(bOn As Boolean)
Dim hCtrl As Control
For Each hCtrl In tabSearch[0].Children
hCtrl.Enabled = bOn
Next
End
Private Sub Browse()
Dim sFile As String
@ -453,7 +465,13 @@ Private Sub Browse()
lblBrowse.Raise
Inc Application.Busy
Me.Enabled = False
FMain.Enabled = False
EnableGUI(False)
'tabSearch.Enabled = False
btnClose.Text = ("Cancel")
btnClose2.Text = ("Cancel")
$bCancel = False
tvwFind.Rows.Count = 0
tvwFind.Clear
@ -478,18 +496,19 @@ Private Sub Browse()
If sName Begins "callgrind.out." Then Continue
If sName Begins "cachegrind.out." Then Continue
'Debug sName
Try hFile = Project.LoadFile(sPath)
If Not hFile Then Continue
If sFile Begins ".src/" Then
lblBrowse.Text = sName
Else
lblBrowse.Text = sFile
Endif
'Debug sName
Wait
Try hFile = Project.LoadFile(sPath)
If Not hFile Then Continue
aResult = GrepFile(hFile)
If $bCancel Then Break
For iInd = 0 To aResult.Max
hResult = aResult[iInd]
If Not hFile.SetPosition(hResult, True) Then
@ -508,7 +527,10 @@ Finally
Endif
lblBrowse.Hide
Me.Enabled = True
EnableGUI(True)
FMain.Enabled = True
btnClose.Text = ("Close")
btnClose2.Text = ("Close")
Dec Application.Busy
End
@ -529,7 +551,11 @@ End
Public Sub btnClose_Click()
Me.Close
If FMain.Enabled Then
Me.Close
Else
$bCancel = True
Endif
End
@ -718,6 +744,8 @@ End
Public Sub Form_KeyPress()
If Key.Code = Key.Esc Then Me.Close
If Key.Code = Key.Esc Then
btnClose_Click
Endif
End

View file

@ -113,8 +113,7 @@
Text = ("Replace &all")
Picture = Picture["icon:/small/wizard"]
}
{ btnBrowse2 Button btnBrowse
Name = "btnBrowse2"
{ btnBrowse Button
MoveScaled(0,16,18,4)
Text = ("&Browse")
Picture = Picture["icon:/small/zoom-in"]
@ -170,12 +169,6 @@
{ panSearch HBox
MoveScaled(1,26,79,4)
Spacing = True
{ btnBrowse Button
MoveScaled(0,0,21,4)
Visible = False
Text = ("&Refresh")
Picture = Picture["icon:/small/refresh"]
}
{ btnBrowseReplace Button
MoveScaled(21,0,21,4)
Visible = False

View file

@ -1406,6 +1406,37 @@ Public Function IsForm(hFile As Object) As Boolean
End
Private Sub IsTextFile(sPath As String) As Boolean
Dim hFile As File
Dim sStr As String
Dim sCar As String
Dim iInd As Integer
Dim iCode As Integer
Dim sTest As String
hFile = Open sPath
sStr = Read #hFile, -256
While sStr
sCar = String.Left(sStr)
If Not sCar Then Break
If Len(sCar) = 1 Then
iCode = Asc(sCar)
If iCode = &HFE Then Return False
If iCode = &HFF Then Return False
If iCode < 32 And If iCode <> 10 And If iCode <> 7 Then Return False
Else
Try sTest = Conv(sCar, "UTF-8", "UCS-4LE")
Endif
If Error Then Return False
sStr = Mid$(sStr, Len(sCar) + 1)
Wend
Return True
End
Public Function LoadFile(sPath As String) As Object
@ -1463,10 +1494,17 @@ Public Function LoadFile(sPath As String) As Object
Select Case Lower(File.Ext(sPath))
Case "png", "gif", "jpg", "jpeg", "bmp", "xpm"
Case "png", "gif", "jpg", "jpeg", "bmp", "xpm"
hForm = New FIconEditor(sPath)
Case Else
' Check that it is not a binary file
If Not IsTextFile(sPath) Then
Dec Application.Busy
Files[sPath] = Null
FMain.ShowError(("Cannot open a binary file."), sPath)
Return
Endif
hForm = New FTextEditor(sPath)
End Select
@ -1485,7 +1523,7 @@ Public Function LoadFile(sPath As String) As Object
hForm.Icon = GetFileIcon(sPath, 16)
Endif
FSearch.OnNewForm(hForm)
If hForm Then FSearch.OnNewForm(hForm)
Dec Application.Busy
@ -1497,7 +1535,7 @@ Catch
Dec Application.Busy
Files[sPath] = Null
FGambas.Error(("Cannot open file.") & "\n\n" & Error.Text & "\n" & Error.Where)
FMain.ShowError(("Cannot open file.") & "\n\n" & Error.Text & "\n" & Error.Where, sPath)
End

View file

@ -24,6 +24,7 @@ Public Sub _new()
$hProjectItem = New ProjectItem(panProjectTitle)
$hProjectItem.Highlight = False
panProject.Reparent(dchProject.FileView.Parent)
End
@ -68,6 +69,7 @@ Public Sub Form_Open()
Settings.Read(Me)
Settings.Read(dchProject)
Settings.Read(splProject)
dchProject.ShowFile = True
'dchProject.Value = Settings["/FOpenProject/Path"]
dchProject_Change
tabProject_Click
@ -114,15 +116,12 @@ Public Sub dchProject_Change()
Dim sPath As String
Dim hProjectTree As CProjectTree
fvwProject.ShowHidden = dchProject.ShowHidden
fvwProject.Dir = dchProject.Value
sPath = GetProjectPath(dchProject.Value)
If Not sPath Then
$sLast = ""
fvwProject.Show
panProject.Hide
dchProject.FileView.Show
Return
Endif
@ -134,44 +133,44 @@ Public Sub dchProject_Change()
hProjectTree = New CProjectTree(tvwProject, sPath)
panProject.Show
fvwProject.Hide
dchProject.FileView.Hide
splProject_Resize
End
Public Sub fvwProject_Activate()
' Public Sub fvwProject_Activate()
'
' Dim sPath As String = fvwProject.Dir &/ fvwProject.Current
' Dim sProg As String
'
' If IsDir(sPath) Then
' dchProject.Value = sPath
' Return
' Endif
'
' If sPath Like "*.tar.gz" Then
' sProg = "tar xfz"
' Else If sPath Like "*.tar.bz2" Then
' sProg = "tar xfj"
' Else
' Return
' Endif
'
' If Message.Question("<b>" & fvwProject.Current & "</b><p>" & ("Do you want to uncompress this archive?"), ("Uncompress"), ("Cancel")) = 2 Then Return
'
' Shell "cd " & Shell$(File.Dir(sPath)) & " && " & sProg & " " & Shell$(sPath) Wait
' dchProject.Reload
'
' End
Dim sPath As String = fvwProject.Dir &/ fvwProject.Current
Dim sProg As String
If IsDir(sPath) Then
dchProject.Value = sPath
Return
Endif
If sPath Like "*.tar.gz" Then
sProg = "tar xfz"
Else If sPath Like "*.tar.bz2" Then
sProg = "tar xfj"
Else
Return
Endif
If Message.Question("<b>" & fvwProject.Current & "</b><p>" & ("Do you want to uncompress this archive?"), ("Uncompress"), ("Cancel")) = 2 Then Return
Shell "cd " & Shell$(File.Dir(sPath)) & " && " & sProg & " " & Shell$(sPath) Wait
dchProject.Reload
End
Public Sub fvwProject_Icon(Path As String)
If Exist(Path &/ ".project") Then
fvwProject.Icon = Project.GetIcon(Path, 16)
Endif
End
' Public Sub fvwProject_Icon(Path As String)
'
' If Exist(Path &/ ".project") Then
' fvwProject.Icon = Project.GetIcon(Path, 16)
' Endif
'
' End
Private Sub FillRecent()
@ -336,12 +335,6 @@ Public Sub lstExample_Activate()
End
Public Sub fvwProject_Menu()
Debug
End
Public Sub splProject_Resize()
panProjectTitle.H = $hProjectItem.IdealHeight + panProjectTitle.Padding * 2

View file

@ -20,26 +20,23 @@
MoveScaled(1,1,93,61)
Expand = True
{ dchProject DirChooser
MoveScaled(1,0,45,58)
MoveScaled(1,0,62,58)
Expand = True
ShowFile = True
ShowBookmark = True
ShowSplitter = False
}
{ Panel2 Panel
MoveScaled(50,3,42,56)
MoveScaled(64,2,28,56)
Visible = False
Arrangement = Arrange.Fill
{ fvwProject FileView
MoveScaled(1,38,40,17)
ShowDetailed = True
ShowDirectory = True
}
{ panProject Panel
MoveScaled(1,1,40,32)
MoveScaled(1,1,26,53)
Arrangement = Arrange.Vertical
Padding = 1
Border = Border.Sunken
{ panProjectTitle Panel
MoveScaled(1,1,34,9)
MoveScaled(1,1,20,9)
Background = Color.TextBackground
Arrangement = Arrange.Fill
Padding = 2
@ -49,8 +46,9 @@
Background = Color.TextBackground
}
{ tvwProject TreeView
MoveScaled(2,13,35,17)
MoveScaled(2,13,22,37)
Expand = True
Mode = Select.None
Border = False
}
}

View file

@ -479,6 +479,14 @@ Settings
p
Variant[]
DirView
r
DirView
FileView
r
FileView
:Change
:
@ -740,6 +748,14 @@ Settings
p
Variant[]
DirView
r
DirView
FileView
r
FileView
ReadOnly
p
b

View file

@ -86,27 +86,27 @@ msgstr ""
msgid "System"
msgstr ""
#: FDirChooser.class:907
#: FDirChooser.class:908
msgid "Parent directory"
msgstr ""
#: FDirChooser.class:918
#: FDirChooser.class:919
msgid "Refresh"
msgstr ""
#: FDirChooser.class:924
#: FDirChooser.class:925
msgid "Create directory"
msgstr ""
#: FDirChooser.class:930
#: FDirChooser.class:931
msgid "View hidden files"
msgstr ""
#: FDirChooser.class:938
#: FDirChooser.class:939
msgid "Toggle view"
msgstr ""
#: FDirChooser.class:944
#: FDirChooser.class:945
msgid "Show files"
msgstr ""

View file

@ -20,6 +20,8 @@ Property ShowSplitter As Boolean
Property Bookmarks As Array
Property Icon As Picture
Property Settings As Variant[]
Property Read DirView As DirView
Property Read FileView As FileView
Event Change
Event Activate
@ -217,3 +219,15 @@ Public Sub Reload()
frmChooser.Reload
End
Private Function FileView_Read() As FileView
Return frmChooser.FileView
End
Private Function DirView_Read() As DirView
Return frmChooser.DirView
End

View file

@ -57,7 +57,7 @@ End
Public Sub dvwChoose_Click()
If fvwChoose.Visible Then fvwChoose.Dir = dvwChoose.Current
If panView.Visible Then fvwChoose.Dir = dvwChoose.Current
AddToHistory(dvwChoose.Current)
Object.Lock(cmbDir)
@ -94,7 +94,7 @@ End
Public Sub btnView_Click()
$bView = Not $bView
fvwChoose.Visible = $bView
panView.Visible = $bView
btnDetailed.Visible = $bView
If $bView Then
fvwChoose.Dir = dvwChoose.Current
@ -165,13 +165,13 @@ End
Public Function GetFileVisible() As Boolean
Return fvwChoose.Visible
Return panView.Visible
End
Public Sub SetFileVisible(bVisible As Boolean)
If fvwChoose.Visible <> bVisible Then btnView_Click
If panView.Visible <> bVisible Then btnView_Click
End

View file

@ -91,9 +91,13 @@
MoveScaled(2,3,25,33)
Picture = Picture["icon:/small/home"]
}
{ fvwChoose FileView
{ panView Panel
MoveScaled(30,2,25,33)
Visible = False
Arrangement = Arrange.Fill
{ fvwChoose FileView
MoveScaled(0,0,20,26)
}
}
}
}

View file

@ -21,6 +21,8 @@ Property ShowDetailed As Boolean
Property ShowBookmark As Boolean
Property Bookmarks As Array
Property Settings As Variant[]
Property Read DirView As DirView
Property Read FileView As FileView
Property ReadOnly As Boolean
Property Filter As String[]
@ -298,3 +300,15 @@ Public Sub Reload()
End
Private Function FileView_Read() As FileView
Return frmChooser.FileView
End
Private Function DirView_Read() As DirView
Return frmChooser.DirView
End

View file

@ -80,6 +80,7 @@ static int get_next_pos(void)
//_pos += get_char_length(&_str[_pos]);
_pos += _char_length[(unsigned char)_str[_pos]];
return _pos;
}
@ -192,6 +193,9 @@ static void get_substring(int start, int len)
break;
}
if (_pos > _len)
_pos = _len;
if (_pos > pos)
GB_ReturnNewString(_str + pos, _pos - pos);
else

View file

@ -274,6 +274,7 @@ bool ARCH_find(ARCH *arch, const char *path, int len_path, ARCH_FIND *find)
if (len_tpath == 0)
{
find->sym = NULL;
find->index = NO_SYMBOL;
find->pos = -1;
find->len = 0;
return FALSE;