diff --git a/app/src/gambas3/.lang/.pot b/app/src/gambas3/.lang/.pot index fb99cde74..53bcf254f 100644 --- a/app/src/gambas3/.lang/.pot +++ b/app/src/gambas3/.lang/.pot @@ -290,7 +290,7 @@ msgstr "" msgid "Loading information on component &1..." msgstr "" -#: CModule.class:28 FCreateFile.class:625 FEditor.class:3364 FForm.class:3539 +#: CModule.class:28 FCreateFile.class:625 FEditor.class:3365 FForm.class:3539 #: FInfo.class:88 msgid "Form" msgstr "" @@ -327,7 +327,7 @@ msgstr "" msgid "Gambas reports" msgstr "" -#: Design.module:215 Project.module:1655 +#: Design.module:215 Project.module:1659 msgid "In class &1 at line &2." msgstr "" @@ -434,7 +434,7 @@ msgstr "" #: FColorChooser.class:203 FCommit.class:397 FConflict.class:191 #: FConnectionEditor.class:261 FCreateFile.class:885 FDebugInfo.class:490 -#: FEditor.class:2111 FFindList.class:195 FFind.class:114 +#: FEditor.class:2112 FFindList.class:195 FFind.class:114 #: FFontChooser.class:86 FForm.class:2830 FGotoLine.class:63 #: FHelpBrowser.class:186 FIconEditor.class:1393 FImportTable.class:38 #: FList.class:155 FMain.class:204 FMakeExecutable.class:144 @@ -443,7 +443,7 @@ msgstr "" #: FOption.class:576 FPasteSpecial.class:279 FPropertyProject.class:1236 #: FSave.class:118 FSelectExtraFile.class:78 FSelectIcon.class:271 #: FTableChooser.class:145 FTextEditor.class:462 FText.class:107 -#: FTranslate.class:606 Project.module:346 +#: FTranslate.class:606 Project.module:350 msgid "Cancel" msgstr "" @@ -477,40 +477,40 @@ msgid "" msgstr "" #: FCommit.class:234 FConflict.class:327 FConnectionEditor.class:1790 -#: FEditor.class:3188 FForm.class:3380 FIconEditor.class:2168 +#: FEditor.class:3189 FForm.class:3380 FIconEditor.class:2168 #: FOutput.class:473 FTextEditor.class:660 msgid "Cut" msgstr "" #: FCommit.class:241 FConflict.class:334 FConnectionEditor.class:1688 -#: FEditor.class:3194 FForm.class:3387 FIconEditor.class:2177 +#: FEditor.class:3195 FForm.class:3387 FIconEditor.class:2177 #: FOutput.class:480 FTextEditor.class:667 msgid "Copy" msgstr "" #: FCommit.class:248 FConflict.class:341 FConnectionEditor.class:1814 -#: FEditor.class:3201 FForm.class:3394 FIconEditor.class:2186 +#: FEditor.class:3202 FForm.class:3394 FIconEditor.class:2186 #: FOutput.class:487 FTextEditor.class:674 msgid "Paste" msgstr "" #: FCommit.class:255 FConflict.class:348 FConnectionEditor.class:1822 -#: FEditor.class:3171 FForm.class:3622 FIconEditor.class:2150 +#: FEditor.class:3172 FForm.class:3622 FIconEditor.class:2150 #: FOption.class:1189 FOutput.class:455 FTextEditor.class:642 msgid "Undo" msgstr "" #: FCommit.class:262 FConflict.class:355 FConnectionEditor.class:1830 -#: FEditor.class:3178 FForm.class:3633 FOutput.class:462 FTextEditor.class:649 +#: FEditor.class:3179 FForm.class:3633 FOutput.class:462 FTextEditor.class:649 msgid "Redo" msgstr "" -#: FCommit.class:269 FConflict.class:362 FEditor.class:3422 +#: FCommit.class:269 FConflict.class:362 FEditor.class:3423 #: FTextEditor.class:841 msgid "Indent" msgstr "" -#: FCommit.class:276 FConflict.class:369 FEditor.class:3431 +#: FCommit.class:276 FConflict.class:369 FEditor.class:3432 #: FTextEditor.class:849 msgid "Unindent" msgstr "" @@ -583,7 +583,7 @@ msgid "" "Do you really want to open another file?" msgstr "" -#: FConflict.class:254 FOpenProject.class:351 Project.module:346 +#: FConflict.class:254 FOpenProject.class:351 Project.module:350 msgid "Open" msgstr "" @@ -659,7 +659,7 @@ msgstr "" msgid "The table '&1' has been modified. Do you want to save it?" msgstr "" -#: FConnectionEditor.class:261 FEditor.class:3312 FForm.class:3525 +#: FConnectionEditor.class:261 FEditor.class:3313 FForm.class:3525 #: FIconEditor.class:1412 FTextEditor.class:755 msgid "Save" msgstr "" @@ -781,7 +781,7 @@ msgstr "" msgid "Connection editor" msgstr "" -#: FConnectionEditor.class:1547 FEditor.class:2111 FForm.class:2830 +#: FConnectionEditor.class:1547 FEditor.class:2112 FForm.class:2830 #: FHelpBrowser.class:193 FIconEditor.class:2032 FTextEditor.class:462 #: FTranslate.class:700 msgid "Reload" @@ -1211,118 +1211,118 @@ msgstr "" msgid "Stack backtrace" msgstr "" -#: FEditor.class:2111 FIconEditor.class:2032 FTextEditor.class:462 +#: FEditor.class:2112 FIconEditor.class:2032 FTextEditor.class:462 msgid "" "The file has been modified.\n" "\n" "All your changes will be lost." msgstr "" -#: FEditor.class:2508 +#: FEditor.class:2509 msgid "(Declarations)" msgstr "" -#: FEditor.class:3105 +#: FEditor.class:3106 msgid "Go to" msgstr "" -#: FEditor.class:3110 FTextEditor.class:632 +#: FEditor.class:3111 FTextEditor.class:632 msgid "Go to line..." msgstr "" -#: FEditor.class:3116 +#: FEditor.class:3117 msgid "Find definition" msgstr "" -#: FEditor.class:3123 FHelpBrowser.class:172 +#: FEditor.class:3124 FHelpBrowser.class:172 msgid "Go back" msgstr "" -#: FEditor.class:3130 +#: FEditor.class:3131 msgid "Open form" msgstr "" -#: FEditor.class:3137 FForm.class:3308 FMain.class:2328 +#: FEditor.class:3138 FForm.class:3308 FMain.class:2328 msgid "&Startup class" msgstr "" -#: FEditor.class:3146 +#: FEditor.class:3147 msgid "Run &until current line" msgstr "" -#: FEditor.class:3153 +#: FEditor.class:3154 msgid "Toggle &breakpoint" msgstr "" -#: FEditor.class:3160 +#: FEditor.class:3161 msgid "&Watch expression..." msgstr "" -#: FEditor.class:3208 +#: FEditor.class:3209 msgid "Paste special..." msgstr "" -#: FEditor.class:3218 FTextEditor.class:685 +#: FEditor.class:3219 FTextEditor.class:685 msgid "Select &All" msgstr "" -#: FEditor.class:3228 +#: FEditor.class:3229 msgid "Comment" msgstr "" -#: FEditor.class:3235 +#: FEditor.class:3236 msgid "Uncomment" msgstr "" -#: FEditor.class:3246 FTextEditor.class:695 +#: FEditor.class:3247 FTextEditor.class:695 msgid "Find..." msgstr "" -#: FEditor.class:3252 FTextEditor.class:701 +#: FEditor.class:3253 FTextEditor.class:701 msgid "Replace..." msgstr "" -#: FEditor.class:3259 FTextEditor.class:708 +#: FEditor.class:3260 FTextEditor.class:708 msgid "Find Next" msgstr "" -#: FEditor.class:3266 FTextEditor.class:715 +#: FEditor.class:3267 FTextEditor.class:715 msgid "Find Previous" msgstr "" -#: FEditor.class:3276 FTextEditor.class:725 +#: FEditor.class:3277 FTextEditor.class:725 msgid "View" msgstr "" -#: FEditor.class:3280 FTextEditor.class:729 +#: FEditor.class:3281 FTextEditor.class:729 msgid "No split" msgstr "" -#: FEditor.class:3287 FTextEditor.class:736 +#: FEditor.class:3288 FTextEditor.class:736 msgid "Horizontal split" msgstr "" -#: FEditor.class:3294 FTextEditor.class:743 +#: FEditor.class:3295 FTextEditor.class:743 msgid "Vertical split" msgstr "" -#: FEditor.class:3323 FPasteSpecial.class:253 +#: FEditor.class:3324 FPasteSpecial.class:253 msgid "Paste as string" msgstr "" -#: FEditor.class:3328 FPasteSpecial.class:258 +#: FEditor.class:3329 FPasteSpecial.class:258 msgid "Paste as multi-line string" msgstr "" -#: FEditor.class:3333 FPasteSpecial.class:243 +#: FEditor.class:3334 FPasteSpecial.class:243 msgid "Paste as comments" msgstr "" -#: FEditor.class:3340 FOption.class:997 +#: FEditor.class:3341 FOption.class:997 msgid "Editor" msgstr "" -#: FEditor.class:3489 +#: FEditor.class:3490 msgid "Procedure list" msgstr "" @@ -2335,7 +2335,7 @@ msgstr "" msgid "Save project" msgstr "" -#: FMain.class:2439 Project.module:1954 +#: FMain.class:2439 Project.module:1958 msgid "Save project as" msgstr "" @@ -2371,7 +2371,7 @@ msgstr "" msgid "Make installation package" msgstr "" -#: FMain.class:2525 FSelectIcon.class:214 Project.module:1259 +#: FMain.class:2525 FSelectIcon.class:214 Project.module:1263 msgid "Project" msgstr "" @@ -2500,7 +2500,7 @@ msgid "There is no CHANGELOG entry for this release." msgstr "" #: FMakeInstall.class:309 FPropertyProject.class:1236 FSave.class:111 -#: Project.module:2579 +#: Project.module:2583 msgid "Continue" msgstr "" @@ -3065,7 +3065,7 @@ msgstr "" msgid "Image editor" msgstr "" -#: FOption.class:923 +#: FOption.class:923 MTheme.module:6 msgid "Help" msgstr "" @@ -4858,268 +4858,268 @@ msgstr "" msgid "Controls" msgstr "" -#: Project.module:329 +#: Project.module:333 msgid "This project does not exist." msgstr "" -#: Project.module:344 +#: Project.module:348 msgid "This is not a Gambas project." msgstr "" -#: Project.module:346 +#: Project.module:350 msgid "" "This is a Gambas &1 project.\n" "\n" "Do you want to open it anyway?" msgstr "" -#: Project.module:357 +#: Project.module:361 msgid "" "This project seems to be already opened.\n" "\n" "Opening the same project twice can lead to data loss." msgstr "" -#: Project.module:357 +#: Project.module:361 msgid "Open after all" msgstr "" -#: Project.module:357 +#: Project.module:361 msgid "Do not open" msgstr "" -#: Project.module:378 +#: Project.module:382 msgid "This project is read-only." msgstr "" -#: Project.module:378 +#: Project.module:382 msgid "It cannot be converted." msgstr "" -#: Project.module:433 +#: Project.module:437 msgid "Cannot open project file :\n" msgstr "" -#: Project.module:1061 +#: Project.module:1065 msgid "The following classes have circular inheritance:" msgstr "" -#: Project.module:1223 +#: Project.module:1227 msgid "read-only" msgstr "" -#: Project.module:1225 +#: Project.module:1229 msgid "ALPHA VERSION, USE AT YOUR OWN RISK! :-)" msgstr "" -#: Project.module:1262 +#: Project.module:1266 msgid "Sources" msgstr "" -#: Project.module:1265 +#: Project.module:1269 msgid "Connections" msgstr "" -#: Project.module:1274 +#: Project.module:1278 msgid "Data" msgstr "" -#: Project.module:1377 +#: Project.module:1381 msgid "Loading &1..." msgstr "" -#: Project.module:1450 +#: Project.module:1454 msgid "Cannot open file." msgstr "" -#: Project.module:1509 +#: Project.module:1513 msgid "File not found!" msgstr "" -#: Project.module:1615 +#: Project.module:1619 msgid "Cannot compile the project." msgstr "" -#: Project.module:1639 +#: Project.module:1643 msgid "first" msgstr "" -#: Project.module:1641 +#: Project.module:1645 msgid "second" msgstr "" -#: Project.module:1643 +#: Project.module:1647 msgid "third" msgstr "" -#: Project.module:1645 +#: Project.module:1649 msgid "&1th" msgstr "" -#: Project.module:1651 +#: Project.module:1655 msgid "in form definition" msgstr "" -#: Project.module:1805 +#: Project.module:1809 msgid "" "Some project source files are in conflict.\n" "Please solve them if you want to compile the project." msgstr "" -#: Project.module:1809 +#: Project.module:1813 msgid "Compiling project" msgstr "" -#: Project.module:1821 +#: Project.module:1825 msgid "Nothing to do." msgstr "" -#: Project.module:1960 +#: Project.module:1964 msgid "This project already exists." msgstr "" -#: Project.module:1973 +#: Project.module:1977 msgid "Unable to save the project." msgstr "" -#: Project.module:2015 +#: Project.module:2019 msgid "File already exists." msgstr "" -#: Project.module:2060 +#: Project.module:2064 msgid "Cannot copy template file." msgstr "" -#: Project.module:2079 +#: Project.module:2083 msgid "Directory already exists." msgstr "" -#: Project.module:2230 +#: Project.module:2234 msgid "Making executable..." msgstr "" -#: Project.module:2274 +#: Project.module:2278 msgid "Cannot make executable." msgstr "" -#: Project.module:2578 +#: Project.module:2582 msgid "Some components are missing: &1" msgstr "" -#: Project.module:2779 +#: Project.module:2783 msgid "Cannot write project file." msgstr "" -#: Project.module:2812 +#: Project.module:2816 msgid "Unable to create desktop shortcut." msgstr "" -#: Project.module:2893 +#: Project.module:2897 msgid "Unable to install component." msgstr "" -#: Project.module:2931 +#: Project.module:2935 msgid "Unable to uninstall component." msgstr "" -#: Project.module:3074 +#: Project.module:3078 msgid "The directory will be removed at the next commit." msgstr "" -#: Project.module:3093 +#: Project.module:3097 msgid "You must define a startup class or form!" msgstr "" -#: Project.module:3125 +#: Project.module:3129 msgid "Please type a name." msgstr "" -#: Project.module:3129 +#: Project.module:3133 msgid "This name contains a forbidden character:" msgstr "" -#: Project.module:3133 +#: Project.module:3137 msgid "The name cannot begins with a dot." msgstr "" -#: Project.module:3137 +#: Project.module:3141 msgid "This name is already used. Choose another one." msgstr "" -#: Project.module:3168 +#: Project.module:3172 msgid "" "A class name must begin with a letter or an underscore, followed by any " "letter or digit." msgstr "" -#: Project.module:3216 +#: Project.module:3220 msgid "Destination already exists" msgstr "" -#: Project.module:3413 +#: Project.module:3417 msgid "Unable to rename '&1'" msgstr "" -#: Project.module:3528 +#: Project.module:3532 msgid "Please type a project name." msgstr "" -#: Project.module:3536 +#: Project.module:3540 msgid "The project name cannot begin with a dot." msgstr "" -#: Project.module:3539 +#: Project.module:3543 msgid "Non-ASCII characters are forbidden in a project name." msgstr "" -#: Project.module:3540 +#: Project.module:3544 msgid "" "The following characters are forbidden in a project name: ? * / \\ SPACE" msgstr "" -#: Project.module:3550 +#: Project.module:3554 msgid "The project directory already exists." msgstr "" -#: Project.module:3552 +#: Project.module:3556 msgid "" "The project directory cannot be created because a file with the same name " "already exists." msgstr "" -#: Project.module:3598 +#: Project.module:3602 msgid "Create source package" msgstr "" -#: Project.module:3599 +#: Project.module:3603 msgid "Source packages" msgstr "" -#: Project.module:3869 +#: Project.module:3873 msgid "Cannot copy file &1." msgstr "" -#: Project.module:3881 +#: Project.module:3885 msgid "Linking a directory is forbidden." msgstr "" -#: Project.module:3911 +#: Project.module:3915 msgid "Cannot create link &1." msgstr "" -#: Project.module:3928 +#: Project.module:3932 msgid "Cannot move a directory inside itself." msgstr "" -#: Project.module:3992 +#: Project.module:3996 msgid "Cannot move file &1." msgstr "" -#: Project.module:4539 +#: Project.module:4546 msgid "modified" msgstr "" -#: Project.module:4619 +#: Project.module:4626 msgid "Unable to update all forms." msgstr "" diff --git a/app/src/gambas3/.src/Component/CSymbolInfo.class b/app/src/gambas3/.src/Component/CSymbolInfo.class index e2c2a8790..2571a6b11 100644 --- a/app/src/gambas3/.src/Component/CSymbolInfo.class +++ b/app/src/gambas3/.src/Component/CSymbolInfo.class @@ -703,6 +703,109 @@ Public Function GetHelpURL() As String End +'' Transform one line of help into HTML by decoding some sort of light wiki syntax. +'' - #sLine# is the line of help text +'' The HTML is returned. + +Private Sub DecodeHelpLine(sLine As String) As String + + Dim iPos As Integer + Dim iLen As Integer = String.Len(sLine) + Dim sChar As String + Dim sHTML As String + Dim sWait As String + Dim bBold, bItalic, bMonospace, bUnderline As Boolean + Dim iSavePos As Integer + Dim sLink As String + Dim iPoint As Integer + Dim hClass As CClassInfo + Dim hSymbol As CSymbolInfo + + sLine = RTrim(sLine) + If Not sLine Then Return "

" + If sLine = "--" Then Return "


" + + If sLine Begins "-" Then + sHtml = "
  • " + sLine = Mid$(sLine, 2) + Endif + + Do + + Inc iPos + If iPos > iLen Then Break + sChar = String.Mid(sLine, iPos, 1) + + If sWait = ">" Then + sHTML &= sChar + If sChar = ">" Then sWait = "" + Continue + Else If sWait = "]" Then + If sChar <> "]" Then Continue + sWait = "" + sLink = String.Mid$(sLine, iSavePos, iPos - iSavePos) + sChar = sLink + If sLink Like "*://*" Then + Else + iPoint = RInStr(sLink, ".") + If iPoint = 0 Then + hClass = Null + Try hClass = CComponent.Classes[sLink] + If hClass Then + sLink = hClass.GetHelpURL() + Else + sLink = "" + Endif + Else + hSymbol = Null + Try hSymbol = CComponent.Classes[Trim(Left(sLink, iPoint - 1))].Symbols[Trim(Mid$(sLink, iPoint + 1))] + If hSymbol Then + sLink = hSymbol.GetHelpURL() + Else + sLink = "" + Endif + Endif + Endif + If sLink Then + sHTML &= "" & Html(sChar) & "" + Else + sHTML &= "" & Html(sChar) & "?" + Endif + Continue + Endif + + If sChar = "\\" Then + sHTML &= Html(String.Mid$(sLine, iPos + 1, 1)) + Inc iPos + Else If sChar = "<" Then + sHTML &= sChar + sWait = ">" + Else If sChar = "*" Then + bBold = Not bBold + sHTML &= If(bBold, "", "") + Else If sChar = "=" Then + bMonospace = Not bMonospace + sHTML &= If(bMonospace, "", "") + Else If sChar = "'" Then + bItalic = Not bItalic + sHTML &= If(bItalic, "", "") + Else If sChar = "#" Then + bUnderline = Not bUnderline + sHTML &= If(bUnderline, "", "") + Else If sChar = "[" Then + sWait = "]" + iSavePos = iPos + 1 + Else + sHTML &= Html(sChar) + Endif + + Loop + + Return sHTML + +End + + Public Function GetHelpHTML() As String Dim hForm As Object @@ -728,7 +831,7 @@ Public Function GetHelpHTML() As String If Highlight.Types[i] = Highlight.Comment Then sLine = Trim(Highlight.Symbols[i]) If sLine Begins "''" Then - sHelp = Trim(Mid$(sline, 3)) + sHelp = DecodeHelpLine(Trim(Mid$(sLine, 3))) Endif Endif Endif @@ -740,7 +843,7 @@ Public Function GetHelpHTML() As String For i = iLine - 1 To 0 Step -1 sLine = Trim(hEdit.Lines[i].Text) If sLine Begins "''" Then - sHelp = Trim(Mid(sLine, 3)) & "
    " & sHelp + sHelp = DecodeHelpLine(Trim(Mid(sLine, 3))) & "\n" & sHelp Else If Trim(sLine) = "" Then Continue Break diff --git a/app/src/gambas3/.src/Editor/Code/FEditor.class b/app/src/gambas3/.src/Editor/Code/FEditor.class index 5e8cc6608..ff1e8fac5 100644 --- a/app/src/gambas3/.src/Editor/Code/FEditor.class +++ b/app/src/gambas3/.src/Editor/Code/FEditor.class @@ -1352,12 +1352,12 @@ End ' ' END - '' Read the type of a symbol declared globally, or as a method argument, from an analyzed line of code. -''
  • aSym is an array of symbols (like Highlight.Symbols). -''
  • iIndex is the index of the first symbol to take into account into aSym. -''
  • sSymbol is the name of the local symbol. If specified, it must be the first symbol to read. -''

    This function returns the datatype of the symbol. +'' - #aSym# is an array of symbols (like [Highlight.Symbols]). +'' - #iIndex# is the index of the first symbol to take into account into #aSym#. +'' - #sSymbol# is the name of the local symbol. If specified, it must be the first symbol to read. +'' +'' This function returns the datatype of the symbol. Static Public Function ReadSymbolType(aSym As String[], iIndex As Integer, Optional sSymbol As String) As String @@ -1388,11 +1388,12 @@ Catch End '' Get information about a local symbol declared with DIM from an analyzed line of code. -''

  • aSym is an array of symbols (like Highlight.Symbols). -''
  • iIndex is the index of the first symbol to take into account into aSym. -''
  • sSymbol is the name of the local symbol to search for. -''
  • hSymbol is a CSymbolInfo object that will be filled with the type information. -''

    This function returns TRUE if the symbol has been found, FALSE otherwise. +'' - #aSym# is an array of symbols (like [Highlight.Symbols]). +'' - #iIndex# is the index of the first symbol to take into account into #aSym#. +'' - #sSymbol# is the name of the local symbol to search for. +'' - #hSymbol# is a CSymbolInfo object that will be filled with the type information. +'' +'' This function returns =TRUE= if the symbol has been found, =FALSE= otherwise. Static Function ReadLocalSymbolType(aSym As String[], iIndex As Integer, sSymbol As String, hSymbol As CSymbolInfo) As Boolean diff --git a/app/src/gambas3/.src/MMime.module b/app/src/gambas3/.src/MMime.module index d386647f1..3c46fb293 100644 --- a/app/src/gambas3/.src/MMime.module +++ b/app/src/gambas3/.src/MMime.module @@ -31,4 +31,3 @@ Public Sub GetName(sFormat As String) As String Endif End - diff --git a/app/src/gambas3/.src/MTheme.module b/app/src/gambas3/.src/MTheme.module index a93a20609..13483b879 100644 --- a/app/src/gambas3/.src/MTheme.module +++ b/app/src/gambas3/.src/MTheme.module @@ -2,8 +2,8 @@ Public Const DEFAULT_THEME As String = "sapphire" -Public ColorKeys As String[] = ["Background", "Alternate", "Normal", "Keyword", "Datatype", "Function", "Operator", "Symbol", "Number", "String", "Comment", "Breakpoint", "Current", "Selection", "Highlight", "CurrentLine", "Error"] -Public ColorNames As String[] = [("Background"), ("Alternate background"), ("Normal text"), ("Keywords"), ("Data types"), ("Subroutines"), ("Operators"), ("Symbols"), ("Numbers"), ("Strings"), ("Comments"), ("Breakpoints"), ("Current line"), ("Selection"), ("Highlighting"), ("Editing line"), ("Errors")] +Public ColorKeys As String[] = ["Background", "Alternate", "Normal", "Keyword", "Datatype", "Function", "Operator", "Symbol", "Number", "String", "Comment", "Help", "Breakpoint", "Current", "Selection", "Highlight", "CurrentLine", "Error"] +Public ColorNames As String[] = [("Background"), ("Alternate background"), ("Normal text"), ("Keywords"), ("Data types"), ("Subroutines"), ("Operators"), ("Symbols"), ("Numbers"), ("Strings"), ("Comments"), ("Help"), ("Breakpoints"), ("Current line"), ("Selection"), ("Highlighting"), ("Editing line"), ("Errors")] Private $cDefault As Collection diff --git a/app/src/gambas3/.src/Project.module b/app/src/gambas3/.src/Project.module index 2e3c19a02..8eeb9e19f 100644 --- a/app/src/gambas3/.src/Project.module +++ b/app/src/gambas3/.src/Project.module @@ -178,6 +178,7 @@ Public Sub Main() Dim sPath As String Dim iTest As Integer + Dim iInd As Integer Application.Theme = Settings["/Theme"] 'DB.Debug = True @@ -200,9 +201,12 @@ Public Sub Main() FMain.Load - If Application.Args.Count >= 2 Then - sPath = Application.Args[1] - Endif + For iInd = 1 To Application.Args.Count - 1 + If Left(Application.Args[iInd]) <> "-" Then + sPath = Application.Args[iInd] + Break + Endif + Next 'FMain.Close 'Return @@ -4203,6 +4207,9 @@ Public Function CheckProgram(sProg As String) As Boolean End +'' Open a URL inside an external browser. +''

  • sLink is the URL to open. + Public Sub OpenWebPage(sLink As String) Dim sExec As String diff --git a/app/src/gambas3/theme/amber b/app/src/gambas3/theme/amber index df7033a30..7b86e46f6 100644 --- a/app/src/gambas3/theme/amber +++ b/app/src/gambas3/theme/amber @@ -16,4 +16,5 @@ Highlight="#CF9FFF" CurrentLine="#FFEFCF" Error="#028078,Underline" Alternate="#BFFFFF" +Help="#808080,Bold,Italic" diff --git a/app/src/gambas3/theme/amethyst b/app/src/gambas3/theme/amethyst index caf836b05..10cbecde4 100644 --- a/app/src/gambas3/theme/amethyst +++ b/app/src/gambas3/theme/amethyst @@ -16,4 +16,5 @@ Highlight="#9FFF9F" CurrentLine="#F9E7FF" Error="#008000,Underline" Alternate="#BFDFFF" +Help="#BF7FFF,Bold,Italic" diff --git a/app/src/gambas3/theme/emerald b/app/src/gambas3/theme/emerald index 380607661..04a37d01a 100644 --- a/app/src/gambas3/theme/emerald +++ b/app/src/gambas3/theme/emerald @@ -16,4 +16,5 @@ Current="#BFFFBF" CurrentLine="#E7FFE7" Error="#800080,Underline" Alternate="#FFFF9F" +Help="#805500,Bold,Italic" diff --git a/app/src/gambas3/theme/obsidian b/app/src/gambas3/theme/obsidian index d3adf912d..427629b59 100644 --- a/app/src/gambas3/theme/obsidian +++ b/app/src/gambas3/theme/obsidian @@ -16,4 +16,5 @@ Highlight="#305880" CurrentLine="#202020" Error="#C00000,Underline" Alternate="#00C060" +Help="#BF7FFF,Bold,Italic" diff --git a/app/src/gambas3/theme/quest b/app/src/gambas3/theme/quest index a376454bf..7f40bac62 100644 --- a/app/src/gambas3/theme/quest +++ b/app/src/gambas3/theme/quest @@ -16,4 +16,5 @@ Highlight="#FFFF00" CurrentLine="#E7F3FF" Error="#FF0000,Underline" Alternate="#BFFFBF" +Help="#808080,Bold,Italic" diff --git a/app/src/gambas3/theme/quick b/app/src/gambas3/theme/quick index b05609854..602b5946d 100644 --- a/app/src/gambas3/theme/quick +++ b/app/src/gambas3/theme/quick @@ -15,4 +15,5 @@ Breakpoint="#FF5F5F" Current="#5F5FBF" CurrentLine="#00376F" Error="#808000" +Help="#5FBF5F,Bold" diff --git a/app/src/gambas3/theme/ruby b/app/src/gambas3/theme/ruby index c2bbf1f56..257ddd4a7 100644 --- a/app/src/gambas3/theme/ruby +++ b/app/src/gambas3/theme/ruby @@ -16,4 +16,5 @@ Current="#FFBFBF" CurrentLine="#FFE7E7" Error="#008000,Underline" Alternate="#FFFF9F" +Help="#FF8000,Bold,Italic" diff --git a/app/src/gambas3/theme/sapphire b/app/src/gambas3/theme/sapphire index 8ea6a6086..bccdefcec 100644 --- a/app/src/gambas3/theme/sapphire +++ b/app/src/gambas3/theme/sapphire @@ -16,3 +16,4 @@ Selection="#C0C0FF" Highlight="#FFFF00" CurrentLine="#E7F3FF" Error="#808000,Underline" +Help="#808080,#F0F0F0,Bold,Italic" diff --git a/app/src/gambas3/theme/visual b/app/src/gambas3/theme/visual index fa7c0aef8..ea3b6bce7 100644 --- a/app/src/gambas3/theme/visual +++ b/app/src/gambas3/theme/visual @@ -16,4 +16,5 @@ Current="#BFBFFF" CurrentLine="#E7F3FF" Error="#004040,Underline" Alternate="#FFFF9F" +Help="#008800,Bold,Italic" diff --git a/gb.qt/src/ext/gdocument.cpp b/gb.qt/src/ext/gdocument.cpp index 92feebade..df9a845aa 100644 --- a/gb.qt/src/ext/gdocument.cpp +++ b/gb.qt/src/ext/gdocument.cpp @@ -981,6 +981,7 @@ int GDocument::convState(int state) case EVAL_TYPE_DATATYPE: return GLine::Datatype; case EVAL_TYPE_ERROR: return GLine::Error; case EVAL_TYPE_ALTERNATE: return GLine::Alternate; + case EVAL_TYPE_HELP: return GLine::Help; default: return GLine::Normal; } } diff --git a/gb.qt/src/ext/gdocument.h b/gb.qt/src/ext/gdocument.h index 885fd2f4a..02abfe208 100644 --- a/gb.qt/src/ext/gdocument.h +++ b/gb.qt/src/ext/gdocument.h @@ -28,9 +28,9 @@ struct GHighlight { - unsigned state : 4; + unsigned state : 5; unsigned alternate : 1; - unsigned len : 11; + unsigned len : 10; }; typedef @@ -46,7 +46,7 @@ public: Operator, Symbol, Number, String, Comment, Breakpoint, Current, Datatype, Selection, Highlight, Line, Error, - Alternate, + Alternate, Help, NUM_STATE }; diff --git a/gb.qt4/src/CTextArea.cpp b/gb.qt4/src/CTextArea.cpp index 33e63b2e0..8838d49fe 100644 --- a/gb.qt4/src/CTextArea.cpp +++ b/gb.qt4/src/CTextArea.cpp @@ -235,44 +235,66 @@ BEGIN_PROPERTY(CTEXTAREA_max_length) END_PROPERTY */ -/* -BEGIN_PROPERTY(CTEXTAREA_line) - - int line, col; - - WIDGET->getCursorPosition(&line, &col); - - if (READ_PROPERTY) - GB.ReturnInteger(line); - else - { - line = VPROP(GB_INTEGER); - look_pos(WIDGET, &line, &col); - - WIDGET->setCursorPosition(line, col); - } - -END_PROPERTY - +static int get_column(CTEXTAREA *_object) +{ + QTextCursor cursor = WIDGET->textCursor(); + return cursor.position() - cursor.block().position(); +} BEGIN_PROPERTY(CTEXTAREA_column) - int line, col; - - WIDGET->getCursorPosition(&line, &col); - + QTextCursor cursor = WIDGET->textCursor(); + if (READ_PROPERTY) - GB.ReturnInteger(col); + //GB.ReturnInteger(WIDGET->textCursor().columnNumber()); + GB.ReturnInteger(get_column(THIS)); else { - col = VPROP(GB_INTEGER); - look_pos(WIDGET, &line, &col); - - WIDGET->setCursorPosition(line, col); + int col = VPROP(GB_INTEGER); + + if (col <= 0) + cursor.movePosition(QTextCursor::QTextCursor::StartOfBlock); + else if (col >= cursor.block().length()) + cursor.movePosition(QTextCursor::QTextCursor::EndOfBlock); + else + cursor.setPosition(cursor.block().position() + col); + + WIDGET->setTextCursor(cursor); + } + +END_PROPERTY + +BEGIN_PROPERTY(CTEXTAREA_line) + + QTextCursor cursor = WIDGET->textCursor(); + + if (READ_PROPERTY) + GB.ReturnInteger(cursor.blockNumber()); + else + { + int col = get_column(THIS); + int line = VPROP(GB_INTEGER); + + if (line < 0) + cursor.movePosition(QTextCursor::Start); + else if (line >= WIDGET->document()->blockCount()) + cursor.movePosition(QTextCursor::End); + else + { + cursor.setPosition(WIDGET->document()->findBlockByNumber(line).position()); + if (col > 0) + { + if (col >= cursor.block().length()) + cursor.movePosition(QTextCursor::QTextCursor::EndOfBlock); + else + cursor.setPosition(cursor.block().position() + col); + } + } + + WIDGET->setTextCursor(cursor); } END_PROPERTY -*/ BEGIN_PROPERTY(CTEXTAREA_pos) @@ -567,8 +589,8 @@ GB_DESC CTextAreaDesc[] = GB_PROPERTY("Wrap", "b", CTEXTAREA_wrap), GB_PROPERTY("Border", "b", CWIDGET_border_simple), - //GB_PROPERTY("Line", "i", CTEXTAREA_line), - //GB_PROPERTY("Column", "i", CTEXTAREA_column), + GB_PROPERTY("Line", "i", CTEXTAREA_line), + GB_PROPERTY("Column", "i", CTEXTAREA_column), GB_PROPERTY("Pos", "i", CTEXTAREA_pos), GB_PROPERTY_SELF("Selection", ".TextAreaSelection"), diff --git a/gb.qt4/src/ext/gview.cpp b/gb.qt4/src/ext/gview.cpp index 9462c6dd5..a3e230167 100644 --- a/gb.qt4/src/ext/gview.cpp +++ b/gb.qt4/src/ext/gview.cpp @@ -83,7 +83,9 @@ static QColor defaultColors[GLine::NUM_STATE] = QColor(0xC0, 0xC0, 0xFF), QColor(0xFF, 0xFF, 0x00), QColor(0xE8, 0xE8, 0xF8), - Qt::red + Qt::red, + Qt::black, + Qt::gray }; /**---- GEditor -----------------------------------------------------------*/ @@ -93,7 +95,7 @@ QPixmap *GEditor::breakpoint = 0; int GEditor::count = 0; GEditor::GEditor(QWidget *parent) - : Q3GridView(parent), + : Q3ScrollView(parent), fm(font()) { int i; @@ -103,19 +105,20 @@ GEditor::GEditor(QWidget *parent) count++; - setNumCols(1); setKeyCompression(true); setFocusPolicy(Qt::WheelFocus); setAttribute(Qt::WA_InputMethodEnabled, true); + setAttribute(Qt::WA_StaticContents, true); setMouseTracking(true); viewport()->setMouseTracking(true); viewport()->setCursor(Qt::ibeamCursor); - //setBackgroundRole(QPalette::Base); viewport()->setBackgroundRole(QPalette::Base); viewport()->setAutoFillBackground(true); viewport()->setPaletteBackgroundColor(defaultColors[GLine::Background]); - //viewport()->setWFlags(WRepaintNoErase); + viewport()->setAttribute(Qt::WA_NoSystemBackground, true); + //viewport()->setAttribute(Qt::WA_StaticContents, true); + viewport()->setFocusProxy(this); x = y = xx = 0; x1m = x2m = 0; @@ -135,15 +138,16 @@ GEditor::GEditor(QWidget *parent) _showCol = 0; _showLen = 0; _posOutside = false; + _cellw = _cellh = 0; lineWidthCacheY = -1; for (i = 0; i < GLine::NUM_STATE; i++) { styles[i].color = defaultColors[i]; - styles[i].bold = i == GLine::Keyword; + styles[i].bold = i == GLine::Keyword || i == GLine::Help; styles[i].italic = i == GLine::Comment; styles[i].underline = i == GLine::Error; - if (i == GLine::Comment) + if (i == GLine::Comment || i == GLine::Help || i == GLine::Help) { styles[i].background = true; styles[i].backgroundColor = QColor(0xE8, 0xE8, 0xE8); @@ -153,6 +157,7 @@ GEditor::GEditor(QWidget *parent) } flags = 0; + setFont(QFont("monospace", QApplication::font().pointSize())); updateHeight(); @@ -211,11 +216,10 @@ int GEditor::getCharWidth() const void GEditor::updateCache() { - if (cache->width() < visibleWidth() || cache->height() < cellHeight()) + if (cache->width() < visibleWidth() || cache->height() < _cellh) { int nw = QMAX(cache->width(), visibleWidth()); - int nh = cellHeight(); //QMAX(cache->height(), cellHeight()); - //qDebug("cache->resize(%d, %d)", nw, nh); + int nh = _cellh; //QMAX(cache->height(), _cellh); cache->resize(nw, nh); } } @@ -292,15 +296,15 @@ void GEditor::updateWidth(int y) { w = lineWidth(y); - //qDebug("contentsWidth() = %d cellWidth() = %d", contentsWidth(), cellWidth()); + //qDebug("contentsWidth() = %d _cellw = %d", contentsWidth(), _cellw); //setCellWidth(QMAX(visibleWidth(), margin + charWidth * doc->getMaxLineLength() + 2)); - if (w > cellWidth()) + if (w > _cellw) { largestLine = y; goto UPDATE_WIDTH; } - else if (w < cellWidth() && y == largestLine) + else if (w < _cellw && y == largestLine) { w = findLargestLine(); goto UPDATE_WIDTH; @@ -312,33 +316,36 @@ void GEditor::updateWidth(int y) UPDATE_WIDTH: w = QMAX(visibleWidth(), w); - if (w != cellWidth()) + if (w != _cellw) { - setCellWidth(w); + _cellw = w; + updateCache(); + updateViewport(); //qDebug("setCellWidth: %d (largestLine = %d)", w, largestLine); } - updateCache(); } void GEditor::updateHeight() { - setCellHeight(fm.lineSpacing() + 1); + _cellh = fm.lineSpacing() + 1; updateCache(); - if (pattern.height() < cellHeight()) - pattern.resize(16, cellHeight()); + if (pattern.height() < _cellh) + pattern.resize(16, _cellh); + + updateViewport(); } void GEditor::redrawContents() { updateContents(); - if (contentsHeight() < visibleHeight()) - repaintContents(contentsX(), contentsHeight(), visibleWidth(), visibleHeight() - contentsHeight() + contentsX(), true); + //if (contentsHeight() < visibleHeight()) + // repaintContents(contentsX(), contentsHeight(), visibleWidth(), visibleHeight() - contentsHeight() + contentsX(), true); } void GEditor::changeEvent(QEvent *e) { - Q3GridView::changeEvent(e); + Q3ScrollView::changeEvent(e); if (e->type() == QEvent::FontChange) { fm = fontMetrics(); @@ -444,7 +451,7 @@ void GEditor::paintText(QPainter &p, GLine *l, int x, int y, int xmin, int lmax, xd2 = x2; if (alternate && (i == (GB.Count(l->highlight) - 1))) - nx = cellWidth(); + nx = _cellw; p.fillRect(x, 0, nx - x, h, bg); @@ -611,7 +618,7 @@ void GEditor::paintCell(QPainter *painter, int row, int) bool folded; bool highlight; - ur = cellGeometry(row, 0); + ur = QRect(0, row * _cellh, _cellw, _cellh); contentsToViewport(ur.x(), ur.y(), x1, y1); ur.setRect(-x1, y1, ur.width(), ur.height()); @@ -659,7 +666,7 @@ void GEditor::paintCell(QPainter *painter, int row, int) color = calc_color(a, b, styles[GLine::Background].color); - p.fillRect(0, 0, cellWidth(), cellHeight(), color); + p.fillRect(0, 0, _cellw, _cellh, color); p.setFont(font()); //p.setFont(painter->font()); @@ -670,7 +677,7 @@ void GEditor::paintCell(QPainter *painter, int row, int) { if (getFlag(BlendedProcedureLimits)) { - make_blend(pattern, styles[GLine::Line].color, color, cellHeight()); + make_blend(pattern, styles[GLine::Line].color, color, _cellh); p.drawTiledPixmap(0, 0, cache->width(), cache->height(), pattern); } else @@ -684,7 +691,7 @@ void GEditor::paintCell(QPainter *painter, int row, int) // Show string if (highlight && (_showRow == realRow || _showString.length())) - paintShowString(p, l, margin, fm.ascent() + 1, xmin, lmax, cellHeight(), realRow); + paintShowString(p, l, margin, fm.ascent() + 1, xmin, lmax, _cellh, realRow); // Selection background xs1 = 0; @@ -701,11 +708,11 @@ void GEditor::paintCell(QPainter *painter, int row, int) x1 = lineWidth(y1, x1); if (realRow < y2) - x2 = cellWidth() + 1; + x2 = _cellw + 1; else x2 = lineWidth(y2, x2); - p.fillRect(x1, 0, x2 - x1, cellHeight(), styles[GLine::Selection].color); + p.fillRect(x1, 0, x2 - x1, _cellh, styles[GLine::Selection].color); xs1 = x1; xs2 = x2; } @@ -715,12 +722,12 @@ void GEditor::paintCell(QPainter *painter, int row, int) if (margin && (margin > ur.left())) { //if (!l->flag) - // p.fillRect(0, 0, margin, cellHeight(), color); //styles[GLine::Background].color); + // p.fillRect(0, 0, margin, _cellh, color); //styles[GLine::Background].color); if (getFlag(ShowModifiedLines) && l->changed) - p.fillRect(0, 0, margin - 2, cellHeight(), styles[GLine::Highlight].color); + p.fillRect(0, 0, margin - 2, _cellh, styles[GLine::Highlight].color); else //if (getFlag(ShowLineNumbers)) - p.fillRect(0, 0, margin - 2, cellHeight(), styles[GLine::Line].color); + p.fillRect(0, 0, margin - 2, _cellh, styles[GLine::Line].color); //x1 = 0; @@ -740,10 +747,10 @@ void GEditor::paintCell(QPainter *painter, int row, int) { //highlight_text(p, x1m * charWidth + margin, fm.ascent(), l->s.getString().mid(x1m, 1), styles[GLine::Highlight].color); //highlight_text(p, x2m * charWidth + margin, fm.ascent(), l->s.getString().mid(x2m, 1), styles[GLine::Highlight].color); - highlight_text(p, lineWidth(ym, x1m), fm.ascent(), lineWidth(ym, x1m + 1), cellHeight(), l->s.getString().mid(x1m, 1), styles[GLine::Highlight].color); - highlight_text(p, lineWidth(ym, x2m), fm.ascent(), lineWidth(ym, x2m + 1), cellHeight(), l->s.getString().mid(x2m, 1), styles[GLine::Highlight].color); - /*p.fillRect(x1m * charWidth + margin, 0, charWidth, cellHeight(), styles[GLine::Highlight].color); - p.fillRect(x2m * charWidth + margin, 0, charWidth, cellHeight(), styles[GLine::Highlight].color);*/ + highlight_text(p, lineWidth(ym, x1m), fm.ascent(), lineWidth(ym, x1m + 1), _cellh, l->s.getString().mid(x1m, 1), styles[GLine::Highlight].color); + highlight_text(p, lineWidth(ym, x2m), fm.ascent(), lineWidth(ym, x2m + 1), _cellh, l->s.getString().mid(x2m, 1), styles[GLine::Highlight].color); + /*p.fillRect(x1m * charWidth + margin, 0, charWidth, _cellh, styles[GLine::Highlight].color); + p.fillRect(x2m * charWidth + margin, 0, charWidth, _cellh, styles[GLine::Highlight].color);*/ } // Line text @@ -765,7 +772,7 @@ void GEditor::paintCell(QPainter *painter, int row, int) }*/ else { - paintText(p, l, margin, fm.ascent() + 1, xmin, lmax, cellHeight(), xs1, xs2, realRow); + paintText(p, l, margin, fm.ascent() + 1, xmin, lmax, _cellh, xs1, xs2, realRow); } } @@ -777,9 +784,9 @@ void GEditor::paintCell(QPainter *painter, int row, int) int w; pal.setColor(QColorGroup::Foreground, styles[GLine::Normal].color); - w = qMin(cellHeight(), 12); + w = qMin(_cellh, 12); //opt.rect = QRect(margin - 12, 0, 12, 12); - opt.rect = QRect(margin - w, 0, w, cellHeight()); + opt.rect = QRect(margin - w, 0, w, _cellh); opt.palette = pal; opt.state |= QStyle::State_Enabled; @@ -789,28 +796,28 @@ void GEditor::paintCell(QPainter *painter, int row, int) // Breakpoint symbol if ((l->flag & (1 << GLine::BreakpointFlag)) && breakpoint && !breakpoint->isNull()) { - //p.fillRect(margin - 10, 0, 8, cellHeight(), styles[GLine::Breakpoint].color); + //p.fillRect(margin - 10, 0, 8, _cellh, styles[GLine::Breakpoint].color); //updateBreakpoint(styles[GLine::Background].color.rgb(), styles[GLine::Breakpoint].color.rgb()); - p.drawPixmap(margin - (cellHeight() + breakpoint->width()) / 2, (cellHeight() - breakpoint->height()) / 2, *breakpoint); + p.drawPixmap(margin - (_cellh + breakpoint->width()) / 2, (_cellh - breakpoint->height()) / 2, *breakpoint); } // Text cursor if (cursor && realRow == y) - //p.fillRect(QMIN((int)l->s.length(), x) * charWidth + margin, 0, 1, cellHeight(), styles[GLine::Normal].color); - p.fillRect(lineWidth(realRow, QMIN((int)l->s.length(), x)), 0, 1, cellHeight(), styles[GLine::Normal].color); + //p.fillRect(QMIN((int)l->s.length(), x) * charWidth + margin, 0, 1, _cellh, styles[GLine::Normal].color); + p.fillRect(lineWidth(realRow, QMIN((int)l->s.length(), x)), 0, 1, _cellh, styles[GLine::Normal].color); // Flash if (flashed) { //p.setCompositionMode(QPainter::CompositionMode_Xor); - p.fillRect(0, 0, visibleWidth(), cellHeight(), Qt::black); + p.fillRect(0, 0, visibleWidth(), _cellh, Qt::black); } p.end(); //if (cache->width() < visibleWidth()) // qDebug("cache->width() = %d < visibleWidth() = %d", cache->width(), visibleWidth()); - painter->drawPixmap(ur.left(), 0, *cache, 0, 0, cellWidth(), cellHeight()); + painter->drawPixmap(ur.left(), 0, *cache, 0, 0, _cellw, _cellh); } @@ -1095,13 +1102,13 @@ void GEditor::cursorEnd(bool shift, bool ctrl) void GEditor::cursorPageUp(bool mark) { - int page = visibleHeight() / cellHeight(); + int page = visibleHeight() / _cellh; cursorGoto(viewToReal(realToView(y) - page), 0, mark); } void GEditor::cursorPageDown(bool mark) { - int page = visibleHeight() / cellHeight(); + int page = visibleHeight() / _cellh; cursorGoto(viewToReal(realToView(y) + page), 0, mark); } @@ -1506,7 +1513,7 @@ void GEditor::cursorToPos(int y, int x, int *px, int *py) y = realToView(y); - npy = y * cellHeight() - contentsY(); + npy = y * _cellh - contentsY(); //npx = x * charWidth - contentsX() + margin; npx = lineWidth(y, x) - contentsX(); @@ -1635,9 +1642,10 @@ void GEditor::mouseReleaseEvent(QMouseEvent *e) void GEditor::resizeEvent(QResizeEvent *e) { - Q3GridView::resizeEvent(e); + Q3ScrollView::resizeEvent(e); baptizeVisible(); updateWidth(); + //updateViewport(); } bool GEditor::isCursorVisible() @@ -1646,7 +1654,7 @@ bool GEditor::isCursorVisible() cursorToPos(y, x, &px, &py); - return !(px < margin || px >= (visibleWidth() - 2) || py < 0 || py >= (visibleHeight() - cellHeight() - 1)); + return !(px < margin || px >= (visibleWidth() - 2) || py < 0 || py >= (visibleHeight() - _cellh - 1)); } void GEditor::ensureCursorVisible() @@ -1661,11 +1669,11 @@ void GEditor::ensureCursorVisible() yy = realToView(y); if (center) - //ensureVisible(x * charWidth, y * cellHeight() + cellHeight() / 2, margin + 2, visibleHeight() / 2); - ensureVisible(lineWidth(y, x) + getCharWidth() / 2, yy * cellHeight() + cellHeight() / 2, margin + 2, visibleHeight() / 2); + //ensureVisible(x * charWidth, y * _cellh + _cellh / 2, margin + 2, visibleHeight() / 2); + ensureVisible(lineWidth(y, x) + getCharWidth() / 2, yy * _cellh + _cellh / 2, margin + 2, visibleHeight() / 2); else - //ensureVisible(x * charWidth, y * cellHeight() + cellHeight() / 2, margin + 2, cellHeight()); - ensureVisible(lineWidth(y, x) + getCharWidth() / 2, yy * cellHeight() + cellHeight() / 2, margin + 2, cellHeight()); + //ensureVisible(x * charWidth, y * _cellh + _cellh / 2, margin + 2, _cellh); + ensureVisible(lineWidth(y, x) + getCharWidth() / 2, yy * _cellh + _cellh / 2, margin + 2, _cellh); } center = false; } @@ -1698,13 +1706,13 @@ void GEditor::focusInEvent(QFocusEvent *e) { startBlink(); //ensureCursorVisible(); - Q3GridView::focusInEvent(e); + Q3ScrollView::focusInEvent(e); } void GEditor::focusOutEvent(QFocusEvent *e) { stopBlink(); - Q3GridView::focusOutEvent(e); + Q3ScrollView::focusOutEvent(e); } @@ -1735,11 +1743,12 @@ void GEditor::setStyle(int index, GHighlightStyle *style) void GEditor::setNumRows(int n) { - n = realToView(n - 1) + 1; - Q3GridView::setNumRows(n); - Q3GridView::updateScrollBars(); - if (contentsHeight() < visibleHeight()) - repaintContents(contentsX(), contentsHeight(), visibleWidth(), visibleHeight() - contentsHeight() + contentsX(), true); + _nrows = realToView(n - 1) + 1; + //Q3GridView::setNumRows(n); + updateViewport(); + //Q3ScrollView::updateScrollBars(); + //if (contentsHeight() < visibleHeight()) + // repaintContents(contentsX(), contentsHeight(), visibleWidth(), visibleHeight() - contentsHeight() + contentsX(), true); //if (contentsHeight() < visibleHeight()) //repaintContents(true); } @@ -1918,7 +1927,7 @@ QVariant GEditor::inputMethodQuery(Qt::InputMethodQuery property) const getCursor(&cy, &cx); that->cursorToPos(cy, cx, &px, &py); - return QRect(px, py, 1, cellHeight()); + return QRect(px, py, 1, _cellh); } case Qt::ImFont: return font(); @@ -2050,7 +2059,7 @@ void GEditor::foldLine(int row, bool no_refresh) end--; l = doc->lines.at(end); //qDebug("[%d] state = %d %d", end, l->highlight ? l->highlight[0].state : -1, l->highlight ? l->highlight[0].len : -1); - if (!l->highlight || l->highlight[0].state != GLine::Comment) + if (!l->highlight || (l->highlight[0].state != GLine::Comment && l->highlight[0].state != GLine::Help)) break; } } @@ -2083,7 +2092,7 @@ void GEditor::foldLine(int row, bool no_refresh) if (!no_refresh) { setNumRows(numLines()); - redrawContents(); + //redrawContents(); } } @@ -2102,7 +2111,7 @@ void GEditor::unfoldLine(int row) fold.remove(i); //dump_fold(fold); setNumRows(numLines()); - redrawContents(); + //redrawContents(); return; } } @@ -2215,7 +2224,7 @@ void GEditor::foldAll() } setNumRows(numLines()); - updateContents(); + //updateContents(); } void GEditor::unfoldAll() @@ -2223,7 +2232,7 @@ void GEditor::unfoldAll() foldClear(); setNumRows(numLines()); ensureCursorVisible(); - redrawContents(); + //redrawContents(); } @@ -2305,36 +2314,69 @@ void GEditor::showWord(int y, int x, int len) void GEditor::updateLine(int y) { - QRect r(0, realToView(y) * cellHeight(), cellWidth(), cellHeight()); + QRect r(0, realToView(y) * _cellh, _cellw, _cellh); updateContents(r); } +void GEditor::paintEmptyArea(QPainter *p, int cx, int cy, int cw, int ch) +{ + if ((_nrows * _cellh) >= contentsHeight()) + return; + + contentsToViewport(cx, cy, cx, cy); + QRegion reg(QRect(cx, cy, cw, ch)); + QSize size(_cellw, _nrows * _cellh); + reg = reg.subtracted(QRect(contentsToViewport(QPoint(0, 0)), size)); + + // And draw the rectangles (transformed as needed) + QVector r = reg.rects(); + for (int i = 0; i < (int)r.count(); ++i) + p->fillRect(r[i], viewport()->paletteBackgroundColor()); +} + void GEditor::drawContents(QPainter *p, int cx, int cy, int cw, int ch) { - int colfirst = columnAt(cx); int rowfirst = rowAt(cy); int rowlast = rowAt(cy + ch - 1); - if (rowfirst == -1 || colfirst == -1) - { - paintEmptyArea(p, cx, cy, cw, ch); - return; - } - - if (rowlast < 0 || rowlast >= numLines()) - rowlast = numLines() - 1; + if (rowfirst < 0) + rowfirst = 0; + if (rowlast >= _nrows) + rowlast = _nrows - 1; // Go through the rows for (int r = rowfirst; r <= rowlast; ++r) { // get row position and height - int rowp = r * cellHeight(); + int rowp = r * _cellh; // Translate painter and draw the cell p->translate(0, rowp); paintCell(p, r, 0); p->translate(0, -rowp); } - // Paint empty rects paintEmptyArea(p, cx, cy, cw, ch); } + +void GEditor::updateViewport() +{ + int vw, vh; + + vw = contentsRect().width(); + vh = contentsRect().height(); + + if (doc) + { + vw = QMAX(_cellw, vw); + vh = QMAX(_cellh * _nrows, vh); + //qDebug("updateViewport: h = %d vh = %d", _cellh * numLines(), contentsRect().height()); + } + + if (vw != contentsWidth() || vh != contentsHeight()) + Q3ScrollView::resizeContents(vw, vh); +} + +void GEditor::resizeContents(int w, int h) +{ + updateViewport(); +} diff --git a/gb.qt4/src/ext/gview.h b/gb.qt4/src/ext/gview.h index b19505021..ddcc23015 100644 --- a/gb.qt4/src/ext/gview.h +++ b/gb.qt4/src/ext/gview.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include //Added by qt3to4: #include @@ -55,7 +55,7 @@ struct GFoldedProc int end; }; -class GEditor : public Q3GridView +class GEditor : public Q3ScrollView { Q_OBJECT @@ -85,6 +85,8 @@ private: bool _showStringIgnoreCase; int _showRow, _showCol, _showLen; bool _posOutside; + int _cellw, _cellh; + int _nrows; int lastx; bool left; @@ -119,6 +121,7 @@ private: void paintText(QPainter &p, GLine *l, int x, int y, int xmin, int lmax, int h, int x1, int x2, int row); void paintShowString(QPainter &p, GLine *l, int x, int y, int xmin, int lmax, int h, int row); void paintDottedSpaces(QPainter &p, int row, int ps, int ls); + void paintEmptyArea(QPainter *p, int cx, int cy, int cw, int ch); void docTextChanged(); void redrawContents(); @@ -129,6 +132,8 @@ private: bool isCursorVisible(); void clearLineWidthCache() { lineWidthCache.clear(); lineWidthCacheY = -1; } + void updateViewport(); + //static void updateBreakpoint(uint bg, uint fg); private slots: @@ -211,7 +216,8 @@ public: bool getFlag(int f) const { return flags & (1 << f); } void setFlag(int f, bool v); - int getLineHeight() const { return cellHeight(); } + int rowAt(int y) const { return y / _cellh; } + int getLineHeight() const { return _cellh; } int getCharWidth() const; void cursorToPos(int y, int x, int *px, int *py); bool isPosOutside() const { return _posOutside; } @@ -221,9 +227,10 @@ public: int lastVisibleRow(int y) const { return rowAt(y + visibleHeight() - 1); } int lastVisibleRow() const { return lastVisibleRow(contentsY()); } void updateLine(int y); - - virtual void setNumRows(int); - + void setNumRows(int); + + virtual void resizeContents(int w, int h); + void checkMatching(); void flash(); void showString(GString s, bool ignoreCase); diff --git a/main/lib/eval/CHighlight.c b/main/lib/eval/CHighlight.c index 6afdd3730..462a51fb9 100644 --- a/main/lib/eval/CHighlight.c +++ b/main/lib/eval/CHighlight.c @@ -144,6 +144,7 @@ static int convState(int state) case EVAL_TYPE_DATATYPE: return HIGHLIGHT_DATATYPE; case EVAL_TYPE_ERROR: return HIGHLIGHT_ERROR; case EVAL_TYPE_ALTERNATE: return HIGHLIGHT_ALTERNATE; + case EVAL_TYPE_HELP: return HIGHLIGHT_HELP; default: return HIGHLIGHT_NORMAL; } } @@ -290,6 +291,7 @@ GB_DESC CHighlightDesc[] = GB_CONSTANT("CurrentLine", "i", HIGHLIGHT_LINE), GB_CONSTANT("Error", "i", HIGHLIGHT_ERROR), GB_CONSTANT("Alternate", "i", HIGHLIGHT_ALTERNATE), + GB_CONSTANT("Help", "i", HIGHLIGHT_HELP), GB_STATIC_METHOD("_exit", NULL, CHIGHLIGHT_exit, NULL), GB_STATIC_METHOD("Analyze", "String[]", CHIGHLIGHT_analyze, "(Code)s[(Rewrite)b(State)i]"), diff --git a/main/lib/eval/eval_analyze.c b/main/lib/eval/eval_analyze.c index 531589e47..4ba287253 100644 --- a/main/lib/eval/eval_analyze.c +++ b/main/lib/eval/eval_analyze.c @@ -309,6 +309,8 @@ static void analyze(EVAL_ANALYZE *result) case EVAL_TYPE_COMMENT: //state = Commentary; space_before = *symbol != ' '; + if (len >= 2 && symbol[1] == '\'') + type = EVAL_TYPE_HELP; break; case EVAL_TYPE_OPERATOR: diff --git a/main/lib/eval/gb.eval.h b/main/lib/eval/gb.eval.h index 18c6a2c14..8c3bab3bb 100644 --- a/main/lib/eval/gb.eval.h +++ b/main/lib/eval/gb.eval.h @@ -33,13 +33,13 @@ typedef typedef void *EVAL_EXPRESSION; -#define EVAL_COLOR_MAX_LEN (1 << 11) +#define EVAL_COLOR_MAX_LEN (1 << 10) typedef struct { - unsigned state : 4; + unsigned state : 5; unsigned alternate : 1; - unsigned len : 11; + unsigned len : 10; } EVAL_COLOR; @@ -75,7 +75,8 @@ enum { EVAL_TYPE_OPERATOR = 11, EVAL_TYPE_DATATYPE = 12, EVAL_TYPE_ERROR = 13, - EVAL_TYPE_ALTERNATE = 14 + EVAL_TYPE_ALTERNATE = 14, + EVAL_TYPE_HELP = 15 }; typedef @@ -98,6 +99,7 @@ typedef HIGHLIGHT_LINE, HIGHLIGHT_ERROR, HIGHLIGHT_ALTERNATE, + HIGHLIGHT_HELP, HIGHLIGHT_NUM_COLOR } HIGHLIGHT_COLOR;