Sign in to follow this  
Followers 0
mr_unreliable

Streamlining The Scite Menus...

7 posts in this topic

hi gang,

I would like to simplify the SciTE tools and options menus.

The reason is that I only have a 17in screen, and the menus are longer

then my screen height, making navigation somewhat cumbersome.

On the tools menu, there are a number of autoit tools included

that I am probably not going to use, at least for a while until I

get to be more proficient.

I can see these "tools" spelled out as "command" parameters

in the au3.properties file.

I can imagine that I could rebuild the au3.properties file to suit

my purposes, but that means re-building for each new release.

Is there an easier way?

What I would like to see is a way to modify the SciTEUser.properties

file, to change the tools menu, keeping some tools and elimination

others. That way, I only have to worry about changing ONE properties

file for each new release.

Moving on, there is also the "options" menu, which includes menu

items for a (great) number of languages, most of which I don't use.

I found the listing of the languages in the SciTEGlobal.properties

file, and "commented-out" the languages that I don't use.

Considering that involves yet another file that I don't wish to modify

for every new release -- my question is: is there any way to make

those changes in the SciTEUser.properies file. That is, can one take

out those languages listed in the "options" menu via the SciTEUser.props

file?

Thanks in advance for any help, jw

Share this post


Link to post
Share on other sites



I can imagine that I could rebuild the au3.properties file to suit

my purposes, but that means re-building for each new release.

Totaly agree with you. Breaking the menues up a bit would be nice (sub menus?).

But I think your best bet is to to the modifications by hand and keep a copy of your au3.properties file. Or create a autoit utility that gives you a option list and a means of selecting those you want. This goes for the language files as well :think:

Share this post


Link to post
Share on other sites

Totaly agree with you. Breaking the menues up a bit would be nice (sub menus?).

But I think your best bet is to to the modifications by hand and keep a copy of your au3.properties file. Or create a autoit utility that gives you a option list and a means of selecting those you want. This goes for the language files as well :think:

We supply the standard SciTE build which doesn't have this option.

A simple way of getting rid of functions in the list you don't want to see without having to do that after every update is to add this to SciTEUSer.properties:

command.name.??.$(file.patterns.au3)=

command.name.??.$(file.patterns.au3)=


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Is there an easier way?

Why not script it.

I execute this from a Scite sub directory to disable Au3.properties tools. (AutoIt Beta needed)

Opt('TrayIconDebug', 1)

#include <GuiConstants.au3>
Global $file_au3properties = @ScriptDir & '\..\au3.properties'

SciteToolsSelector($file_au3properties)

Func SciteToolsSelector($file_au3properties, $debug = 0)
    Local $button_cancel, $button_update, $check, $checkbox, $checkbox_text
    Local $comment, $done, $file_temp, $handle_read, $handle_write
    Local $i, $line, $split, $total, $vertical_spacing
    $comment = '#~ '
; Open Au3.properties for Read
    $handle_read = FileOpen($file_au3properties, 0)
    If $handle_read = -1 Then
        MsgBox(0x42010, Default, 'Unable to open for read ' & $file_au3properties)
        Exit
    EndIf
; Read Tools headers from Au3.properties
    While True
        $line = FileReadLine($handle_read)
        If @error Then ExitLoop
        $line = StringStripWS($line, 3)
        If Not $line Then
            ContinueLoop
        ElseIf StringRegExp($line, '#~ # [0-9]{1,2}') Or StringRegExp($line, '# [0-9]{1,2}') Then
            $total &= $line & '|'
        EndIf
    WEnd
    FileClose($handle_read)
; Remove last pipe char
    If StringRight($total, 1) = '|' Then
        $total = StringTrimRight($total, 1)
    EndIf
; Split Tools headers into an Array
    $split = StringSplit($total, '|')
    If Not @error Then
; Display Tools headers in a Gui
        Local $checkbox[$split[0] + 1]
        GUICreate('Scite4AutoIt3 Tools Selector', 400, UBound($checkbox) * 18, -1, -1, $WS_DLGFRAME)
        For $i = 1 To $split[0]
            $vertical_spacing = $i * 17
            If StringLeft($split[$i], 3) = $comment Then
                $checkbox_text = StringTrimLeft($split[$i], 5)
                $checkbox[$i] = GUICtrlCreateCheckbox($checkbox_text, 10, $vertical_spacing)
                GUICtrlSetState($checkbox[$i], $GUI_UNCHECKED)
            Else
                $checkbox_text = StringTrimLeft($split[$i], 2)
                $checkbox[$i] = GUICtrlCreateCheckbox($checkbox_text, 10, $vertical_spacing)
                GUICtrlSetState($checkbox[$i], $GUI_CHECKED)
            EndIf
        Next
        $button_update = GUICtrlCreateButton('Up&date', 10, 0, 185, 20)
        $button_cancel = GUICtrlCreateButton('C&ancel', 205, 0, 185, 20)
    EndIf
    GUISetState()
;
    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $button_cancel
                Exit
            Case $button_update
                ExitLoop
        EndSwitch
    WEnd
; Process Au3.properties with selections made
    $file_temp = _TempFile()
    $handle_read = FileOpen($file_au3properties, 0)
    If $handle_read = -1 Then
        MsgBox(0x42010, Default, 'Unable to open for read ' & $file_au3properties)
        Exit
    EndIf
    $handle_write = FileOpen($file_temp, 2)
    If $handle_read = -1 Then
        MsgBox(0x42010, Default, 'Unable to open for write ' & $file_temp)
        FileClose($handle_read)
        Exit
    EndIf
;
    While True
        $line = FileReadLine($handle_read)
        If @error Then ExitLoop
        $line = StringStripWS($line, 3)
        Switch $line
            Case '', '#'
        ; Write line then loop again
                FileWriteLine($handle_write, $line)
                ContinueLoop
            Case '# Standard LUA Functions', 'extension.$(file.patterns.au3)=$(SciteDefaultHome)\AutoIt3.lua'
        ; Write line then loop again
                FileWriteLine($handle_write, $line)
                ContinueLoop
            Case '# Commands to for Help F1'
        ; After help line shows, then just write the rest of the file
                FileWriteLine($handle_write, $line)
                While 1
                    $line = FileReadLine($handle_read)
                    If @error Then ExitLoop 2
                    FileWriteLine($handle_write, $line)
                WEnd
                ExitLoop
        EndSwitch
        Switch StringRegExp($line, '##? [0-9]{1,2}')
            Case True
        ; Found a Tools line so enable or disable it
                $done = True
                For $i = 1 To $split[0]
                    If StringInStr($line, $split[$i]) Then
                        Select
                            Case StringLeft($line, 3) = $comment And GUICtrlRead($checkbox[$i]) = $GUI_CHECKED
                                $line = StringTrimLeft($line, 3)
                                $check = -1
                            Case StringLeft($line, 3) = $comment And GUICtrlRead($checkbox[$i]) = $GUI_UNCHECKED
                                $check = 0
                            Case StringLeft($line, 3) <> $comment And GUICtrlRead($checkbox[$i]) = $GUI_UNCHECKED
                                $line = $comment & $line
                                $check = 1
                            Case StringLeft($line, 3) <> $comment And GUICtrlRead($checkbox[$i]) = $GUI_CHECKED
                                $check = 0
                        EndSelect
                        ExitLoop
                    EndIf
                Next
            Case Else
        ; Command lines for Tools which are enabled or disabled
                If $done Then
                    If $check = -1 Then
                ; Trim comment
                        While StringLeft($line, 3) = $comment
                            $line = StringTrimLeft($line, 3)
                        WEnd
                    ElseIf $check = 1 Then
                ; Add comment
                        While Not (StringLeft($line, 3) = $comment)
                            $line = $comment & $line
                        WEnd
                    EndIf
                EndIf
        EndSwitch
        FileWriteLine($handle_write, $line)
        If $debug Then ConsoleWrite($check & @TAB & $line & @TAB & @ScriptLineNumber & @LF)
    WEnd
;
    FileClose($handle_read)
    FileClose($handle_write)
    Sleep(100)
    FileMove($file_temp, $file_au3properties, 1)
    FileDelete($file_temp)
EndFunc

Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7)
    Local $s_TempName
    If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir
    If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir
    If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\"
    Do
        $s_TempName = ""
        While StringLen($s_TempName) < $i_RandomLength
            $s_TempName = $s_TempName & Chr(Random(97, 122, 1))
        WEnd
        $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension
    Until Not FileExists($s_TempName)
    Return ($s_TempName)
EndFunc
Edited by MHz

Share this post


Link to post
Share on other sites

command.name.??.$(file.patterns.au3)=

command.name.??.$(file.patterns.au3)=

Thanks, I'll try it.

cheers, jw

Share this post


Link to post
Share on other sites

Why not script it.

I'm impressed "MHz".

I tried it and it works.

Did you have that one in inventory, or did you just write up 160 lines of code

as a public service???

One of my concerns was that the "command.name.xx" numbers had to be

sequential. But apparently not.

My only suggestion would be to make a backup file before modifying the original.

But then, I wasn't testing against the original file myself. Would that indicate

a lack of total faith in your code? I decline to answer on the grounds that

it may tend to incriminate me.

cheers, jw

Share this post


Link to post
Share on other sites

I'm impressed "MHz".

I tried it and it works.

Did you have that one in inventory, or did you just write up 160 lines of code

as a public service???

It is a recent script from the inventory. I normally have used the idea as JdeB mentions of blocking in the user.properties file. The blocking method does consume alot your user.properties file so I wanted a "stop it at the source" method. Indeed, the script does work.

One of my concerns was that the "command.name.xx" numbers had to be

sequential. But apparently not.

The numbers are just used as the difference between each header, of each tool.

My only suggestion would be to make a backup file before modifying the original.

But then, I wasn't testing against the original file myself. Would that indicate

a lack of total faith in your code? I decline to answer on the grounds that

it may tend to incriminate me.

Yes, a backup would sound good. When you updated Scite4AutoIt3, then you would have to manually replace the backup to ensure that you would have the latest. With the latter, you could be regarded as unwise, if you did not do a test first to gain faith.

It is still a prototype that needs a Gui that remains within a small screen area. I'm not sure of it's direction currently. Something like this would be nice in the main distribution of Scite4AutoIt3, but would need some refinements to suit.

:think:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0