Smart templates with optional parameters and tooltips possible?

Smart templates with optional parameters and tooltips possible?

32
Basic UserBasic User
32

    Feb 20, 2013#1

    Okay going off of a suggestion made by Mofi, I made a smart template for AutoIt...a favorite scripting lang of mine.

    This largely works out fine for me in most cases...however I got some corner cases...where I feel things fail.

    Code: Select all

    ControlCommand ( "title", "text", "classnameNN", "IsVisible", "" )
    Returns 1 if Control is visible, 0 otherwise
    
    ControlCommand ( "title", "text", "classnameNN", "IsEnabled", "" )
    Returns 1 if Control is enabled, 0 otherwise
    
    ControlCommand ( "title", "text", "classnameNN", "ShowDropDown", "" )
    Drops a ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "HideDropDown", "" )
    Undrops a ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "AddString", 'string' )
    Adds a string to the end in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "DelString", occurrence )
    Deletes a string according to occurrence in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "FindString", 'string' )
    Returns occurrence ref of the exact string in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "SetCurrentSelection", occurrence )
    Sets selection to occurrence ref in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "SelectString", 'string' )
    Sets selection according to string in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "IsChecked", "" )
    Returns 1 if Button is checked, 0 otherwise
    
    ControlCommand ( "title", "text", "classnameNN", "Check", "" )
    Checks radio or check Button
    
    ControlCommand ( "title", "text", "classnameNN", "UnCheck", "" )
    Unchecks radio or check Button
    
    ControlCommand ( "title", "text", "classnameNN", "GetCurrentLine", "" )
    Returns the line # where the caret is in an Edit
    
    ControlCommand ( "title", "text", "classnameNN", "GetCurrentCol", "" )
    Returns the column # where the caret is in an Edit
    
    ControlCommand ( "title", "text", "classnameNN", "GetCurrentSelection", "" )
    Returns name of the currently selected item in a ListBox or ComboBox
    
    ControlCommand ( "title", "text", "classnameNN", "GetLineCount", "" )
    Returns # of lines in an Edit
    
    ControlCommand ( "title", "text", "classnameNN", "GetLine", line# )
    Returns text at line # passed of an Edit
    
    ControlCommand ( "title", "text", "classnameNN", "GetSelected", "" )
    Returns selected text of an Edit
    
    ControlCommand ( "title", "text", "classnameNN", "EditPaste", 'string' )
    Pastes the 'string' at the Edit's caret position
    
    ControlCommand ( "title", "text", "classnameNN", "CurrentTab", "" )
    Returns the current Tab shown of a SysTabControl32
    
    ControlCommand ( "title", "text", "classnameNN", "TabRight", "" )
    Moves to the next tab to the right of a SysTabControl32
    
    ControlCommand ( "title", "text", "classnameNN", "TabLeft", "" )
    Moves to the next tab to the left of a SysTabControl32
    
    ControlCommand ( "title", "text", "classnameNN", "SendCommandID", Command ID )
    Simulates the WM_COMMAND message. Usually used for ToolbarWindow32 controls - use the ToolBar tab of Au3Info to get the Command ID.
    Description changes based on params used...some params change based on other params.

    Is there a way to sync params, and maybe give a tooltip of sorts based on a param selected?

    Also in this scripting lang...not all params are required...is there a special way to mark optional params?

    Further given some are not required...is there a way to cause a cascade delete of further params with a key combo?

    6,675585
    Grand MasterGrand Master
    6,675585

      Feb 21, 2013#2

      Nologic wrote:Is there a way to sync params, and maybe give a tooltip of sorts based on a param selected?
      Smart templates are just for quickly inserting text snippets with or without parameters. This feature is not a language dependent IntelliSense feature. The user using the templates for a language must know the meaning. So tooltips for parameters are not possible. That's a typical IntelliSense feature of editors designed for a specific language.
      Nologic wrote:Also in this scripting lang...not all params are required...is there a special way to mark optional params?

      Further given some are not required...is there a way to cause a cascade delete of further params with a key combo?
      There is no possibility to define in a template optional parameters and handle them really optional on inserting the template. Of course a user inserting a smart templates with parameters can at any time stop entering the parameters and finish inserting the template. But every fixed text in the template is nevertheless inserted in this case.

      If there are various variants for example for a command, appropriate smart templates for most often needed variants should be defined with good names and perhaps also an appropriate description for the template. For example in HTML there are many attributes which can be applied to tables, table rows and table cells. But most often within a website not more than 3 to 10 different table layouts are used (otherwise the website is designed poorly). Creating smart templates for the 3 to 10 tables with good names for quick inserting them is what makes the smart templates feature so efficient. If it would be necessary to always fill in all available options for an entire table it would not make much sense to use smart templates feature at all.

      I suggest for your examples with the commands with multiple options, create a smart template with all optional parameters and some more with the parameters you usually really use very often. The goal with smart templates is reducing typing as much as possible.

      32
      Basic UserBasic User
      32

        Feb 23, 2013#3

        Mofi wrote:Smart templates are just for quickly inserting text snippets with or without parameters. This feature is not a language dependent IntelliSense feature. The user using the templates for a language must know the meaning. So tooltips for parameters are not possible. That's a typical IntelliSense feature of editors designed for a specific language.
        Well maybe it should be a feature request...as the tooltip/intellisense could be defined in the Smart Template XML.

        Code: Select all

        <?xml version="1.0"?>
        <Templates encode="utf8escenc">
        	<Template Name="Command"
        		Description="Some Text."
        		Comments="0"
        		Strings="0">
        		<Insert>Command( [+Value1|Value2|Value3+] , [+Param1|Param2|Param3+] )</Insert>
        		<ParameterTip Slot=1 Option="Value1">Some Text Tip 1</ParameterTip>
        		<ParameterTip Slot=1 Option="Value2">Some Text Tip 2</ParameterTip>
        		<ParameterTip Slot=1 Option="Value3">Some Text Tip 3</ParameterTip>
        		<ParameterTip Slot=2 Option="Param1">Some Other Text Tip 1</ParameterTip>
        		<ParameterTip Slot=2 Option="Param2">Some Other Text Tip 2</ParameterTip>
        		<ParameterTip Slot=2 Option="Param3">Some Other Text Tip 3</ParameterTip>
        	</Template>
        </Templates>
        

        Code: Select all

        <?xml version="1.0"?>
        <Templates encode="utf8escenc">
        	<Template Name="Opt"
        		Description="Changes the operation of various AutoIt functions/parameters."
        		Comments="0"
        		Strings="0">
        		<Insert>Opt( [+"CaretCoordMode"|"ExpandEnvStrings"|"ExpandVarStrings"|"GUICloseOnESC"|"GUICoordMode"|"GUIDataSeparatorChar"|"GUIOnEventMode"|"GUIResizeMode"|"GUIEventOptions"|"MouseClickDelay"|"MouseClickDownDelay"|"MouseClickDragDelay"|"MouseCoordMode"|"MustDeclareVars"|"PixelCoordMode"|"SendAttachMode"|"SendCapslockMode"|"SendKeyDelay"|"SendKeyDownDelay"|"TCPTimeout"|"TrayAutoPause"|"TrayIconDebug"|"TrayIconHide"|"TrayMenuMode"|"TrayOnEventMode"|"WinDetectHiddenText"|"WinSearchChildren"|"WinTextMatchMode"|"WinTitleMatchMode"|"WinWaitDelay"+] , [+param+] )</Insert>
        		<ParameterTip Slot=1 Option="CaretCoordMode">Sets the way coords are used in the caret functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window</ParameterTip>
        		<ParameterTip Slot=1 Option="ExpandEnvStrings">Changes how literal strings and % symbols are interpreted.  By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%". 1 = expand environment variables (similar to AutoIt v2) 0 = do not expand environment variables (default) Without this option the usual way would be: 	"The temp directory is: " & EnvGet("temp")</ParameterTip>
        		<ParameterTip Slot=1 Option="ExpandVarStrings">Changes how literal strings and variable/macro ($ and @) symbols are interpreted.  By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$". 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign". 0 = do not expand variables (default)</ParameterTip>
        		<ParameterTip Slot=1 Option="GUICloseOnESC">When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent.  This option toggles this behavior on and off. 1 = Send the $GUI_EVENT_CLOSE message when ESC is pressed (default). 0 = Don't send the $GUI_EVENT_CLOSE message when ESC is pressed.</ParameterTip>
        		<ParameterTip Slot=1 Option="GUICoordMode">Alters the position of a control defined by GUICtrlSetPos. 1 = absolute coordinates (default) still relative to the dialog box. 0 = relative position to the start of the last control (upper left corner). 2 = cell positioning relative to current cell. A -1 for left or top parameter don't increment the start. So next line is -1,offset; next cell is offset,-1; current cell is -1,-1. Obviously "offset" cannot be -1 which reserved to indicate the no increment. But if you can use a multiple of the width you choose to skip or go back.</ParameterTip>
        		<ParameterTip Slot=1 Option="GUIDataSeparatorChar">Define the character which delimits subitems in GUICtrlSetData. The default character is '|'.</ParameterTip>
        		<ParameterTip Slot=1 Option="GUIOnEventMode">Enable/disable OnEvent functions notifications. 0 = (default) disable. 1 = enable.</ParameterTip>
        		<ParameterTip Slot=1 Option="GUIResizeMode">Change default resizing for a control. 0 = (default) keep default control resizing. <1024 = anytype of resizing see GUICtrlSetResizing.</ParameterTip>
        		<ParameterTip Slot=1 Option="GUIEventOptions">Change special event behavior or GUI function return values. 0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize. 1 = suppress windows behavior on minimize, restore or maximize click button or window resize. Just sends the notification.</ParameterTip>
        		<ParameterTip Slot=1 Option="MouseClickDelay">Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10).</ParameterTip>
        		<ParameterTip Slot=1 Option="MouseClickDownDelay">Alters the length a click is held down before release. Time in milliseconds to pause (default=10).</ParameterTip>
        		<ParameterTip Slot=1 Option="MouseClickDragDelay">Alters the length of the brief pause at the start and end of a mouse drag operation. Time in milliseconds to pause (default=250).</ParameterTip>
        		<ParameterTip Slot=1 Option="MouseCoordMode">Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window</ParameterTip>
        		<ParameterTip Slot=1 Option="MustDeclareVars">If this option is used then all variables must be pre-declared with Dim, Local or Global before they can be used - removes the chance for misspelled variables causing bugs. 1 = Variables must be pre-declared 0 = Variables don't need to be pre-declared (default)</ParameterTip>
        		<ParameterTip Slot=1 Option="PixelCoordMode">Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the window defined by hwnd (default active window): 0 = relative coords to the defined window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the defined window</ParameterTip>
        		<ParameterTip Slot=1 Option="SendAttachMode">Specifies if AutoIt attaches input threads when using Send() function.  When not attaching (default mode=0) detecting the state of capslock/scrolllock and numlock can be unreliable under NT4.  However, when you specify attach mode=1 the Send("{... down/up}") syntax will not work and there may be problems with sending keys to "hung" windows.  ControlSend() ALWAYS attaches and is not affected by this mode. 0 = don't attach (default) 1 = attach</ParameterTip>
        		<ParameterTip Slot=1 Option="SendCapslockMode">Specifies if AutoIt should store the state of capslock before a Send function and restore it afterwards. 0 = don't store/restore 1 = store and restore (default)</ParameterTip>
        		<ParameterTip Slot=1 Option="SendKeyDelay">Alters the length of the brief pause in between sent keystrokes.  A value of 0 removes the delay completely. Time in milliseconds to pause (default=5).</ParameterTip>
        		<ParameterTip Slot=1 Option="SendKeyDownDelay">Alters the length of time a key is held down before being released during a keystroke.  For applications that take a while to register keypresses you may need to raise this value from the default.  A value of 0 removes the delay completely. Time in milliseconds to pause (default=5).</ParameterTip>
        		<ParameterTip Slot=1 Option="TCPTimeout">Defines the time before TCP functions stop if no communication. Time in milliseconds before timeout (default=100).</ParameterTip>
        		<ParameterTip Slot=1 Option="TrayAutoPause">Script pauses when click on tray icon. 0 = no pause 1 = pause (default). If there is no DefaultMenu no pause will occurs.</ParameterTip>
        		<ParameterTip Slot=1 Option="TrayIconDebug">If enabled shows the current script line in the tray icon tip to help debugging. 0 = no debug information (default) 1 = show debug</ParameterTip>
        		<ParameterTip Slot=1 Option="TrayIconHide">Hides the AutoIt tray icon.  Note:  The icon will still initially appear ~750 milliseconds. 0 = show icon (default) 1 = hide icon</ParameterTip>
        		<ParameterTip Slot=1 Option="TrayMenuMode">Extend the behaviour of the script tray icon/menu. This can be done with a combination (adding) of the following values. 0 = default menu items (Script Paused/Exit) are appended to the usercreated menu; usercreated checked items will automatically unchecked; if you double click the tray icon then the controlid is returned which has the "Default"-style (default). 1 = no default menu 2 = user created checked items will not automatically unchecked if you click it 4 = don't return the menuitemID which has the "default"-style in the main contextmenu if you double click the tray icon 8 = turn off auto check of radio item groups</ParameterTip>
        		<ParameterTip Slot=1 Option="TrayOnEventMode">Enable/disable OnEvent functions notifications for the tray. 0 = (default) disable 1 = enable</ParameterTip>
        		<ParameterTip Slot=1 Option="WinDetectHiddenText">Specifies if hidden window text can be "seen" by the window matching functions. 0 = Do not detect hidden text (default) 1 = Detect hidden text</ParameterTip>
        		<ParameterTip Slot=1 Option="WinSearchChildren">Allows the window search routines to search child windows as well as top-level windows. 0 = Only search top-level windows (default) 1 = Search top-level and child windows</ParameterTip>
        		<ParameterTip Slot=1 Option="WinTextMatchMode">Alters the method that is used to match window text during search operations. 1 = Complete / Slow mode (default) 2 = Quick mode In quick mode AutoIt can usually only "see" dialog text, button text and the captions of some controls.  In the default mode much more text can be seen (for instance the contents of the Notepad window). If you are having performance problems when performing many window searches then changing to the "quick" mode may help.</ParameterTip>
        		<ParameterTip Slot=1 Option="WinTitleMatchMode">Alters the method that is used to match window titles during search operations. 1 = Match the title from the start (default) 2 = Match any substring in the title 3 = Exact title match 4 = Advanced mode, see Window Titles & Text (Advanced) -1 to -4 = force lower case match according to other type of match.</ParameterTip>
        		<ParameterTip Slot=1 Option="WinWaitDelay">Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).</ParameterTip>
        	</Template>
        </Templates>
        
        Mofi wrote:There is no possibility to define in a template optional parameters and handle them really optional on inserting the template. Of course a user inserting a smart templates with parameters can at any time stop entering the parameters and finish inserting the template. But every fixed text in the template is nevertheless inserted in this case.

        If there are various variants for example for a command, appropriate smart templates for most often needed variants should be defined with good names and perhaps also an appropriate description for the template. For example in HTML there are many attributes which can be applied to tables, table rows and table cells. But most often within a website not more than 3 to 10 different table layouts are used (otherwise the website is designed poorly). Creating smart templates for the 3 to 10 tables with good names for quick inserting them is what makes the smart templates feature so efficient. If it would be necessary to always fill in all available options for an entire table it would not make much sense to use smart templates feature at all.

        I suggest for your examples with the commands with multiple options, create a smart template with all optional parameters and some more with the parameters you usually really use very often. The goal with smart templates is reducing typing as much as possible.
        Well my idea is that you would display all of them, then upon a key combo say ALT+Enter or something, optional parameters beyond where the cursor is are stripped. Markup in the template could be something like:

        Code: Select all

        <?xml version="1.0"?>
        <Templates encode="utf8escenc">
        	<Template Name="Command"
        		Description="Some Text."
        		Comments="0"
        		Strings="0">
        		Command( [+Value1|Value2|Value3+][? , [+1Param1|1Param2|1Param3+]?][? , [+2Param1|2Param2|2Param3+]?] )
        	</Template>
        </Templates>
        
        Where anything between [? ?] is optional...so if I was in slot 1 dealing with Value# and hit ALT+Enter the following two param entries are removed. If I was in 1Param# and did ALT+Enter then the last param would only get nuked.

        Anyways to bad some of this stuff isn't available at this time...and may never be...but would be cool...hehe might be a mild headache creating the smart templates like this but would give a bit more power.

        Course I didn't go over linking param slots to on another or suggested defaults...but some times its nice to day dream.

        Anyways Mofi thanks for your suggestion to use Smart Templates, I'm making good use of them...and thanks for taking the time to respond. :)

        4
        NewbieNewbie
        4

          Templates with select lists

          Nov 05, 2014#4

          Hi,

          very often when defining smart templates, I want to make really sure that a certain position in that text is only filled with certain predefined texts and nothing else - is there any way to really enforce this and prohibit any other input? I'm dreaming of something like [SELECT +prompt+option1|option2|option3] which would enable the user to select from a list.
          (Sure, after all UE is a text-editor and the user may edit anything, but I want to make sure that at least my templates create 100% correct results...)

          Thanks

          Michael

          6,675585
          Grand MasterGrand Master
          6,675585

            Re: Templates with select lists

            Nov 05, 2014#5

            This request is similar to what user Nologic wrote at above.

            It is not possible to define a smart template showing a list on inserting the template for some of the parameters in UE v21.30.0.1016. Your idea on definition of such a list is similar to what Nologic described.

            I suggest to do what Nologic most likely has already done, send a feature request email to IDM support. The more users request a feature, the higher becomes the priority for IDM Computer Solutions, Inc. to implement it in UltraEdit and UEStudio.
            Best regards from an UC/UE/UES for Windows user from Austria