CREATE AutoComplForm AS QFORM
Width = 300
Height = 120
BorderStyle = bsToolWindow
KeyPreview = True
OnKeyPress = AutoComplList_Enter
CREATE AutoComplList AS QLISTBOX
Font.Size = 12
ItemHeight = 28
Width = AutoComplForm.ClientWidth
Height = AutoComplForm.ClientHeight
OnDblClick = AutoComplList_Selected
END CREATE
END CREATE
SUB IDE_AutoCompleteWord
IF IDE.KeyWordList.ItemCount = 0 THEN EXIT SUB
DEFSTR s = IDE_GetKeywordFromText(re.WordAtCursor(), "_(." + Quot$ + sQuot)
DEFINT L = LEN(s)
IF INSTR(s, ".") > 0 THEN s = RIGHT$(s, L - INSTR(s, ".")): L = LEN(s)
DEFINT TheCase = ASC(RIGHT$(s , 1))
s = LCASE$(s)
DIM lookupList AS QSTRINGLIST
lookupList.AddItems("pre cmd", "killfiles", "kill", "run", "nobeep" "nocon", "adddll", "noadddll" , "diricon", "upx")
lookupList.AddList IDE.KeyWordList
lookupList.AddList IDE.KeyWordList2
lookupList.AddList IDE.KeyWordList3
AutoComplList.Clear
DEFINT i = 0
FOR i = 0 TO lookupList.ItemCount - 1
IF s = LEFT$(lookupList.Item(i), L) THEN AutoComplList.AddItems(lookupList.Item(i))
NEXT i
lookupList.Clear
IF AutoComplList.ItemCount = 0 THEN EXIT SUB
IF AutoComplList.ItemCount = 1 THEN
IF re.SelText <> "" THEN re.Set_AnchorPosition(re.Position + L)
IF (TheCase > 64) AND (TheCase < 91) THEN
re.AddStrings(UCASE$(RIGHT$(AutoComplList.Item(0), LEN(AutoComplList.Item(0)) - L)))
re.SetFocus
ELSE
re.AddStrings(RIGHT$(AutoComplList.Item(0), LEN(AutoComplList.Item(0)) - L))
re.SetFocus
END IF
ELSE
AutoComplList.ItemIndex = 0
AutoComplForm.Left = Screen.MOUSEX
IF AutoComplForm.Left > (Screen.Width - AutoComplForm.Width) THEN AutoComplForm.Left = Screen.Width - AutoComplForm.Width
AutoComplForm.Top = Screen.MOUSEY
IF AutoComplForm.Top > (Screen.Height - AutoComplForm.Height) THEN AutoComplForm.Top = Screen.Height - AutoComplForm.Height
AutoComplForm.Show
END IF
END SUB
SUB AutoComplList_Enter(Key AS BYTE)
IF Key = 13 THEN AutoComplList_Selected
IF Key = 27 THEN
AutoComplForm.CLOSE
re.SetFocus
END IF
END SUB
SUB AutoComplList_Selected
DEFSTR s = IDE_GetKeywordFromText(re.WordAtCursor(), "_(." + Quot$ + sQuot)
DEFINT L = LEN(s)
DEFINT TheCase = ASC(RIGHT$(s , 1))
s = AutoComplList.Item(AutoComplList.ItemIndex)
IF re.SelText <> "" THEN re.Set_AnchorPosition(re.Position + L)
IF (TheCase > 64) AND (TheCase < 91) THEN
re.AddStrings(UCASE$(RIGHT$(s, LEN(s) -L)))
ELSE
re.AddStrings(RIGHT$(s, LEN(s) -L))
END IF
AutoComplForm.CLOSE
re.SetFocus
END SUB
|