Jump to content

like the SciTE editor


Recommended Posts

hi guy,

i have question. is it possible to make a context like in the scite editor. I mean if you write a word which beginns with the letter "a" then there will be come a context wit funktions.

look:

Funktions____________________________________________________

CAT

DOG

TIGER

MOUSE

HOURSE

RABBIT

Input____________________

now if i write in the input the letter "c" then it mus come a context with the word cat

i hope you understand.

thx

Link to comment
Share on other sites

  • Developers

yes thats right, but I mean , i want to add this funktion into my gui

:) you want to do...what ?

You mean you want to do the same as what SciTE does but then in your own EDIT control in your own GUI ?

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

You need sort of database to read from and compare the string to that data base, then use a simple child window with desired styles etc..

It's not a trivial task if you're trying to mimic the behavior of SciTE because may require to inspect whether, for example, the code is double on single quoted.

Edit:

lol maybe this horrible wanna be "IDE" can give you example.

Actually, if you can have a better understanding about SCIntilla notification, messages and structure you'll have a better tool in your hand, otherwise, rich edit control is also a good one but may be a pain, from my point of view:

#include <Constants.au3>
#include <EditConstants.au3>
#include <GuiListBox.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global Const $iWidth = 171, $iHeight = 150
Global $fVisible = False

Dim $sData = 'GUICreate;GUICtrlCreate;IsObj;IsHWND;Dec;DllCall;String;StringTrimLeft;ControlSend;ObjGet;ObjCreate;' & _
             'ObjName;Sleep;Eval;Hex;GUICtrlCreateListView;DllStructCreate;DllOpen;WinGetPos;GUICtrlSetData;Else;' & _
             'ElseIf;Switch;GUICtrlCreateButton;GUICtrlCreateInput;GUICtrlCreateProgress;GUICtrlCreateEdit;' & _
             'GUICtrlCreateComboBox;GUICtrlCreateAVI;'

Dim $sBuff = ''
Dim $hUser32 = DllOpen ('user32.dll')

Dim $hGUI = GUICreate ('Title', 400, 200)
Dim $Input = GUICtrlCreateEdit ('', 0, 0, 400, 200, BitOR($ES_MULTILINE, $ES_WANTRETURN, $ES_AUTOHSCROLL, $ES_AUTOVSCROLL))
             GUICtrlSetBkColor (-1, 0xF0F4F9)
             GUICtrlSetFont (-1, 11, 600, 2, 'Nina')
             GUICtrlSetColor(-1, 0x000090)
             
Dim $hChild = GUICreate('', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_CLIENTEDGE), $hGUI)
Dim $hList = _GUICtrlListBox_Create($hChild, '', -1, -1, $iWidth, $iHeight, BitOR($LBS_DISABLENOSCROLL, $LBS_HASSTRINGS, $LBS_SORT, $WS_VSCROLL, $WS_BORDER))

Dim $hInput_Handler = DllCallbackRegister ('Input_Handler', 'lparam', 'hwnd;uint;wparam;lparam')
    If 0 = $hInput_Handler Then Exit

Dim $hOldProc = _WinAPI_GetWindowLong (GUICtrlGetHandle ($Input), $GWL_WNDPROC)
_WinAPI_SetWindowLong (GUICtrlGetHandle ($Input), $GWL_WNDPROC, DllCallbackGetPtr ($hInput_Handler))

GUISetState(@SW_HIDE, $hChild)
GUISwitch($hGUI)
GUISetState()

Do
    Sleep (20)
Until GUIGetMsg() = -3


GUIDelete ($hGUI)
DllCallbackFree ($hInput_Handler)
DllClose ($hUser32)
Exit


Func Input_Handler ($hWnd, $uMsg, $wParam, $lParam)
    Local $Ret
    
    If $uMsg = $WM_CHAR Then
        Local $iX, $iY
        Local $tRECT
        
        $Ret = DllCall($hUser32, 'lparam', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_GETSEL, 'uint*', '', 'uint*', '')
        $Ret = DllCall($hUser32, 'lparam', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_POSFROMCHAR, 'int', $Ret[3]-1, 'lparam', 0)
        $tRECT = DllStructCreate('int nLeft;int nTop;int nRight;int nBottom')
        DllCall($hUser32, 'int', 'GetWindowRect', 'hwnd', $hWnd, 'ptr', DllStructGetPtr($tRECT))
        
        $iX = BitAND($Ret[0], 0x0000FFFF) + DllStructGetData($tRECT, 'nLeft')
        $iY = BitAND($Ret[0], 0xFFFF0000)/0x10000 + DllStructGetData($tRECT, 'nTop') + 25
        
        Switch $wParam
            Case 8 ; Backspace
                $sBuff = StringTrimRight($sBuff, 1)
                _SetTip($iX, $iY)   
                
            Case 13 ; Enter
                If $fVisible Then 
                    Local $iIndex = _GUICtrlListBox_GetCurSel($hList)
                    Local $sFunc = _GUICtrlListBox_GetText($hList, $iIndex)
                    
                    $Ret = DllCall($hUser32, 'lparam', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_GETSEL, 'uint*', '', 'uint*', '')
                        DllCall($hUser32, 'lparam', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_SETSEL, 'int', $Ret[3]-StringLen($sBuff), _
                        'int', $Ret[3])
                        DllCall($hUser32, 'lparam', 'SendMessage', 'hwnd', $hWnd, 'uint', $EM_REPLACESEL, 'int', True, 'str', $sFunc)
            
                    GUISetState(@SW_HIDE, $hChild)
                    $sBuff = ''
                    Return 0
                EndIf
                $sBuff = ''
                
            Case Else
                $sBuff &= Chr($wParam)
                _SetTip($iX, $iY)
        EndSwitch
    EndIf
   
    $Ret = DllCall ($hUser32, 'int', 'CallWindowProc', 'ptr', $hOldProc, 'hwnd', $hWnd, 'uint', _
                    $uMsg, 'wparam', $wParam, 'lparam', $lParam)
    If Not @error Then Return $Ret[0]
EndFunc


Func _SetTip($iLeft, $iTop)
    $fVisible = False
    GUISetState(@SW_HIDE, $hChild)
    If Not StringRegExp($sBuff, '\w') Then Return
    
    Local $aResults = StringRegExp($sData, '(?i)\b(' & $sBuff & '\w+)\b;', 3)
    If IsArray($aResults) Then
                
        _GUICtrlListBox_ResetContent($hList)
        For $i = 0 to UBound($aResults)-1
            _GUICtrlListBox_AddString($hList, $aResults[$i])
        Next
        _GUICtrlListBox_Sort($hList)
        _GUICtrlListBox_SetCurSel($hList, 0)
        
                
        DllCall($hUser32, 'int', 'MoveWindow', 'hwnd', $hChild, 'int', _
                $iLeft, 'int', $iTop, 'int', $iWidth, 'int', $iHeight, 'int', True)
        GUISetState(@SW_SHOWNOACTIVATE, $hChild)
        $fVisible = True
        
    EndIf
EndFunc
Edited by Authenticity
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...