diff --git a/App.xojo_code b/App.xojo_code index e2fb8b7..1856a8a 100644 --- a/App.xojo_code +++ b/App.xojo_code @@ -14,6 +14,8 @@ Inherits Application FileClose.Text = "Close" FileClose.KeyboardShortcut = "cmd-W" end if + + FileSaveWithIndents.Checked = Prefs.SaveWithIndents End Sub #tag EndEvent @@ -126,6 +128,15 @@ Inherits Application End Function #tag EndMenuHandler + #tag MenuHandler + Function FileSaveWithIndents() As Boolean Handles FileSaveWithIndents.Action + Prefs.SaveWithIndents = not Prefs.SaveWithIndents + + Return True + + End Function + #tag EndMenuHandler + #tag MenuHandler Function HelpAbout() As Boolean Handles HelpAbout.Action WndAbout.Show @@ -203,10 +214,10 @@ Inherits Application #Tag Instance, Platform = Linux, Language = Default, Definition = \"&Delete" #tag EndConstant - #tag Constant, Name = kEditComment, Type = String, Dynamic = False, Default = \"Comment", Scope = Public + #tag Constant, Name = kEditComment, Type = String, Dynamic = False, Default = \"Co&mment", Scope = Public #tag EndConstant - #tag Constant, Name = kEditUncomment, Type = String, Dynamic = False, Default = \"Uncomment", Scope = Public + #tag Constant, Name = kEditUncomment, Type = String, Dynamic = False, Default = \"Unco&mment", Scope = Public #tag EndConstant #tag Constant, Name = kFileQuit, Type = String, Dynamic = False, Default = \"&Quit", Scope = Public @@ -218,10 +229,10 @@ Inherits Application #Tag Instance, Platform = Linux, Language = Default, Definition = \"Ctrl+Q" #tag EndConstant - #tag Constant, Name = kViewHideToolbar, Type = String, Dynamic = False, Default = \"Hide Toolbar", Scope = Public + #tag Constant, Name = kViewHideToolbar, Type = String, Dynamic = False, Default = \"Hide &Toolbar", Scope = Public #tag EndConstant - #tag Constant, Name = kViewShowToolbar, Type = String, Dynamic = False, Default = \"Show Toolbar", Scope = Public + #tag Constant, Name = kViewShowToolbar, Type = String, Dynamic = False, Default = \"Show &Toolbar", Scope = Public #tag EndConstant diff --git a/Classes/IDEEmulator.xojo_code b/Classes/IDEEmulator.xojo_code index 08f32a6..76f404d 100644 --- a/Classes/IDEEmulator.xojo_code +++ b/Classes/IDEEmulator.xojo_code @@ -65,7 +65,7 @@ Protected Class IDEEmulator #tag EndMethod #tag Method, Flags = &h1 - Protected Function CurrentBuildTarget() As String + Protected Function CurrentBuildTarget() As Integer Extras.ShowWarning End Function #tag EndMethod @@ -585,16 +585,6 @@ Protected Class IDEEmulator Group="Behavior" Type="Boolean" #tag EndViewProperty - #tag ViewProperty - Name="BuildWebProtocol" - Group="Behavior" - Type="Integer" - #tag EndViewProperty - #tag ViewProperty - Name="BuildWin32" - Group="Behavior" - Type="Boolean" - #tag EndViewProperty #tag ViewProperty Name="Index" Visible=true @@ -609,11 +599,6 @@ Protected Class IDEEmulator InitialValue="0" Type="Integer" #tag EndViewProperty - #tag ViewProperty - Name="Location" - Group="Behavior" - Type="String" - #tag EndViewProperty #tag ViewProperty Name="Name" Visible=true diff --git a/Classes/XsEditCustomEditField.xojo_code b/Classes/XsEditCustomEditField.xojo_code new file mode 100644 index 0000000..b849b6a --- /dev/null +++ b/Classes/XsEditCustomEditField.xojo_code @@ -0,0 +1,634 @@ +#tag Class +Protected Class XsEditCustomEditField +Inherits CustomEditField + #tag MenuHandler + Function EditCopy() As Boolean Handles EditCopy.Action + + Return False + + End Function + #tag EndMenuHandler + + #tag MenuHandler + Function EditCut() As Boolean Handles EditCut.Action + + Return False + + End Function + #tag EndMenuHandler + + + #tag Method, Flags = &h21 + Private Sub Destructor() + if mReindentTimer isa Timer then + mReindentTimer.Mode = Timer.ModeOff + RemoveHandler mReindentTimer.Action, AddressOf ReindentTimerAction + mReindentTimer = nil + end if + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub ReindentText(timed As Boolean) + if timed then + + ReindentTimer.Mode = Timer.ModeSingle + ReindentTimer.Reset + + else + + super.ReindentText() + + end if + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub ReindentText(fromLine as Integer, toLine as integer) + if IsReindenting then + return + end if + + IsReindenting = true + super.ReindentText( fromLine, toLine ) + IsReindenting = false + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ReindentTimerAction(sender As Timer) + #pragma unused sender + + ReindentText( false ) + End Sub + #tag EndMethod + + + #tag Note, Name = Why + For purposes of speed, it's better to turn IdentVisually on, but that means + that copied text will not be indented. + + Instead, we overide the handling of Cut and Copy in WndEditor to + perform those operations in a new, temporary window. That window opens, + pastes just the text it needs into the field, reindents and copies it. That + window is then closed, the user none the wiser. + + #tag EndNote + + + #tag Property, Flags = &h21 + Private IsReindenting As Boolean + #tag EndProperty + + #tag Property, Flags = &h21 + Private mReindentTimer As Timer + #tag EndProperty + + #tag ComputedProperty, Flags = &h21 + #tag Getter + Get + if mReindentTimer is nil then + mReindentTimer = new Timer + mReindentTimer.Mode = Timer.ModeOff + mReindentTimer.Period = 50 + + AddHandler mReindentTimer.Action, AddressOf ReindentTimerAction + end if + + return mReindentTimer + End Get + #tag EndGetter + Private ReindentTimer As Timer + #tag EndComputedProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="AcceptFocus" + Visible=true + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="AcceptTabs" + Visible=true + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="AutoCloseBrackets" + Visible=true + Group="Behavior" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="AutocompleteAppliesStandardCase" + Visible=true + Group="Behavior" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="AutoDeactivate" + Visible=true + Group="Appearance" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="AutoIndentNewLines" + Visible=true + Group="Behavior" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="BackColor" + Visible=true + Group="Appearance" + InitialValue="&cffffff" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="Backdrop" + Visible=true + Group="Appearance" + Type="Picture" + EditorType="Picture" + #tag EndViewProperty + #tag ViewProperty + Name="Border" + Visible=true + Group="Appearance" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="BorderColor" + Visible=true + Group="Appearance" + InitialValue="&h888888" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="BracketHighlightColor" + Visible=true + Group="Behavior" + InitialValue="&cFFFF00" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="CaretColor" + Visible=true + Group="Appearance" + InitialValue="&c000000" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="CaretLine" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="CaretPos" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="ClearHighlightedRangesOnTextChange" + Visible=true + Group="Behavior" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DirtyLinesColor" + Visible=true + Group="Appearance" + InitialValue="&cFF9999" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="disableReset" + Group="Behavior" + InitialValue="False" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DisplayDirtyLines" + Visible=true + Group="Appearance" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DisplayInvisibleCharacters" + Visible=true + Group="Behavior" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DisplayLineNumbers" + Visible=true + Group="Appearance" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DisplayRightMarginMarker" + Visible=true + Group="Appearance" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="DoubleBuffer" + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="EnableAutocomplete" + Visible=true + Group="Behavior" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Appearance" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="EnableLineFoldings" + Visible=true + Group="Behavior" + InitialValue="false" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="enableLineFoldingSetting" + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="EraseBackground" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="GutterBackgroundColor" + Visible=true + Group="Appearance" + InitialValue="&cEEEEEE" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="GutterSeparationLineColor" + Visible=true + Group="Appearance" + InitialValue="&c888888" + Type="Color" + #tag EndViewProperty + #tag ViewProperty + Name="GutterWidth" + Visible=true + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Position" + InitialValue="100" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="HelpTag" + Visible=true + Group="Appearance" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="HighlightBlocksOnMouseOverGutter" + Visible=true + Group="Behavior" + InitialValue="true" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="HighlightMatchingBrackets" + Visible=true + Group="Behavior" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="HighlightMatchingBracketsMode" + Visible=true + Group="Behavior" + InitialValue="0" + Type="Integer" + EditorType="Enum" + #tag EnumValues + "0 - Circle" + "1 - Highlight" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="ignoreRepaint" + Group="Behavior" + InitialValue="0" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="IndentPixels" + Visible=true + Group="Behavior" + InitialValue="16" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="IndentVisually" + Visible=true + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + Type="Integer" + EditorType="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="InitialParent" + Group="Initial State" + Type="String" + #tag EndViewProperty + #tag ViewProperty + Name="KeepEntireTextIndented" + Visible=true + Group="Behavior" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="leftMarginOffset" + Visible=true + Group="Appearance" + InitialValue="4" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="LineNumbersColor" + Visible=true + Group="Appearance" + InitialValue="&c888888" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="LineNumbersTextFont" + Visible=true + Group="Appearance" + InitialValue="System" + Type="string" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="LineNumbersTextSize" + Visible=true + Group="Appearance" + InitialValue="9" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Position" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Position" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Position" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Position" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="MaxVisibleLines" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + Type="String" + EditorType="String" + #tag EndViewProperty + #tag ViewProperty + Name="ReadOnly" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="RightMarginAtPixel" + Visible=true + Group="Appearance" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="RightScrollMargin" + Visible=true + Group="Appearance" + InitialValue="150" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollPosition" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollPositionX" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="selLength" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="selStart" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="SelText" + Group="Behavior" + Type="string" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + Type="String" + EditorType="String" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="TabPanelIndex" + Group="Position" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="TabStop" + Visible=true + Group="Position" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="TabWidth" + Visible=true + Group="Behavior" + InitialValue="4" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Text" + Visible=true + Group="Appearance" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TextColor" + Visible=true + Group="Appearance" + InitialValue="&h000000" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="TextFont" + Visible=true + Group="Appearance" + Type="string" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TextHeight" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="TextLength" + Group="Behavior" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="TextSelectionColor" + Visible=true + Group="Appearance" + InitialValue="&h000000" + Type="color" + #tag EndViewProperty + #tag ViewProperty + Name="TextSize" + Visible=true + Group="Appearance" + InitialValue="0" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="ThickInsertionPoint" + Visible=true + Group="Appearance" + InitialValue="true" + Type="boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + Type="Integer" + #tag EndViewProperty + #tag ViewProperty + Name="Transparent" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="UseFocusRing" + Visible=true + Group="Appearance" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Appearance" + InitialValue="True" + Type="Boolean" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Position" + InitialValue="100" + Type="Integer" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/Example Scripts/Pair & Dictionary.xojo_script b/Example Scripts/Pair & Dictionary.xojo_script index 6a83269..e83db3b 100644 --- a/Example Scripts/Pair & Dictionary.xojo_script +++ b/Example Scripts/Pair & Dictionary.xojo_script @@ -13,11 +13,13 @@ End Sub End Class Class Dictionary -Private Const kBinCount = 10000 +Private Const kBinCount = &hFFFF Private Bins() As Variant Private mIsCaseSensitive As Boolean +Dim DebugMode As Boolean = False + Private Function KeyToStorageKey( key As Variant ) As Variant if not mIsCaseSensitive then select case key.Type @@ -77,15 +79,17 @@ dim storageKeyArr() as variant = entry.LeftValue subBinIndex = StorageIndexOf( storageKeyArr, storageKey ) end if -'print "key: " + key + _ -'", sk: " + storageKey + _ -'", hash: " + str( keyHash ) + _ -'", binIndex: " + str( binIndex ) + _ -'", subBinIndex: " + str( subBinIndex ) +if DebugMode then +print "key: " + key + _ +", sk: " + storageKey + _ +", hash: " + str( keyHash ) + _ +", binIndex: " + str( binIndex ) + _ +", subBinIndex: " + str( subBinIndex ) +end if End Sub Sub Constructor( caseSensitive As Boolean = False ) -mIsCaseSensitive = caseSensitive +mIsCaseSensitive = caseSensitive End Sub Function IsCaseSensitive() As Boolean @@ -187,7 +191,8 @@ dim v as variant = arr( i ) select case v.Type case Variant.TypeString, Variant.TypeText s.Append """" + v.StringValue + """" -case Variant.TypeBoolean, Variant.TypeInteger, Variant.TypeDouble, Variant.TypeSingle, Variant.TypeColor +case Variant.TypeBoolean, Variant.TypeInteger, Variant.TypeLong, _ +Variant.TypeDouble, Variant.TypeSingle, Variant.TypeColor s.Append v case Variant.TypeNil s.Append "nil" @@ -205,17 +210,34 @@ End Sub Sub PrintValues() PrintVariantArray( self.Values ) End Sub + +Function CountCollisions() As Integer +dim cnt as integer +for each entry as Pair in Bins +if entry isa Pair then +dim p as Pair = entry.RightValue +dim keyArr() as variant = p.LeftValue +cnt = cnt + keyArr.Ubound +end if +next +return cnt +End Function End Class -dim startms as double = Microseconds +// +// Tests +// + dim d as Dictionary = new Dictionary( true ) + +dim startms as double = Microseconds for i as integer = 1 to 1000 d.Value( i ) = nil next dim endms as double = Microseconds -print format( endms - startms, "#," ) +print "Processing Time: " + format( endms - startms, "#," ) -d = new Dictionary( false ) +d = new Dictionary( true ) d.Value( 12 ) = 12 d.Value( "a" ) = "a" @@ -241,4 +263,19 @@ d.Value( new Pair ) = "pair" print "printing keys" d.PrintKeys -d.PrintValues \ No newline at end of file +d.PrintValues + +// +// Test collisions +// + +d = new Dictionary( true ) +dim key1 as variant = CType( 12, UInt64 ) +dim key2 as variant = CType( &hFFFF + 12, UInt64 ) + +d.DebugMode = true +d.Value( key1 ) = 1 +d.Value( key2 ) = 2 +d.PrintKeys +d.PrintValues +print "Collisions: " + str( d.CountCollisions ) diff --git a/Menu Stuff/MainMenuBar.xojo_menu b/Menu Stuff/MainMenuBar.xojo_menu index 55174dd..587e9d7 100644 --- a/Menu Stuff/MainMenuBar.xojo_menu +++ b/Menu Stuff/MainMenuBar.xojo_menu @@ -8,7 +8,7 @@ Begin Menu MainMenuBar Visible = True Begin MenuItem FileNew SpecialMenu = 0 - Text = "New Script" + Text = "&New Script" Index = -2147483648 ShortcutKey = "N" Shortcut = "Cmd+N" @@ -18,7 +18,7 @@ Begin Menu MainMenuBar End Begin MenuItem FileOpen SpecialMenu = 0 - Text = "Open..." + Text = "&Open..." Index = -2147483648 ShortcutKey = "O" Shortcut = "Cmd+O" @@ -28,7 +28,7 @@ Begin Menu MainMenuBar End Begin MenuItem FileClose SpecialMenu = 0 - Text = "Close" + Text = "&Close" Index = -2147483648 ShortcutKey = "W" Shortcut = "Cmd+W" @@ -45,7 +45,7 @@ Begin Menu MainMenuBar End Begin MenuItem FileSave SpecialMenu = 0 - Text = "Save" + Text = "&Save" Index = -2147483648 ShortcutKey = "S" Shortcut = "Cmd+S" @@ -55,7 +55,7 @@ Begin Menu MainMenuBar End Begin MenuItem FileSaveAs SpecialMenu = 0 - Text = "Save As..." + Text = "Save &As..." Index = -2147483648 ShortcutKey = "S" Shortcut = "Cmd+Shift+S" @@ -64,6 +64,25 @@ Begin Menu MainMenuBar AutoEnable = True Visible = True End + Begin MenuItem UntitledSeparator9 + SpecialMenu = 0 + Text = "-" + Index = -2147483648 + AutoEnable = True + Visible = True + End + Begin MenuItem FileSaveWithIndents + SpecialMenu = 0 + Text = "Should Save &Indents" + Index = -2147483648 + ShortcutKey = "S" + Shortcut = "Cmd+Option+Alt+S" + MenuModifier = True + MacOptionKey = True + PCAltKey = True + AutoEnable = True + Visible = True + End Begin MenuItem UntitledSeparator0 SpecialMenu = 0 Text = "-" @@ -99,7 +118,7 @@ Begin Menu MainMenuBar End Begin MenuItem EditRedo SpecialMenu = 0 - Text = "Redo" + Text = "&Redo" Index = -2147483648 ShortcutKey = "Z" Shortcut = "Cmd+Shift+Z" @@ -195,7 +214,7 @@ Begin Menu MainMenuBar End Begin MenuItem EditFind SpecialMenu = 0 - Text = "Find" + Text = "&Find" Index = -2147483648 ShortcutKey = "F" Shortcut = "Cmd+F" @@ -205,7 +224,7 @@ Begin Menu MainMenuBar End Begin MenuItem EditFindNext SpecialMenu = 0 - Text = "Find Next" + Text = "Find &Next" Index = -2147483648 ShortcutKey = "G" Shortcut = "Cmd+G" @@ -215,7 +234,7 @@ Begin Menu MainMenuBar End Begin MenuItem EditFindPrevious SpecialMenu = 0 - Text = "Find Previous" + Text = "Fin&d Previous" Index = -2147483648 ShortcutKey = "G" Shortcut = "Cmd+Shift+G" @@ -233,7 +252,7 @@ Begin Menu MainMenuBar End Begin PrefsMenuItem EditPreferences SpecialMenu = 0 - Text = "Preferences..." + Text = "Preference&s..." Index = -2147483648 AutoEnable = True Visible = True @@ -369,7 +388,7 @@ Begin Menu MainMenuBar End Begin MenuItem ScriptInsertInclude SpecialMenu = 0 - Text = "Insert Include File..." + Text = "&Insert Include File..." Index = -2147483648 AutoEnable = True Visible = True @@ -383,7 +402,7 @@ Begin Menu MainMenuBar Visible = True Begin MenuItem HelpXojoScriptingLanguageDocs SpecialMenu = 0 - Text = "Xojo Scripting Language Documentation" + Text = "&Xojo Scripting Language Documentation" Index = -2147483648 AutoEnable = True Visible = True @@ -397,7 +416,7 @@ Begin Menu MainMenuBar End Begin ApplicationMenuItem HelpAbout SpecialMenu = 0 - Text = "About" + Text = "&About" Index = -2147483648 AutoEnable = True Visible = True diff --git a/Other Files/Syntax Definition/XojoScript.xml b/Other Files/Syntax Definition/XojoScript.xml index aa0e76f..e490040 100644 --- a/Other Files/Syntax Definition/XojoScript.xml +++ b/Other Files/Syntax Definition/XojoScript.xml @@ -1,5 +1,5 @@ - + XojoScript @@ -18,7 +18,7 @@ ^\s*(protected\b|private\b)?\s*interface\b ^\s*end\s+interface\b - ^(|.*\W)_\s*(|//.*|'.*)$ + ^((?:"[^"\r\n]*"|(?!'|//|\brem\b)[^\r\n_])*)_[\t\x20]*((?:'|//|\brem\b)[^\r\n]*|)$ diff --git a/Preference Stuff/Preferences.xojo_code b/Preference Stuff/Preferences.xojo_code index e152676..3e948c1 100644 --- a/Preference Stuff/Preferences.xojo_code +++ b/Preference Stuff/Preferences.xojo_code @@ -157,6 +157,18 @@ Protected Class Preferences End Function #tag EndMethod + #tag Method, Flags = &h1 + Protected Function GetWindowToolbar(win As Window) As Toolbar + for i as integer = 0 to win.ControlCount - 1 + if win.Control(i) isa Toolbar then + return Toolbar(win.Control(i)) + end if + next + + return nil + End Function + #tag EndMethod + #tag Method, Flags = &h21 Private Sub InformWatchers() WatcherTimer.Mode = Timer.ModeSingle @@ -233,8 +245,8 @@ Protected Class Preferences End Sub #tag EndMethod - #tag Method, Flags = &h21 - Private Function MakeKey(prefix As String, o As Object) As String + #tag Method, Flags = &h1 + Protected Function MakeKey(prefix As String, o As Object) As String dim key() as string if prefix <> "" then @@ -365,6 +377,15 @@ Protected Class Preferences dim fk as string = MakeKey(prefix, win) dim child as Xojo.Core.Dictionary = ChildWindowValues.Lookup(fk, nil) if child isa Xojo.Core.Dictionary then + + // + // Restore the Toolbar first + // + dim tb as Toolbar = GetWindowToolbar(win) + if tb isa Toolbar then + tb.Visible = child.Lookup("ToolbarVisible", tb.Visible) + end if + proposedLeft = child.Lookup("Left", proposedLeft) proposedTop = child.Lookup("Top", proposedTop) @@ -506,6 +527,11 @@ Protected Class Preferences child.Value("Width") = bounds.Width child.Value("Height") = bounds.Height + dim tb as Toolbar = GetWindowToolbar(win) + if tb isa Toolbar then + child.Value("ToolbarVisible") = tb.Visible + end if + dim fk as string = MakeKey(prefix, win) ChildWindowValues.Value(fk) = child diff --git a/Preference Stuff/XsEditPreferences.xojo_code b/Preference Stuff/XsEditPreferences.xojo_code index a0541da..175ba09 100644 --- a/Preference Stuff/XsEditPreferences.xojo_code +++ b/Preference Stuff/XsEditPreferences.xojo_code @@ -124,6 +124,21 @@ Inherits Preferences CodeFontSize As Integer #tag EndComputedProperty + #tag ComputedProperty, Flags = &h0 + #tag Getter + Get + return BooleanValue( kPrefSaveWithIndents, kDefaultSaveWithIndents ) + End Get + #tag EndGetter + #tag Setter + Set + BooleanValue( kPrefSaveWithIndents ) = value + + End Set + #tag EndSetter + SaveWithIndents As Boolean + #tag EndComputedProperty + #tag ComputedProperty, Flags = &h0 #tag Getter Get @@ -198,6 +213,9 @@ Inherits Preferences #tag Constant, Name = kDefaultCodeFontSize, Type = Double, Dynamic = False, Default = \"0", Scope = Public #tag EndConstant + #tag Constant, Name = kDefaultSaveWithIndents, Type = Boolean, Dynamic = False, Default = \"False", Scope = Public + #tag EndConstant + #tag Constant, Name = kDefaultShowInvisibles, Type = Boolean, Dynamic = False, Default = \"False", Scope = Public #tag EndConstant @@ -225,6 +243,9 @@ Inherits Preferences #tag Constant, Name = kPrefCodeFontSize, Type = String, Dynamic = False, Default = \"CodeFontSize", Scope = Public #tag EndConstant + #tag Constant, Name = kPrefSaveWithIndents, Type = String, Dynamic = False, Default = \"SaveWithIndents", Scope = Public + #tag EndConstant + #tag Constant, Name = kPrefShowInvisibles, Type = String, Dynamic = False, Default = \"ShowInvisibles", Scope = Public #tag EndConstant diff --git a/README.md b/README.md index 4321f8a..e89fdb2 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Download and build the project. Start up the XsEdit app and either create a new The Test Run button will force your script to run directly in XsEdit. This is good for testing small scripts but any IDE scripting methods or functions like `Location` will not actually do anything. +One benefit of Test Run is the ability to ignore the remaining Print and Input events in a script. Although there is no way to cancel the running script, you can fake it this way. + ## About Auto-complete Auto-complete works, but it is not scope or context aware. It merely auto-completes any known keyword or any variable, module, class, interface, etc., that you've defined earlier in the script whether you can access to it at that point or not, and whether it makes sense the way you are using it or not. @@ -84,3 +86,15 @@ Fork the project to your GitHub account. Use the "develop" branch for general fi - Added additional keywords. - Files will be saved with the EOL for the given platform. - Comment/Uncomment has been combined and improved. + +1.2 (August 24, 2015) + +- When window position is restored, the Toolbar visibility will be considered. +- Window staggering code fixed. +- Commenting will start at the first non-whitespace character. +- Fixed bug where line-continuation character within a comment was treated as a true line-continuation character. +- In Test Run, ability to ignore the remaining Print and Input events in the script (a sort-of cancel function). +- Copying code will copy with indents. +- Option to save a script with indents. +- Added keyboard shortcuts to menus for Windows and Linux. +- CurrentBuildTarget returns an integer instead of a string. diff --git a/Third Party Classes/CustomEditField/CustomEditField.xojo_code b/Third Party Classes/CustomEditField/CustomEditField.xojo_code index 0469e02..7acb21f 100644 --- a/Third Party Classes/CustomEditField/CustomEditField.xojo_code +++ b/Third Party Classes/CustomEditField/CustomEditField.xojo_code @@ -1973,6 +1973,13 @@ Implements MessageReceiver End Function #tag EndMethod + #tag Method, Flags = &h0 + Sub ForceHonorRepaint() + mIgnoreRepaintCount = 0 + + End Sub + #tag EndMethod + #tag Method, Flags = &h1 Protected Sub getFieldXY(byref locx as integer, byref locy as integer) //find the window where this control is... @@ -3496,6 +3503,7 @@ Implements MessageReceiver dim modified as Boolean dim previousLine as TextLine + dim wasDirty as boolean = line.IsDirty // Determine the indentation level dim currTextUntrimmed as String = TextStorage.getText(line.offset, line.length) @@ -3620,6 +3628,7 @@ Implements MessageReceiver if mIndentVisually then // we're done + line.IsDirty = wasDirty return modified end if @@ -3652,6 +3661,7 @@ Implements MessageReceiver end if private_replace (line.offset, origLeadingSpaces, theText, false, CurrentEventID, true, true) + line.IsDirty = wasDirty modified = true end @@ -3749,7 +3759,7 @@ Implements MessageReceiver // Use the default line ending from the line manager if the text is just the Return or Enter character. text = ReplaceLineEndings(text, lines.lineEnding) - text = text.ReplaceAll(Chr(3), lines.lineEnding) + text = text.ReplaceAll(chr(3), lines.lineEnding) dim removedText as String = TextStorage.getText(offset, length) dim removedAttrs() as TextLineAttributes = lines.getAttributesOfLinesInRange(offset, length) @@ -5244,12 +5254,31 @@ Implements MessageReceiver #tag ComputedProperty, Flags = &h0 #tag Getter Get - return mIgnorerepaint + return mIgnoreRepaintCount > 0 End Get #tag EndGetter #tag Setter Set - mIgnorerepaint = value + // Sets a counter so each True must be balanced with a False or + // call ForceHonorRepaint + + // + // Make sure it's never negative + // + if mIgnoreRepaintCount < 0 then + mIgnoreRepaintCount = 0 + end if + + if value then + + mIgnoreRepaintCount = mIgnoreRepaintCount + 1 + + elseif mIgnoreRepaintCount > 0 then + + mIgnoreRepaintCount = mIgnoreRepaintCount - 1 + + end if + End Set #tag EndSetter IgnoreRepaint As boolean @@ -5609,7 +5638,7 @@ Implements MessageReceiver #tag EndProperty #tag Property, Flags = &h21 - Private mIgnorerepaint As boolean + Private mIgnoreRepaintCount As Integer #tag EndProperty #tag Property, Flags = &h21 diff --git a/Third Party Classes/CustomEditField/SyntaxHighlightEngine/HighlightDefinition.xojo_code b/Third Party Classes/CustomEditField/SyntaxHighlightEngine/HighlightDefinition.xojo_code index cac39cb..64d8134 100644 --- a/Third Party Classes/CustomEditField/SyntaxHighlightEngine/HighlightDefinition.xojo_code +++ b/Third Party Classes/CustomEditField/SyntaxHighlightEngine/HighlightDefinition.xojo_code @@ -942,7 +942,7 @@ Protected Class HighlightDefinition #tag EndProperty - #tag Constant, Name = version, Type = Double, Dynamic = False, Default = \"1.3", Scope = Public + #tag Constant, Name = version, Type = Double, Dynamic = False, Default = \"1.4", Scope = Public #tag EndConstant diff --git a/Windows/TBConstants.xojo_code b/Windows/TBConstants.xojo_code index f682145..16a71fa 100644 --- a/Windows/TBConstants.xojo_code +++ b/Windows/TBConstants.xojo_code @@ -15,13 +15,13 @@ Protected Module TBConstants #tag Constant, Name = kTBEditorHelpTagRunInIDE, Type = String, Dynamic = False, Default = \"Run the current script in the Xojo IDE", Scope = Public #tag EndConstant - #tag Constant, Name = kTBEditorLabelCompile, Type = String, Dynamic = False, Default = \"Compile", Scope = Public + #tag Constant, Name = kTBEditorLabelCompile, Type = String, Dynamic = False, Default = \"&Compile", Scope = Public #tag EndConstant - #tag Constant, Name = kTBEditorLabelRunInIDE, Type = String, Dynamic = False, Default = \"Run in IDE", Scope = Public + #tag Constant, Name = kTBEditorLabelRunInIDE, Type = String, Dynamic = False, Default = \"&Run in IDE", Scope = Public #tag EndConstant - #tag Constant, Name = kTBEditorLabelTestRun, Type = String, Dynamic = False, Default = \"Test Run", Scope = Public + #tag Constant, Name = kTBEditorLabelTestRun, Type = String, Dynamic = False, Default = \"&Test Run", Scope = Public #tag EndConstant diff --git a/Windows/WndEditor.xojo_window b/Windows/WndEditor.xojo_window index 674e932..feb60ec 100644 --- a/Windows/WndEditor.xojo_window +++ b/Windows/WndEditor.xojo_window @@ -26,20 +26,7 @@ Begin SearchReceiverWindowBase WndEditor Implements PreferenceWatcher Title = "Untitled" Visible = True Width = 600 - Begin Timer tmrReindent - Height = 32 - Index = -2147483648 - InitialParent = "" - Left = 0 - LockedInPosition= False - Mode = 0 - Period = 50 - Scope = 2 - TabPanelIndex = 0 - Top = 0 - Width = 32 - End - Begin CustomEditField fldCode + Begin XsEditCustomEditField fldCode AcceptFocus = False AcceptTabs = False AutoCloseBrackets= False @@ -398,6 +385,7 @@ End end if dim doItAgain as boolean + dim myBounds as REALbasic.Rect = self.Bounds do doItAgain = false @@ -406,17 +394,19 @@ End if testWindow is self then continue for i end if - if testWindow.Left = self.Left then - self.Left = self.Left + 10 + if testWindow.Bounds.Left = myBounds.Left then + myBounds.Left = myBounds.Left + 10 doItAgain = true end if - if testWindow.Top = self.Top then - self.Top = self.Top + 10 + if testWindow.Bounds.Top = myBounds.Top then + myBounds.Top = myBounds.Top + 10 doItAgain = true end if next loop until not doItAgain + self.Bounds = myBounds + dim hd as new HighlightDefinition if not hd.LoadFromXml( App.SyntaxDefinitionFile ) then MsgBox "Could not load syntax definition" @@ -545,7 +535,11 @@ End else for each lineIndex as integer in lineIndexes - dim charPos as integer = fldCode.CharPosAtLineNum( lineIndex ) + dim thisLine as string = fldCode.GetLine( lineIndex ) + dim trimmedLine as string = thisLine.LTrim + dim spaceCount as integer = thisLine.Len - trimmedLine.Len + + dim charPos as integer = fldCode.CharPosAtLineNum( lineIndex ) + spaceCount fldCode.SelStart = charPos fldCode.SelLength = 0 fldCode.SelText = kCommentToken @@ -566,6 +560,41 @@ End End Function #tag EndMenuHandler + #tag MenuHandler + Function EditCopy() As Boolean Handles EditCopy.Action + if fldCode.IndentVisually then + dim tmpWnd as new WndEditor + tmpWnd.SetAndCopyText( fldCode.SelText ) + tmpWnd.Close + else + fldCode.Copy + end if + + Return True + + End Function + #tag EndMenuHandler + + #tag MenuHandler + Function EditCut() As Boolean Handles EditCut.Action + // + // Peform copy first + // + if fldCode.IndentVisually then + dim tmpWnd as new WndEditor + tmpWnd.SetAndCopyText( fldCode.SelText ) + tmpWnd.Close + else + fldCode.Copy + end if + + fldCode.SelText = "" + + Return True + + End Function + #tag EndMenuHandler + #tag MenuHandler Function EditFindNext() As Boolean Handles EditFindNext.Action DoFindNext @@ -1110,12 +1139,16 @@ End MyDocumentAlias = f fldCode.Text = f.TextContents_MTC( Encodings.UTF8 ) + 'fldCode.ReindentText() CodeBeforeChanges = fldCode.Text fldCode.ResetUndo fldCode.ResetUndoDirtyFlag self.ContentsChanged = false + fldCode.ClearLineIcons + fldCode.ClearDirtyLines + SetTitle() End Sub #tag EndMethod @@ -1183,7 +1216,43 @@ End return SaveAs() end if - MyDocument.TextContents_MTC = ReplaceLineEndings( fldCode.Text, EndOfLine ) + dim src as string + + dim alreadyIndented as boolean = not fldCode.IndentVisually + dim saveWithIndents as boolean = App.Prefs.SaveWithIndents + + if alreadyIndented and not saveWithIndents then + // + // Trim the leading whitespace of each line + // + src = fldCode.Text + src = ReplaceLineEndings( src, EndOfLine ) + + dim srcLines() as string = src.Split( EndOfLine ) + for i as integer = 0 to srcLines.Ubound + srcLines( i ) = srcLines( i ).LTrim + next + src = join( srcLines, EndOfLine ) + + elseif not alreadyIndented and saveWithIndents then + // + // Put back the whitespace + // + fldCode.IgnoreRepaint = true + fldCode.IndentVisually = false + src = fldCode.Text + src = ReplaceLineEndings( src, EndOfLine ) + fldCode.IndentVisually = true + fldCode.IgnoreRepaint = false + + else // Already indented the way it ought to be + + src = fldCode.Text + src = ReplaceLineEndings( src, EndOfLine ) + + end if + + MyDocument.TextContents_MTC = src ContentsChanged = false fldCode.ClearDirtyLines @@ -1216,6 +1285,7 @@ End Private Sub ScriptCompile() LastCompilerErrorCode = -1 LastCompilerErrorLine = -1 + IsScriptCancelled = false dim src as string = fldCode.Text @@ -1362,6 +1432,8 @@ End #tag Method, Flags = &h21 Private Sub SelectLineRange(firstLineIndex As Integer, lastLineIndex As Integer) + fldCode.ReindentText( false ) + dim startPos as integer = fldCode.CharPosAtLineNum( firstLineIndex ) dim endPos as integer = fldCode.CharPosAtLineNum( lastLineIndex + 1 ) if endPos = -1 then @@ -1373,6 +1445,22 @@ End End Sub #tag EndMethod + #tag Method, Flags = &h1 + Protected Sub SetAndCopyText(s As String) + dim origText as string = fldCode.Text + + fldCode.IgnoreRepaint = true + fldCode.Text = s + fldCode.IndentVisually = false + fldCode.SelectAll + fldCode.Copy + + fldCode.Text = origText + ContentsChanged = false + + End Sub + #tag EndMethod + #tag Method, Flags = &h21 Private Sub SetAutocompleteWords() if AutocompleterKeywords is nil then @@ -1469,6 +1557,7 @@ End fldCode.AutoIndentNewLines = true fldCode.IndentVisually = true + fldCode.TabWidth = 2 fldCode.Border = false fldCode.UseFocusRing = false @@ -1561,6 +1650,10 @@ End Private IsIDEAvailable As Boolean #tag EndComputedProperty + #tag Property, Flags = &h21 + Private IsScriptCancelled As Boolean + #tag EndProperty + #tag Property, Flags = &h21 Private LastCompilerErrorCode As Integer = -1 #tag EndProperty @@ -1620,18 +1713,10 @@ End #tag EndWindowCode -#tag Events tmrReindent - #tag Event - Sub Action() - fldCode.ReindentText - End Sub - #tag EndEvent -#tag EndEvents #tag Events fldCode #tag Event Sub TextChanged() - tmrReindent.Mode = Timer.ModeSingle - tmrReindent.Reset + fldCode.ReindentText( true ) me.ClearLineIcons me.HelpTag = "" @@ -1878,18 +1963,28 @@ End #tag EndEvent #tag Event Sub Print(msg As String) - dim dlg as new MessageDialog - dlg.Title = "Print" - dlg.Message = msg - dlg.CancelButton.Visible = false - - call dlg.ShowModalWithin( self ) + if not IsScriptCancelled then + dim dlg as new MessageDialog + dlg.Title = "Print" + dlg.Message = msg + dlg.CancelButton.Visible = true + dlg.CancelButton.Caption = "Go Silent" + dlg.ActionButton.Caption = "Continue" + + dim btn as MessageDialogButton = dlg.ShowModalWithin( self ) + + if btn is dlg.CancelButton then + IsScriptCancelled = true + end if + end if End Sub #tag EndEvent #tag Event Function Input(prompt As String) As String - dim dlg as new DlgInput - return dlg.ShowModalWithin( self, prompt ) + if not IsScriptCancelled then + dim dlg as new DlgInput + return dlg.ShowModalWithin( self, prompt ) + end if End Function #tag EndEvent #tag EndEvents diff --git a/XsEdit.xojo_project b/XsEdit.xojo_project index 2230964..1e31035 100644 --- a/XsEdit.xojo_project +++ b/XsEdit.xojo_project @@ -10,6 +10,7 @@ Folder=Windows;Windows;&h1B897FFF;&h0;false Folder=Dialogs;Dialogs;&h11A577FF;&h0;false Toolbar=TBEditor;Windows/TBEditor.xojo_toolbar;&h28F3D7FF;&h1B897FFF;false Folder=Classes;Classes;&h8E0CFFF;&h0;false +Class=XsEditCustomEditField;Classes/XsEditCustomEditField.xojo_code;&h5D9F9FFF;&h8E0CFFF;false Folder=Search Stuff;Search Stuff;&h758907FF;&h0;false Window=WndSearch;Search Stuff/WndSearch.xojo_window;&h43CF17FF;&h758907FF;false Class=SearchReceiverWindowBase;Search Stuff/SearchReceiverWindowBase.xojo_code;&h4F462FFF;&h758907FF;false @@ -115,13 +116,13 @@ Picture=systemrun3small;Images/system-run-3-small.png;&h4075DFFF;&h3F391FFF;fals Class=IDEEmulatorExtras;Classes/IDEEmulatorExtras.xojo_code;&h3EF787FF;&h8E0CFFF;false AppMenuBar=MainMenuBar MajorVersion=1 -MinorVersion=1 +MinorVersion=2 SubVersion=0 NonRelease=0 Release=3 InfoVersion=Advanced XojoScript editor -LongVersion=v.1.1. ©2015 by Kem Tekinay and Jeremy Cowgar. All rights reserved. -ShortVersion=1.1 +LongVersion=v.1.2. ©2015 by Kem Tekinay and Jeremy Cowgar. All rights reserved. +ShortVersion=1.2 WinCompanyName=MacTechnologies Consulting WinInternalName=XsEdit WinProductName=XsEdit