purebasic icon indicating copy to clipboard operation
purebasic copied to clipboard

AutoComplete Full function

Open ChrisRfr opened this issue 2 years ago • 8 comments

AutoComplete Full function. On #WINDOW_AutoComplete list, use shorcut Shift+Tab (also used for un-indent) to insert the selected word with its quick help function.

ChrisRfr avatar Nov 03 '21 02:11 ChrisRfr

I wanted to do it like this but Shift+Tab is not allowed at the moment because it is used by Indent/Unindent. Shift+Tab seems however the most appropriate shortcuts, it's just used here for the AutoComplete Window. I don't know if it's good to allow Shift+Tab in settings or to leave it unconfigurable and hidden.

An interesting idea that could be behind this function, would be an autocomplete v2 function. A little like chi's Lazzycoder tool. For my part, I don't have the knowledge to do it AutoComplete2

ChrisRfr avatar Nov 06 '21 12:11 ChrisRfr

Well, since the other shortcuts are customizable (including the Tab for insert) having this one hardcoded is not a good idea. How do you know Shift+Tab is the most appropriate for other people's settings?

t-harter avatar Nov 07 '21 18:11 t-harter

The shortcut Shift+Tab is now configurable in the preferences. I'm not sure about the changes in CreateKeyboardShortcuts() procedure in ShortcutManagement.pb. Is it possible to check it.

ChrisRfr avatar Nov 13 '21 14:11 ChrisRfr

In reference To Pull Request #183: Context sensitive AutoComplete For PB constants For the AutoComplete Full function, it will be possible to write in comment the list of constants that apply to the function ex:

ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags]) ; #PB_Button_Right | #PB_Button_Left | #PB_Button_Default | #PB_Button_MultiLine | #PB_Button_Toggle

      If FullFunction And IsBasicFunction(UCase(String$)) <> -1
        index = IsBasicFunction(UCase(String$))
        ;String$ = BasicFunctions(index)\Name$
        If BasicFunctions(index)\Proto$
          String$ + StringField(BasicFunctions(index)\Proto$, 1, " - ")
; Addition Begin
          ; Write in comment the List of constants that apply For this Function ex:
          Fields = CountString(String$, ",") + 1
          *Context.AutoCompleteConstants = 0
          ; loop in case the flags are not at the last fields
          For f = 0 To Fields - 1
            ; Map has lowercase names and 1-based parameter index
            *Context.AutoCompleteConstants = FindMapElement(AutoComplete_ContextConstants(), LCase(BasicFunctions(index)\Name$) + "," + Str(Fields - f))
            If *Context
              Break
            EndIf
          Next f
          If *Context
            ForEach *Context\Constants()
              If ListIndex(*Context\Constants()) > 0
                String$ + " | " + *Context\Constants()
              Else
                String$ + " ; " + *Context\Constants()
              EndIf
            Next *Context\Constants()
          EndIf
; Addition End 
        Else
          String$ + "()"
        EndIf
      EndIf

To temporarily test it in "context-autocomplete" branch, in AutoComplete.pb, AutoComplete_Insert() procedure, add the above code after : "String$ = GetGadgetItemText(#GADGET_AutoComplete_List, index, 0)" and change "If FullFunction And IsBasicFunction(UCase(String$)) <> -1" to "If IsBasicFunction(UCase(String$)) <> -1"

ChrisRfr avatar Nov 20 '21 02:11 ChrisRfr

The interest is low for an advanced PureBasic developer. It is just to display the complete syntax to then modify the fields or copy/paste the constants in comments. Given the limited interest, the time I'm wasting you and the conflicts I cause with my friend GitHub. It is perhaps better to delete this branch or that I leave my hand. I wanted to help and participate but I fail. I'm disappointed but otherwise no worries, good continuation :)

ChrisRfr avatar Jan 11 '22 01:01 ChrisRfr

@Naheulf

Insérez à la fois le nom de la fonction et les paramètres ? Insert both the function name and the parameters ? German ? Fügen Sie sowohl den Namen der Funktion mit den Parametern ?

With functions, It seems to be a good formulation: +1 Then, I can't go any further on my side because of Deutsch/Editor.catalog encoding. I'm not sure how to do it right, between ISO-8859-1 and Github desktop which probably uses my French locale setting, as you. As @tajmone wrote, Encoding in UTF-8 would greatly help.

Also, the function will have its real interest once "Context sensitive AutoComplete for PB constants" #183 is committed and by adding the list of PB Constants in comment as done in this previous post.

ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags]) ; #PB_Button_Right | #PB_Button_Left | #PB_Button_Default | #PB_Button_MultiLine | #PB_Button_Toggle

As previously stated, this function remains of limited interest, it will probably not be used often. However, it may be of interest from time to time when using a function for the first time, for example, or to copy/paste the constants in comments, faster than writing #PB_ with auto-completion. Without complicating too much the current code, the arrays are there, it's just an assembly. It's up to Timo or Fred to choose whether it is worth adding or not.

ChrisRfr avatar Jan 12 '22 14:01 ChrisRfr

@ChrisRfr If you want to update your devel branch to the state of fantaisie-software:devel branch, use rebase instead of merge.

With rebase, Git will set your devel branch temporarily to the fantaisie-software:devel state, and then puts your new commits created in devel on top of the new devel. This keeps the commit history clean, without a merge commit.

To fix your devel branch, follow this instruction. Instead of branch-123 use your devel branch and instead of master use the fantaisie-software:devel branch.

SicroAtGit avatar Jan 13 '22 20:01 SicroAtGit

It's been a while and I still have the same problems with the Documentation Catalogs encoding. I am unable to participate. This Pull Request has really a limited interest, I propose to remove it.

ChrisRfr avatar Jun 10 '22 14:06 ChrisRfr