Jump to content

Lua for Scite


 Share

Recommended Posts

I've been wanting to  be able to select text in my AutoIT script (editing in Scite) and change it to uppercase.

I found:

http://lua-users.org/wiki/UsingLuaWithScite

That guides how to do it (and generally how to add Lua commands to the Tools menu) but perhaps because the Scite is flavoured for AutoIT, even the simplest example fails.

For example, it says:

Quote

Here is a simple example; put this in your properties file (could be local,user or global):

 


command.name.1.*=Load Lua
command.subsystem.1.*=3
command.1.*=dofile $(FilePath)

You will now have a menu item called 'Load Lua' on the Tools menu

OK ... so to test this, I created SciTEUser.properties (attached) with the commands above and placed it in the same folder as the existing SciTEGlobal.properties and opened up my AutoIT script.

Disappointingly, I couldn't find 'Load Lua' on the Tools menu ... any ideas how to make it all happen please?

I also tried:

Quote

Put this in a Lua file (say test.lua) in your home directory

 


function make_uppercase()
  local sel = editor:GetSelText()
  editor:ReplaceSel(string.upper(sel))
end

and in your properties file, put this

 


ext.lua.startup.script=$(SciteUserHome)/test.lua

command.name.12.*=Make Selection Uppercase
command.subsystem.12.*=3
command.12.*=make_uppercase
command.mode.12.*=savebefore:no
command.shortcut.12.*=Ctrl+M

Now, after selecting text, you can make it uppercase with Ctrl+M.

with same failure, but it's this one I'd like to get working somehow.

SciTEUser.properties

Link to comment
Share on other sites

  • Developers
13 minutes ago, Tippex said:

I've been wanting to  be able to select text in my AutoIT script (editing in Scite) and change it to uppercase.

What about simply using Ctrl+Shift+u to make the selected text uppercase?

-or else when you want your own lua functions simply add them to PersonalTools.lua located in the same directory as SciTEUser.properties.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Dont know how your german is, but AutoIt.de has a LUA section with lots of info and startup "guide", i dont use it myself though.

Use some online translator, maybe your browser have it built in.

Info thread...

https://autoit.de/index.php?thread/26871-lua-ich-wir-lerne-n/

The subforum itself

https://autoit.de/index.php?board/56-lua/

Alot of info on SciTe and LUA.

Edited by Werty

Some guy's script + some other guy's script = my script!

Link to comment
Share on other sites

  • 2 weeks later...
On 8/30/2019 at 10:08 AM, Jos said:

Ctrl+Shift+u

Thanks Jos ... works perfectly.

Ctrl+u to lowercase apparently.

I did search the Keyboard shortcuts in Scite help, but these appear to be missing?

I haven't tried "PersonalTools.lua" but very useful to know.

- Thanks to Werty also ... I'll try Google translating it if I get a requirement for LUA again,

 

Edited by Tippex
noted that Ctrl+u lowercases in case useful for others.
Link to comment
Share on other sites

2 hours ago, Tippex said:

I did search the Keyboard shortcuts in Scite help, but these appear to be missing?

Here a script that may help you (and others) to find the shortcuts stored in different locations (you will also find Ctrl+Shift+U -> see 4.).  

Global $sPrefix = StringTrimRight(@AutoItExe, 11)
Global $sAu3Prop, $sGlobalProp, $sUserProp, $sFile, $aMatch, $sResult

; 1. Read shortcuts from au3.properties :
$sAu3Prop = $sPrefix & 'SciTE\properties\au3.properties'
$sResult  = ''
ConsoleWrite ('-------- Shortcuts from au3.properties ---------- ' & @CRLF)
$sFile   = FileRead($sAu3Prop)
For $i = 0 To 49
    $aMatch = StringRegExp($sFile, 'command\.shortcut\.' & $i & '\.\$\(au3\)=(.+)', 1)
    If IsArray($aMatch) Then
        $sResult &= $aMatch[0] & '|'
        $aMatch = StringRegExp($sFile, 'command\.name\.' & $i & '\.\$\(au3\)=(.+)', 1)
        $sResult &= $aMatch[0] & @CRLF
    EndIf
Next
ConsoleWrite($sResult & @CRLF)


; 2. Read shortcuts from SciTEGlobal.properties :
$sGlobalProp = $sPrefix & 'SciTE\SciTEGlobal.properties'
$sResult = ''
ConsoleWrite ('-------- Shortcuts from SciTEGlobal.properties ---------- ' & @CRLF)
$sFile = FileRead($sGlobalProp)
$aMatch = StringRegExp($sFile, '(?m)user\.shortcuts=([^# ]+)', 1)
If IsArray($aMatch) Then
    $sResult = StringRegExpReplace(StringRegExpReplace($aMatch[0], '\|?\\', ''), '\|$', '')
EndIf
ConsoleWrite($sResult & @CRLF)


; 3. Read shortcuts from SciTEUser.properties :
; Info :
; A modified version of the SciTEUser.properties may be located in another folder,
; i.e. @LocalAppDataDir\SciTE\SciTEUser.properties

;~ $sUserProp = $sPrefix & 'SciTE\SciTEUser.properties'
$sUserProp = @LocalAppDataDir & '\AutoIt v3\SciTE\SciTEUser.properties' ;
$sResult = ''
ConsoleWrite ('-------- Shortcuts from SciTEUser.properties ---------- ' & @CRLF)
$sFile = FileRead($sUserProp)
If @error Then
    ConsoleWrite ('! File not found : ' & $sUserProp & @CRLF)
Else
    $aMatch = StringRegExp($sFile, '(?m)user\.shortcuts=([^# ]+)', 1)
    If IsArray($aMatch) Then
        $sResult = StringRegExpReplace(StringRegExpReplace($aMatch[0], '\|?\\', ''), '\|$', '')
        ConsoleWrite($sResult & @CRLF)
    Else
        ConsoleWrite ('! No shortcuts found. Use another folder' & @CRLF & @CRLF)
        $sResult = ''
    EndIf
EndIf

; 4. From the SciTERes.rc (just a list) : (Menu | Action | Shortcut)
ConsoleWrite ('-------- Shortcuts from SciTERes.rc ---------- ' & @CRLF)
ConsoleWrite ('File | New | Ctrl+N' & @CRLF)
ConsoleWrite ('File | Open... | Ctrl+O' & @CRLF)
ConsoleWrite ('File | Open Selected Filename | Ctrl+Shift+O' & @CRLF)
ConsoleWrite ('File | Revert | Ctrl+R' & @CRLF)
ConsoleWrite ('File | Close | Ctrl+W' & @CRLF)
ConsoleWrite ('File | Save | Ctrl+S' & @CRLF)
ConsoleWrite ('File | Save As... | Ctrl+Shift+S' & @CRLF)
ConsoleWrite ('File | Save a Copy... | Ctrl+Shift+P' & @CRLF)
ConsoleWrite ('Export | Print... | Ctrl+P' & @CRLF)
ConsoleWrite ('Edit | Undo | Ctrl+Z' & @CRLF)
ConsoleWrite ('Edit | Redo | Ctrl+Y' & @CRLF)
ConsoleWrite ('Edit | Cut | Ctrl+X' & @CRLF)
ConsoleWrite ('Edit | Copy | Ctrl+C' & @CRLF)
ConsoleWrite ('Edit | Paste | Ctrl+V' & @CRLF)
ConsoleWrite ('Edit | Duplicate | Ctrl+D' & @CRLF)
ConsoleWrite ('Edit | Select All | Ctrl+A' & @CRLF)
ConsoleWrite ('Edit | Match Brace | Ctrl+E' & @CRLF)
ConsoleWrite ('Edit | Select to Brace | Ctrl+Shift+E' & @CRLF)
ConsoleWrite ('Edit | Show Calltip | Ctrl+Shift+Space' & @CRLF)
ConsoleWrite ('Edit | Complete Symbol | Ctrl+I' & @CRLF)
ConsoleWrite ('Edit | Complete Word | Ctrl+Enter' & @CRLF)
ConsoleWrite ('Edit | Expand Abbreviation | Ctrl+B' & @CRLF)
ConsoleWrite ('Edit | Insert Abbreviation | Ctrl+Shift+R' & @CRLF)
ConsoleWrite ('Edit | Block Comment or Uncomment | Ctrl+Q' & @CRLF)
ConsoleWrite ('Edit | Box Comment | Ctrl+Shift+B' & @CRLF)
ConsoleWrite ('Edit | Stream Comment | Ctrl+Shift+Q' & @CRLF)
ConsoleWrite ('Edit | Make Selection Uppercase | Ctrl+Shift+U' & @CRLF)
ConsoleWrite ('Edit | Make Selection Lowercase | Ctrl+U' & @CRLF)
ConsoleWrite ('Search | Find... | Ctrl+F' & @CRLF)
ConsoleWrite ('Search | Find Previous | Shift+F3' & @CRLF)
ConsoleWrite ('Search | Find in Files... | Ctrl+Shift+F' & @CRLF)
ConsoleWrite ('Search | Replace... | Ctrl+H' & @CRLF)
ConsoleWrite ('Search | Incremental Search... | Ctrl+Alt+I' & @CRLF)
ConsoleWrite ('Search | Selection Add Next | Ctrl+Shift+D' & @CRLF)
ConsoleWrite ('Search | Go to... | Ctrl+G' & @CRLF)
ConsoleWrite ('Search | Previous Bookmark | Shift+F2' & @CRLF)
ConsoleWrite ('Search | Toggle Bookmark | Ctrl+F2' & @CRLF)
ConsoleWrite ('View | Whitespace | Ctrl+Shift+8' & @CRLF)
ConsoleWrite ('View | End of Line | Ctrl+Shift+9' & @CRLF)
ConsoleWrite ('View | Parameters | Shift+F8' & @CRLF)
ConsoleWrite ('Tools | Compile | Ctrl+F7' & @CRLF)
ConsoleWrite ('Tools | Clean | Shift+F7' & @CRLF)
ConsoleWrite ('Tools | Stop Executing | Ctrl+Break' & @CRLF)
ConsoleWrite ('Tools | Previous Message | Shift+F4' & @CRLF)
ConsoleWrite ('Tools | Clear Output | Shift+F5' & @CRLF)
ConsoleWrite ('Tools | Switch Pane | Ctrl+F6' & @CRLF)
ConsoleWrite ('Line End Characters | Change Indentation Settings... | Ctrl+Shift+I' & @CRLF)
ConsoleWrite ('Line End Characters | Use Monospaced Font | Ctrl+F11' & @CRLF)
ConsoleWrite ('Buffers | Previous | Shift+F6' & @CRLF)

BTW : Credits should go to @BugFix

I have only summarized the information from the german site into one script and added small enhancements ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

On 9/10/2019 at 6:45 PM, Musashi said:

Here a script that may help you (and others) to find the shortcuts stored in different locations

Excellent, thank you & @BugFix 

-------- Shortcuts from au3.properties ---------- 
Alt+F5|Beta Run
Alt+F7|Beta Compile
Alt+F1|Beta Help
Ctrl+F5|SyntaxCheck Prod
Ctrl+Alt+F5|SyntaxCheck Beta
Ctrl+Shif+F6|AU3Info
Shift+F5|Test Run
Shift+F7|Test Compile
Ctrl+T|Tidy AutoIt Source
Alt+W|CodeWizard
Alt+m|Koda(FormDesigner)
Ctrl+1|SciTe Config
Alt+Q|SciTE Jump
Ctrl+J|Jump to Function Prod
Ctrl+Alt+J|Jump to Function Beta
Ctrl+Shift+J|Jump Back
Alt+L|List Functions
Ctrl+F11|Toggle Override Font
Ctrl+Alt+B|Insert Bookmarked Line(s)
Ctrl+Shift+D|Debug to MsgBox
Alt+D|Debug to Console
Ctrl+Alt+Z|Debug Remove lines
Alt+Shift+D|DebugTrace: Comment ALL lines
Alt+Ctrl+D|DebugTrace: UnComment ALL lines
Alt+I|Open Include
Alt+Shift+I|Open Include Beta
Ctrl+Alt+H|Make UDF Header

-------- Shortcuts from SciTEGlobal.properties ---------- 

Ctrl+Shift+V|IDM_PASTEANDDOWN
Ctrl+PageUp|IDM_PREVFILE
Ctrl+PageDown|IDM_NEXTFILE
KeypadPlus|IDM_EXPAND
KeypadMinus|IDM_BLOCK_COMMENT
Ctrl+F1|IDM_HELP_SCITE

-------- Shortcuts from SciTEUser.properties ---------- 
! No shortcuts found. Use another folder

-------- Shortcuts from SciTERes.rc ---------- 
File | New | Ctrl+N
File | Open... | Ctrl+O
File | Open Selected Filename | Ctrl+Shift+O
File | Revert | Ctrl+R
File | Close | Ctrl+W
File | Save | Ctrl+S
File | Save As... | Ctrl+Shift+S
File | Save a Copy... | Ctrl+Shift+P
Export | Print... | Ctrl+P
Edit | Undo | Ctrl+Z
Edit | Redo | Ctrl+Y
Edit | Cut | Ctrl+X
Edit | Copy | Ctrl+C
Edit | Paste | Ctrl+V
Edit | Duplicate | Ctrl+D
Edit | Select All | Ctrl+A
Edit | Match Brace | Ctrl+E
Edit | Select to Brace | Ctrl+Shift+E
Edit | Show Calltip | Ctrl+Shift+Space
Edit | Complete Symbol | Ctrl+I
Edit | Complete Word | Ctrl+Enter
Edit | Expand Abbreviation | Ctrl+B
Edit | Insert Abbreviation | Ctrl+Shift+R
Edit | Block Comment or Uncomment | Ctrl+Q
Edit | Box Comment | Ctrl+Shift+B
Edit | Stream Comment | Ctrl+Shift+Q
Edit | Make Selection Uppercase | Ctrl+Shift+U
Edit | Make Selection Lowercase | Ctrl+U
Search | Find... | Ctrl+F
Search | Find Previous | Shift+F3
Search | Find in Files... | Ctrl+Shift+F
Search | Replace... | Ctrl+H
Search | Incremental Search... | Ctrl+Alt+I
Search | Selection Add Next | Ctrl+Shift+D
Search | Go to... | Ctrl+G
Search | Previous Bookmark | Shift+F2
Search | Toggle Bookmark | Ctrl+F2
View | Whitespace | Ctrl+Shift+8
View | End of Line | Ctrl+Shift+9
View | Parameters | Shift+F8
Tools | Compile | Ctrl+F7
Tools | Clean | Shift+F7
Tools | Stop Executing | Ctrl+Break
Tools | Previous Message | Shift+F4
Tools | Clear Output | Shift+F5
Tools | Switch Pane | Ctrl+F6
Line End Characters | Change Indentation Settings... | Ctrl+Shift+I
Line End Characters | Use Monospaced Font | Ctrl+F11
Buffers | Previous | Shift+F6

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...