Jump to content

Close Match on Gui List


Recommended Posts

Ook, I'm making an [text] editor program, and I was wondering how I could simulate the "close match" type thing when a user enters s certain line of letters, for example in SCITE, if you enter "sl" it comes up with a close match of "sleep", I want to do the same thing, however, with a list.

Oh an sorry if this is supposed to be in the GUI section.. I don't think so though...

I was thinking of Making hotkeys for all the letters but i thought id be too tedious...

Heres my script (without all the list add stuff, to save room):

[autoit]#include <GUIConstants.au3>

#Include <GuiList.au3>

HotKeySet("{ins}","insert")

$Form1_1 = GUICreate("EasyScript Editor", 962, 760, 228, 110)

GUISetBkColor(0x000000)

$Tab2 = GUICtrlCreateTab(0, 0, 961, 657)

$TabSheet4 = GUICtrlCreateTabItem("Untitled")

$Edit1 = GUICtrlCreateEdit("", 8, 32, 945, 617)

If Not IsDeclared('Green') Then Local $Green = 0x00FF00

GUICtrlSetColor($Edit1,$Green)

If Not IsDeclared('Black') Then Local $Black = 0x000000

GUICtrlSetBkColor($Edit1,$Black)

GUICtrlCreateTabItem("")

$List1 = GUICtrlCreateList("", 0, 656, 961, 84)

GUICtrlSetColor($List1,0x0F0FFF)

;Functions List was here

$filemenu = GUICtrlCreateMenu("File")

$fileitem1 = GUICtrlCreateMenuitem("Save", $filemenu)

$fileitem3 = GUICtrlCreateMenuitem("Open", $filemenu)

$fileitem4 = GUICtrlCreateMenuitem("Compile", $filemenu)

$fileitem5 = GUICtrlCreateMenuitem("Run", $filemenu)

$filemenu2 = GUICtrlCreateMenu("Color")

$fileitem21 = GUICtrlCreateMenuitem("Default", $filemenu2)

$fileitem22 = GUICtrlCreateMenuitem("Custom...", $filemenu2)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $fileitem21

If Not IsDeclared('Green') Then Local $Green = 0x00FF00

GUICtrlSetColor($Edit1,$Green)

If Not IsDeclared('Black') Then Local $Black = 0x000000

GUICtrlSetBkColor($Edit1,$Black)

Case $fileitem22

#include <Misc.au3>

MsgBox(0,"Choose...","Choose text Color (Click OK)")

$fgcolor=_ChooseColor (2,0x00FF00)

GUICtrlSetColor($Edit1,$fgcolor)

MsgBox(0,"Choose...","Choose back Color (Click OK)")

$bgcolor=_ChooseColor (2)

GUICtrlSetBkColor($Edit1,$bgcolor)

Case $fileitem1

$save=FileSaveDialog("Save As...",@DesktopDir,"(*.au3)")

$FormSave = GUICreate("Saving", 300, 100, -1, -1,$WS_POPUP)

GUICtrlCreateAvi("shell32.dll", 165, 10, 10, -1, -1, BitOr($ACS_TRANSPARENT, $ACS_AUTOPLAY))

GUISetState()

FileWrite($save&".au3",GUICtrlRead($Edit1))

Sleep(2000)

GUIDelete($FormSave)

Case $fileitem3

$open=FileOpenDialog("Open...",@DesktopDir,"(*.au3)")

GUICtrlSetData($Edit1,FileRead($open))

Case $fileitem4

Run(@HomeDrive&"\Program Files\AutoIt3\Aut2Exe\Aut2Exe.exe")

Case $fileitem5

FileDelete("temp.au3")

FileWrite("temp.au3",GUICtrlRead($Edit1))

Do

Sleep(100)

Until FileExists("temp.au3")

Run(@HomeDrive&"\Program Files\AutoIt3\AutoIt3.exe temp.au3")

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Func insert()

GUICtrlSetData($Edit1,GUICtrlRead($Edit1)&GUICtrlRead($List1))

EndFunc

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Oh and while this thread is still open, what is the tab character? in scite, TAB is about 4-5 spaces, but instead of 4-5 spaces, its 1 character, and since im building a text editor, I think its a nice thing to have in there...

Thanks again

EDIt:

And while im at that, [relevant to 1st question] after it matches it... how do I get it to "SELECT" an item on the list..

thenks again, lol

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Hi

Hope you don't mind my input, but I'm still working on the close match routine, I got it to work , but I need to refine it so it doesn't use so much cpu time. Will post it once I get it better sorted.

I do have some other suggestions for your editor.

The Gui itself needs to be more compatible with differant screen resolutions.

Atm if a user has their screen resolution 1024 x 768 or 800x 600 then they can't see the whole gui.

Maybe put the Function bank into a text file and load the text file into the list when the gui is started.

This way your able to update the function list without rewriting your script , also a user can easily add new function names to the list by just adding it to the text file. Another plus is your script will be shorter.

Example of doing list that can be loaded:

Add this to the top of your script

#include <File.au3>oÝ÷ Ø]¶¬¶!z·²¢êêºEºw-ì.+-Á«!z·ªºewºÚ"µÍÑ[Ý[Û[Ê
oÝ÷ Ø]¶¬¶ayº-¶¨*.®Ç+ZºÚ"µÍ[ÈÑ[Ý[Û[Ê
BQ[H    ÌÍÑ[Ý[Û[ÂYÝÑ[TXYÐ^JØÜ    [È ][ÝÉÌLÑ[Ý[Û[Ë    ][ÝË  ÌÍÑ[Ý[Û[ÊH[BSÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÈÜXY[È   ][ÝÈ  [ÈØÜ [È ][ÝÉÌLÑ[Ý[Û[Ë    ][ÝÊB[ÙBBQÜ ÌÍØYHHÈ ÌÍÑ[Ý[Û[ÖÌBBBWÑÕRPÝÝY][J ÌÍÓÝK   ÌÍÑ[Ý[Û[ÖÉÌÍØYJBBS^BQ[Y[[

Lastly drop this file into the directory your script is being run from

PS: I corrected some typo's you had with function names.

eg: ASind should be ASin , AdlibEnabled should be AdlibEnable, WinWait Pauses should be WinWait... etc

Cheers

Edited by smashly
Link to comment
Share on other sites

yea I had the functions in a list, but with like 100 of them, it takes alot of time to load, though I could load additional ones.. thanks!!

and typos? I copied these out of the help file, lol =P

Thanks much!

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

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