Jump to content

scite autocomplete for "incl" --> "#include <"


rudi
 Share

Recommended Posts

Hello,

I have no clue what to search for: Out of all PCs I come across doing autoit, there are two, where SciTE is doing the following auto complete, all others dont:

 

 

Type ...

incl<SPACE>

will become

#include <

... then when typing a part of the wanted standard include, the availabe ones are listed in a selection list.

 

typing "file" will bring up

 

<file.au3>

<fileconstants.au3>

 

What SciTE option is that?

Autoit v3.3.14.5 and latest SciTE on all boxes.

 

regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers
37 minutes ago, rudi said:

incl<SPACE>

This is part of the standard abbreviation functionality of SciTE, which I have modified to be activated when a space is hit by means of a LUA script. This will only work when the Abbreviation is in the abbrev.properties file, opened by Options/Open Abbreviations file, which actually only has 2 entries:

import au3abbrev
import au3UserAbbrev

All these 3 files are located at the same location as where you opened the abbrev.properties from. This will allow for the standard abbreviation expansion Ctrl+B.

The Space option will only work when the typed abbreviation is part of  the au3.keywords.abbreviations.propterties file and also turns red when typed with the standard color scheme. 

47 minutes ago, rudi said:

typing "file" will bring up
<file.au3>
<fileconstants.au3>

This is also an addition I have build and is part of AutoItAutoComplete.lua and uses file includes.txt also present in the same directory as the previous defined files.
 

So it looks like the SciteUserHome directory is missing some of these files on the pc's you have issues with ....or...  they do not use the full version with all the extra's.

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

There is also one another posible reason. There is instaled old SciTE4AutoIt version. 

Edit: Sorry for my English.. typing on phone with Polish dictionary..

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Thanks for your replies to both of you.

 

@Jos Thanks for that feature, it's saving me such a lot of time! BTW: Is that coverd in the HelpFiles? If so, I missed it.

 

At one of the installations the "incl" is expanded, but the available include files were not showing up in a drop down selection. After copying over missing the includes.txt from another PC, that feature worked immediatly, even no SciTE restart was required.

  • What Process is "doing" the file %localappdata%\AutoIt v3\SciTE\includes.txt
  • Is it possible to put in other includes with there full path into that file, so that they will be expanded like...
  • #include "\\server\share\Autoit\UDF\dbg.au3"

All PCs have the latest Autoit and SciTE installed, and I'm not aware of having modified any settings manually for the boxes, it's working fine, I'll check.

 

Another thing that shows up for some PCs is, that the typed letters *DO* turn red (so they are "noticed", that they *COULD* be expanded, eg incl  for "#include <" or mb for "MsgBox()"), but a SPACE doesn't "expand" the red text.

 

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers
1 hour ago, rudi said:

What Process is "doing" the file %localappdata%\AutoIt v3\SciTE\includes.txt

The installer runs this commandline at the end of the install process: ExecWait '"$INSTDIR\..\AutoIt3.exe" "$INSTDIR\SciTEConfig\SciTEConfig.au3" /Installer'
This does several things of which one is doing the creation of the includes.txt based on all files available in Autoit3\Includes.
This process is also triggered when pressing the Save&Update button in SciTEConfig.

1 hour ago, rudi said:

Is it possible to put in other includes with there full path into that file, so that they will be expanded like...

Not easily other than adding them to the standard directory, which has the risk of being scratched when doing an uninstall.
.. but anything is possible when you put your mind to it. ;)

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

@Jos

thanks for your reply. "SciTE Config" --> "save + apply" worked nicely, thx.

I don't want to put a copy of these "global UDF includes" to some local directory. When modified on the server, the local copy won't be updated, too.

 

I've found, that you've implemented the 1st part of my request already, incll:

 

# Directives
include=#include <|\n
incl=#include <|\n
incll=#include "|.au3"\n

 

As I didn't get the full mechanism, you used to offer this dropdown selection list, ...

 

image.png.63bdde95d34f28976f44d408c9f4976d.png

 

I'd like to ask, howto create some list for the UDFs stored on the server, so that they will be displayed as above, e.g. typing "d" will look like this in the list ...

incll --> #include "

typing "d" will be "pre-expanded" to...

H:\Data\batch\autoit3\snippets\Dbg.au3"
H:\Data\batch\autoit3\snippets\DriveGetAllSerials.au3"
H:\Data\batch\autoit3\snippets\DatumZeitPrefixForFileNaming.au3"

Rudi.

 

<edit: Typo, Grammar>

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers

Thought I had already answered/described that. The lua function is using the file includes.txt and that is what is used for that drop-down box as input. So you either have to add them to includes.txt or adapt the lua functionality.

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

Hello Jos,

 

yes, I've got that for "incl" --> "#Include <" --> dorpdown selection list, taken from includes.txt

What I cannot see so far, in "include.txt" there are only the file names listed, but the autocomplete function automatically adds a "closing >" behind the names of the include file's names.

 

I don't get it for "incll" --> #include ".AU3", from au3abbrev.properties, as that one does not use the file include.txt
I guess, that some extra file for the "expand list" is required. Best would be to place this on the server as well...

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

I looked into "C:\Program Files (x86)\AutoIt3\SciTE\lua\AutoItAutoComplete.lua", trying to just get an idea, how all this stuff works, and howto "modify a clone" for the "incl" --> #include <selection-list from include.txt> to get the same behavior for INCLL as well.

 

Is that the right place to search?

 

So far I don't get it at all... :'(

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers

That is the correct LUA script. In this Function:

function AutoItAutoComplete:OnChar(c)

.. there is a section that does this:

-- Show Includes dropdown after #include<
        local style = editor.StyleAt[editor:WordStartPosition(editor.CurrentPos, true)]
        curline = editor:GetCurLine()
        if (curline:match("^%s*#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]%s*<"))
        or (curline:match("^%s*#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]%s*") and c == "<")  then
            -- don't popup after closing ">"
            if (curline:match("<.*>"))  then
                return true
            end
            local pos = editor.CurrentPos
            local startPos = editor:WordStartPosition(pos, true)
            local len = pos - startPos
            local IncludeNames
            names = {}
            --Load Include table
            f = io.open(props['SciteUserHome'].."\\includes.txt")
            if f ~= nil then
                IncludeNames = f:read('*a')
                f:close()
                local prefix = string.sub(editor:textrange(startPos, pos),1,len)
                for word in string.gmatch(IncludeNames, "[%a_][%w_.]+") do
                    if string.lower(string.sub(word,1,len)) == string.lower(prefix) then
                        table.insert(names, word..">")
                    end
                end
            end
            --
            editor:AutoCShow(len,table.concat(names, " "))
            return true
        end

It simply gets the current line and checks whether it contains #include <  and if it does it will read the possible values from : props['SciteUserHome'].."\\includes.txt" and insert that in table names.
At the end it will present that AutoComplete dropdownbox by displaying the names table: editor:AutoCShow(len,table.concat(names, " "))

As simple as that ;)

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

I tried to modify the section for "#include <" to cover "full-path-au3", if I got that correctly, it should be done this way:

  • includes in the default include directory have to be specified as "#include <filename.au3>"
  • Includes in the script dir are specified as '#include "filename.au3" '
  • Includes in other locations have to be addressse as ' #include "\\server\share\path\filename.au3" '

 

So it will be required, to "ESCAPE" the doulbe qoutes ' " ' in the replace syntax. This one doesn't seem to work, I tried to use ' \" ' to ESCAPE the double quotes:

 

Instead of the full path as specified below I tried as well to use "\\" instead of "\", that's not correct as well?

-- Show Includes dropdown after #include"
        local style = editor.StyleAt[editor:WordStartPosition(editor.CurrentPos, true)]
        curline = editor:GetCurLine()
        if (curline:match("^%s*#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]%s*\""))
        or (curline:match("^%s*#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]%s* ") and c == "\"")  then
            -- don't popup after closing ">"
            if (curline:match("\".*\""))  then
                return true
            end
            local pos = editor.CurrentPos
            local startPos = editor:WordStartPosition(pos, true)
            local len = pos - startPos
            local IncludeNames
            names = {}
            --Load Include table
            f = io.open("h:\daten\private\sysop\netz\batch\autoit\My-Snippets.txt")
            if f ~= nil then
                IncludeNames = f:read('*a')
                f:close()
                local prefix = string.sub(editor:textrange(startPos, pos),1,len)
                for word in string.gmatch(IncludeNames, "[%a_][%w_.]+") do
                    if string.lower(string.sub(word,1,len)) == string.lower(prefix) then
                        table.insert(names, word.."\"")
                    end
                end
            end
            --
            editor:AutoCShow(len,table.concat(names, " "))
            return true
        end

It seems to do something, at least when typing #include "     I do see just flashing once an "empty list", vanishing immediately again.

image.png.8267075968dd0ee3015dd70a611e35d7.png

For the other question I'll place a separate posting.

 

Regards, Rudi.

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Testing with the file file %localappdata%\AutoIt v3\SciTE\includes.txt I fail to specify strings containing the chars : and \

 

abc123.au3
B:\cdefg.au3
C\:au3
D\:\\test.au3
AD.au3

in SciTE I see this result:

image.png.192e44dc2d36a4867539873a6f109ab7.png

 

edit -- added:

Looks like "\\" is doing some kind of LINEBREAK?

 

B:\cdefg.au3
C\:au3
D\:\\server\\path\\test.au3
AD.au3
...

image.png.999618bd0b8c40a71c2d7e3ebca9478f.png

 

 

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

  • Developers

This is mainly LUA stuff that is bothering you. I don't have much time in the coming 2 weeks to do any testing/playing myself .... sorry
The SciTE helpfile contains the LUA manual and there is also lots of info available on the internet.

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

  • Developers

Thinking about this for a little longer I can see all kinds of challenges with your wish.
The directory/path in front of the include will give these challenges as AutoCshow currently assumes a filter of the characters typed in SciTE after <. So you would need to type the whole path to filter them properly. 
Getting them added to the table is possible by changing this line:

                for word in string.gmatch(IncludeNames, "[%a_\\/][%w_.\\/]+") do
This will allow backslash and slash in the table entries.

Open the Helpfile and type AutoCshow in the search option and select Lua interface to see the details of the command options for AutoC??????

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

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...