[DEVELOPMENT ENVIRONMENT]

* BUG: Fix source file import.
* NEW: New menu entries for inserting HTLM and CSS files.
* BUG: Fix file chooser filter in the file creation dialog.
* BUG: Do not open read-only projects having the old source structure.

[GB.EVAL.HIGHLIGHT]
* NEW: A new component to centralize Editor highlighting routines.

[GB.QT4]
* BUG: Always defer ScrollView layout to prevent strange crashes.



git-svn-id: svn://localhost/gambas/trunk@2079 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2009-07-06 11:04:10 +00:00
parent 43fd627078
commit cb01337b46
44 changed files with 3916 additions and 3627 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@ Private $bMouse As Boolean
Private $bDoNotSetName As Boolean
Private $bInit As Boolean
Private $iFilter As Integer
Private $aFilterType As String[]
Public Sub Run(sPath As String, sDir As String, sType As String)
@ -47,7 +48,7 @@ Public Sub lstType_Click()
Object.Unlock(txtName)
Endif
iFilter = ["module", "class", "form", "image", "html", "text"].Find(LCase(sPrefix))
iFilter = $aFilterType.Find(LCase(sPrefix))
$iFilter = iFilter
txtName.SetFocus
@ -66,17 +67,20 @@ Public Sub Form_Open()
$bDoNotSetName = False
Settings.Read(Me)
$aFilterType = ["module", "class"]
aFilter = ["*.module", ("Gambas modules"), "*.class", ("Gambas classes")]
For Each hModule In CModule.All
$aFilterType.Add(hModule.Key)
aFilter.Add("*." & hModule.Key)
aFilter.Add(hModule.NameFilter)
Next
aFilter.Insert(["*.png;*.jpg;*.jpeg;*.xpm;*.gif", ("Picture files"), "*.htm;*.html", ("HTML files")])
aFilter.Insert(["*.png;*.jpg;*.jpeg;*.xpm;*.gif", ("Picture files"), "*.htm;*.html", ("HTML files"), "*.css", ("Cascading style sheets")])
$aFilterType.Insert(["image", "html", "css", "text"])
fchExisting.Filter = aFilter
@ -361,8 +365,6 @@ Finally
End
Private Sub ImportFile() As Boolean
Dim sDir As String
@ -377,24 +379,24 @@ Private Sub ImportFile() As Boolean
Select Case File.Ext(sTemp)
Case "module"
sName = File.BaseName(Project.GetUniqueName(Project.Dir, sName))
Project.InsertSource(sName, "module", sTemp,,, chkLink.Value)
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "module", $sDir, sTemp,,, chkLink.Value)
Case "class"
sName = File.BaseName(Project.GetUniqueName(Project.Dir, sName))
Project.InsertSource(sName, "class", sTemp,,, chkLink.Value)
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, sTemp,,, chkLink.Value)
Case "form"
sName = File.BaseName(Project.GetUniqueName(Project.Dir, sName))
Project.InsertSource(sName, "class", File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "form", sTemp,, True, chkLink.Value)
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "form", $sDir, sTemp,, True, chkLink.Value)
ImportDependencies(sName, sTemp, chkLink.Value)
Project.OpenForm(sName)
Case "webpage"
sName = File.BaseName(Project.GetUniqueName(Project.Dir, sName))
Project.InsertSource(sName, "class", File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "webpage", sTemp,,, chkLink.Value)
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "webpage", $sDir, sTemp,,, chkLink.Value)
Default
sName = Project.GetUniqueName($sDir, sName)

View File

@ -88,7 +88,7 @@
}
}
{ HBox5 HBox
MoveScaled(0,25,27,6)
MoveScaled(0,25,30,6)
Tag = "image"
Spacing = True
Margin = True

View File

@ -236,4 +236,10 @@ Public Sub tabInfo_Click()
Endif
Endif
End
Public Sub edtChange_Highlight()
End

View File

@ -144,6 +144,7 @@
Text = ("Versioning")
{ edtChange Editor
MoveScaled(1,1,39,28)
Highlight = Highlight.Custom
}
{ lblNoChange TextLabel
MoveScaled(1,1,36,8)

View File

@ -326,18 +326,19 @@ Public Sub mnuPopup_Show()
mnuCopyPath.Visible = mnuCopy.Visible
If mnuNew.Visible Then
mnuAddDirectory.Visible = Project.Dir <> Project.SourceDir
mnuNewFile.Visible = False
mnuNewImage.Visible = False
mnuNewModule.Visible = True
mnuNewClass.Show
For Each hMenu In mnuNew.Children
If Not hMenu.Tag Then Continue
If Not CModule.All.Exist(hMenu.Tag) Then Continue
hMenu.Visible = CModule[hMenu.Tag].Used
If Not CModule.All.Exist(hMenu.Tag) Then
hMenu.Hide
Else
hMenu.Visible = CModule[hMenu.Tag].Used
Endif
Next
mnuNewClass.Show
mnuNewModule.Show
Endif
@ -366,16 +367,19 @@ Public Sub mnuPopup_Show()
If mnuNew.Visible Then
mnuNewFile.Visible = bFile Or bCanStoreFile
mnuNewImage.Visible = mnuNewFile.Visible
mnuNewModule.Hide
mnuAddDirectory.Visible = True
For Each hMenu In mnuNew.Children
If Not hMenu.Tag Then Continue
If CModule.All.Exist(hMenu.Tag) Then
hMenu.Hide
Else
hMenu.Visible = bFile Or bCanStoreFile
Endif
Next
mnuNewClass.Hide
For Each hMenu In mnuNew.Children
If Not hMenu.Tag Then Continue
hMenu.Hide
Next
mnuNewModule.Hide
Endif
Endif

View File

@ -381,6 +381,18 @@
Picture = Picture["icon:/small/image"]
Tag = "image"
}
{ mnuNewHtml Menu mnuNewFile
Name = "mnuNewHtml"
Text = ("&HTML file...")
Picture = Picture["icon:/small/html"]
Tag = "html"
}
{ mnuNewCSS Menu mnuNewFile
Name = "mnuNewCSS"
Text = ("&Style sheet...")
Picture = Picture["icon:/small/html"]
Tag = "css"
}
{ mnuNewFile Menu mnuNewFile
Name = "mnuNewFile"
Action = "new-other"

View File

@ -334,6 +334,10 @@ Public Function Open(sDir As String) As Boolean
VersionControl.Refresh
If Not Exist(SourceDir) Then
If ReadOnly Then
Message.Error(("This project is read-only.") & " " & ("It cannot be converted."))
Return True
Endif
Inc Application.Busy
InsertDirectory(SourceDir)
For Each sFile In Dir(sDir, "*")
@ -3627,6 +3631,25 @@ Public Sub GetUniqueName(sDir As String, sName As String, Optional sSuffix As St
End
Public Sub GetUniqueSourceName(sName As String) As String
Dim iInd As Integer
Dim sNewName As String
Dim sExt As String
Dim sPath As String
sNewName = sName
While $cSourceDir.Exist(sNewName)
Inc iInd
sExt = File.Ext(sName)
sNewName = File.BaseName(sName) & CStr(iInd) & "." & File.Ext(sName)
Wend
Return sNewName
End
Public Sub CopyFile(sSrc As String, sDst As String)

View File

@ -0,0 +1,6 @@
[Component]
Key=gb.eval.highlight
Version=0.0.1
State=1
Requires=gb.eval

View File

@ -0,0 +1,2 @@
[Desktop Entry]
Icon=./.icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,15 @@
#Highlight
C
Html
M
Css
M
WebPage
M

View File

@ -0,0 +1 @@
Highlight

View File

@ -0,0 +1,9 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r2067)
Title=gb.eval.highlight
Startup=Main
Version=0.0.3
Component=gb.eval
TabSize=2
MakeComponent=1
State=1

View File

@ -0,0 +1,18 @@
[Breakpoints]
Count=0
[FFind]
SearchIn="Module"
CaseSensitive=False
SearchWord=False
SearchComment=False
SearchString=True
[OpenFile]
File[1]="Highlight.class:4.0"
Fold[1]=[]
Active=2
File[2]="MMain.module:6.0"
Fold[2]=[]
Count=2

View File

@ -0,0 +1,21 @@
' Gambas class file
Export
Static Public Sub Html()
HighlightHTML.Run(Main.STYLE_HTML)
End
Static Public Sub Css()
HighlightHTML.Run(Main.STYLE_Css)
End
Static Public Sub WebPage()
HighlightHTML.Run(Main.STYLE_Web)
End

View File

@ -0,0 +1,275 @@
' Gambas module file
' Gambas module file
Public Const STYLE_HTML As Integer = 1
Public Const STYLE_WEB As Integer = 2
Public Const STYLE_CSS As Integer = 3
Private Const TAG_HTML As Integer = 0
Private Const TAG_CODE As Integer = 1
Private Sub AnalyzeCode(sText As String) As String
Dim iInd As Integer
Dim iPos As Integer
Dim iLen As Integer
If Not sText Then Return
Highlight.Analyze(sText, True)
iPos = 0
For iInd = 0 To Highlight.Symbols.Max
If iPos < Highlight.Positions[iInd] Then
Highlight.Add(Highlight.Normal, Highlight.Positions[iInd] - iPos)
iPos = Highlight.Positions[iInd]
Endif
iLen = String.Len(Highlight.Symbols[iInd])
Highlight.Add(Highlight.Types[iInd], iLen)
iPos += iLen
Next
If iPos < String.Len(Highlight.TextAfter) Then
Highlight.Add(Highlight.Normal, String.Len(Highlight.TextAfter) - iPos)
Endif
Return Highlight.TextAfter
End
Public Sub Run(iStyle As Integer)
Dim iState As Integer
Dim iNextState As Integer
Dim iInd As Integer
Dim J As Integer
Dim sText As String
Dim sTextAfter As String
Dim sCar As String
Dim iPos As Integer
Dim bMarkup As Boolean
Dim bQuote As Boolean
Dim bLimit As Boolean
Dim bCode As Boolean
Dim iTag As Integer
Dim iCount As Integer
Dim iCodeStart As Integer
iState = Highlight.State
iTag = Highlight.Tag
sText = Highlight.Text
'PRINT "Highlight:";; iState;; iTag;; sText
Select Case iStyle
Case STYLE_HTML, STYLE_WEB
If iTag = TAG_HTML Then
bMarkup = iState = Highlight.Keyword
Else If iTag = TAG_CODE
bCode = True
iCodeStart = 1
Endif
For iInd = 1 To String.Len(sText)
iNextState = iState
sCar = String.Mid$(sText, iInd, 1)
If bCode Then
If bQuote Then
If sCar = Chr$(34) Then
bQuote = False
Endif
Else If sCar = Chr$(34) Then
bQuote = True
Else If sCar = "'" Then
Break
Else If String.Mid$(sText, iInd, 2) = "%>" Then
bCode = False
sTextAfter &= AnalyzeCode(String.Mid$(sText, iCodeStart, iInd - iCodeStart))
Highlight.Add(Highlight.Keyword, 2)
sTextAfter &= "%>"
Inc iInd
Highlight.AlternateState = False
iState = Highlight.Normal
iNextState = Highlight.Normal
Endif
Continue
Else If bMarkup Then
If bQuote Then
If sCar = Chr$(34) Then
bQuote = False
iNextState = Highlight.Operator
Endif
Else If sCar = ">" Then
bMarkup = False
iState = Highlight.Keyword
iNextState = Highlight.Normal
Else If sCar = " " Then
iNextState = Highlight.Operator
Else If sCar = "=" Then
iNextState = Highlight.String
Else If sCar = Chr$(34) Then
bQuote = True
Endif
Else
Select Case iState
Case Highlight.Normal
If sCar = "<" Then
If String.Mid$(sText, iInd, 4) = "<!--" Then
iState = Highlight.Comment
iNextState = Highlight.Comment
Else If String.Mid$(sText, iInd, 9) = "<![CDATA[" Then
iState = Highlight.Symbol
iNextState = Highlight.Symbol
Else If iStyle = STYLE_WEB And If String.Mid$(sText, iInd, 2) = "<%" Then
If String.Mid$(sText, iInd + 2, 1) = "=" Then
iCount = 3
Else
iCount = 2
Endif
Highlight.AlternateState = True
Highlight.Add(Highlight.Keyword, iCount)
sTextAfter &= String.Mid$(sText, iInd, iCount)
iInd += iCount - 1
iState = Highlight.Normal
iNextState = Highlight.Normal
bCode = True
iCodeStart = iInd + 1
Continue
Else
iState = Highlight.Keyword
iNextState = Highlight.Keyword
bMarkup = True
If String.Mid$(sText, iInd, 5) = "<body" Or If String.Mid$(sText, iInd, 5) = "<head" Then bLimit = True
Endif
Else If sCar = "&" Then
iPos = String.InStr(sText, ";", iInd)
If iPos = 0 Or iPos = iInd + 1 Then
iState = Highlight.Error
Else
For J = iInd + 1 To iPos - 1
sCar = String.Mid$(sText, J, 1)
If IsLetter(sCar) Then Continue
If IsDigit(sCar) Then Continue
If InStr("_#", sCar) Then Continue
Break
Next
If J = iPos Then
Highlight.Add(Highlight.Number, iPos - iInd + 1)
sTextAfter &= String.Mid$(sText, iInd, iPos - iInd + 1)
iInd = iPos
Continue
Else
iState = Highlight.Error
Endif
Endif
Endif
Case Highlight.Comment
If sCar = ">" And If iInd > 2 And If String.Mid$(sText, iInd - 2, 2) = "--" Then
iNextState = Highlight.Normal
Endif
Case Highlight.Symbol
If sCar = ">" And If iInd > 2 And If String.Mid$(sText, iInd - 2, 2) = "]]" Then
iNextState = Highlight.Normal
Endif
End Select
Endif
sTextAfter &= sCar
Highlight.Add(iState)
iState = iNextState
Next
If bCode Then
sTextAfter &= AnalyzeCode(String.Mid$(sText, iCodeStart))
iTag = TAG_CODE
Else
iTag = TAG_HTML
If iNextState <> Highlight.Comment And If iNextState <> Highlight.Symbol Then
If bMarkup Then
iNextState = Highlight.Keyword
Else
iNextState = Highlight.Normal
Endif
Endif
Endif
Highlight.Text = sTextAfter
Case STYLE_CSS
For iInd = 1 To String.Len(sText)
iNextState = iState
sCar = String.Mid$(sText, iInd, 1)
Select Case iState
Case Highlight.Normal, Highlight.String
If sCar = "." Or If sCar = "#" Then
iState = Highlight.String
iNextState = iState
Else If sCar = " " Then
iState = Highlight.Normal
iNextState = iState
Else If sCar = "{" Then
iState = Highlight.Keyword
iNextState = iState
iTag = Highlight.Keyword
bLimit = True
Else If sCar = "/" Then
If Mid$(sText, iInd, 2) = "/*" Then
iState = Highlight.Comment
iNextState = iState
Endif
Endif
Case Highlight.Keyword, Highlight.Number
If sCar = ":" Then
iNextState = Highlight.Number
Else If sCar = ";" Then
iState = Highlight.Keyword
iNextState = iState
Else If sCar = "}" Then
iNextState = Highlight.Normal
iTag = 0
Else If sCar = "/" Then
If Mid$(sText, iInd, 2) = "/*" Then
iState = Highlight.Comment
iNextState = iState
Endif
Endif
Case Highlight.Comment
If sCar = "/" And If iInd > 1 And If String.Mid$(sText, iInd - 1, 1) = "*" Then
iNextState = IIf(iTag, iTag, Highlight.Normal)
Endif
End Select
Highlight.Add(iState)
iState = iNextState
Next
End Select
Highlight.State = iNextState
Highlight.Tag = iTag
Highlight.ShowLimit = bLimit
End

View File

@ -0,0 +1,13 @@
' Gambas module file
Public Const STYLE_HTML As Integer = 1
Public Const STYLE_WEB As Integer = 2
Public Const STYLE_CSS As Integer = 3
Private Const TAG_HTML As Integer = 0
Private Const TAG_CODE As Integer = 1
Public Sub Main()
End

View File

@ -0,0 +1,8 @@
Main
gb.eval.highlight
0
0
0.0.2
gb.eval

View File

@ -10,7 +10,7 @@
Arrangement = Arrange.Horizontal
AutoResize = True
{ btnExpand PictureBox
MoveScaled(1,0,3,4)
MoveScaled(1,0,2,4)
Picture = Picture["img/8/side-bottom-void.png"]
Alignment = Align.Left
}

View File

@ -1 +1 @@
gb.settings gb.info gb.form gb.form.dialog gb.form.mdi gb.db.form gb.web gb.report gb.chart gb.mysql
gb.eval.highlight gb.settings gb.info gb.form gb.form.dialog gb.form.mdi gb.db.form gb.web gb.report gb.chart gb.mysql

View File

@ -1,5 +1,5 @@
[Component]
Key=gb.cairo
Author=Benoît Minisini
State=2
State=1
Requires=gb.image

View File

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r2053)
# Compiled with Gambas 2.99.0 (r2067)
Startup=FMain
Version=0.0.202
Version=0.0.203
Component=gb.gtk
TabSize=2
KeepDebugInfo=1

View File

@ -0,0 +1 @@
../../../../gb.qt/src/gb.qt/.src/Action.class

View File

@ -1 +0,0 @@
../../../gb.qt/src/gb.qt/Action.class

View File

@ -305,7 +305,7 @@ void MyContents::checkWidget(QWidget *wid)
#ifdef DEBUG
CWIDGET *ob = CWidget::get(wid);
qDebug("MyContents::checkWidget: %p: %s %p", wid, GB.GetClassName(ob), ob);
qDebug("MyContents::checkWidget: %p: %s %p: %s", wid, GB.GetClassName(ob), ob, ob->name);
qDebug("MyContents::checkWidget: %d %d", wid->x(), wid->y());
#endif
@ -346,10 +346,14 @@ void MyContents::childEvent(QChildEvent *e)
if (e->added())
{
checkWidget((QWidget *)e->child());
//qDebug("childEvent: added: %p: %s %p: %d", e->child(), GB.GetClassName(CWidget::get(e->child())), CWidget::get(e->child()), CWIDGET_test_flag(CWidget::get(e->child()), WF_DELETED));
//checkWidget((QWidget *)e->child());
_mustfind = true;
checkAutoResizeLater();
}
else if (e->removed())
{
//qDebug("childEvent: removed: %p: %s %p: %d", e->child(), GB.GetClassName(CWidget::get(e->child())), CWidget::get(e->child()), CWIDGET_test_flag(CWidget::get(e->child()), WF_DELETED));
if (e->child() == right || e->child() == bottom)
{
if (e->child() == right)
@ -381,7 +385,8 @@ void MyContents::checkAutoResizeLater()
void CSCROLLVIEW_arrange(void *_object, CWIDGET *child)
{
if (THIS->container)
THIS->container->checkWidget(child->widget);
THIS->container->checkAutoResizeLater();
//THIS->container->checkWidget(child->widget);
}
/***************************************************************************

View File

@ -207,14 +207,24 @@ void *CWIDGET_get_parent(void *_object)
return CWidget::get(parent);
}
int CCONTROL_check(void *object)
{
return QWIDGET(object) == NULL || CWIDGET_test_flag(object, WF_DELETED);
}
static void arrange_parent(CWIDGET *_object)
{
void *parent = CWIDGET_get_parent(THIS);
if (!parent)
return;
if (CCONTROL_check(parent))
return;
CCONTAINER_arrange(parent);
if (GB.Is(parent, CLASS_ScrollView))
{
//qDebug("CSCROLLVIEW_arrange: %p: %p %d", THIS, THIS->widget, CWIDGET_test_flag(THIS, WF_DELETED));
CSCROLLVIEW_arrange(parent, THIS);
}
}
static QWidget *get_viewport(QWidget *w)
@ -251,7 +261,8 @@ void CWIDGET_new(QWidget *w, void *_object, bool no_show, bool no_filter, bool n
CWidget::add(w, _object, no_filter);
//qDebug("CWIDGET_new: %p: %p", object, w);
//QWidget *p = w->parentWidget();
//qDebug("CWIDGET_new: %s %p: %p in (%s %p)", GB.GetClassName(THIS), THIS, w, p ? GB.GetClassName(CWidget::get(p)) : "", CWidget::get(p));
THIS->widget = w;
THIS->level = MAIN_loop_level;
@ -282,12 +293,6 @@ void CWIDGET_new(QWidget *w, void *_object, bool no_show, bool no_filter, bool n
}
int CCONTROL_check(void *object)
{
return QWIDGET(object) == NULL || CWIDGET_test_flag(object, WF_DELETED);
}
QString CWIDGET_Utf8ToQString(GB_STRING *str)
{
return QString::fromUtf8((const char *)(str->value.addr + str->value.start), str->value.len);

View File

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.0 (r2053)
# Compiled with Gambas 2.99.0 (r2067)
Startup=FMain
Version=0.0.271
Version=0.0.272
Component=gb.qt
TabSize=2
KeepDebugInfo=1

View File

@ -0,0 +1 @@
../../../../gb.qt/src/gb.qt/.src/Action.class

View File

@ -0,0 +1 @@
../../../../gb.qt/src/gb.qt/.src/_Qt.module

View File

@ -1 +0,0 @@
../../../gb.qt/src/gb.qt/Action.class

View File

@ -1 +0,0 @@
../../../gb.qt/src/gb.qt/_Qt.module