Auto-complete editor

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by AndrewC.

I am interested in a PB editor that has auto-complete features, is anyone else interested in something like that?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Hi! What do you mean with auto-complete features in PB editor?

MrVainSCL!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by AndrewC.

Hello

Auto complete is where you type the first few letters of the keyword then select the one you want the editor to complete from a popup list. e.g.

You type:
En

List offers:
End
EndIf
EndProcedure

You then select and press enter or tab to complete the word. I am thinking of starting one in VB5 (I don't know PB enough yet)

Andrew
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wayne1.

try ConText editor (freeware) press ctrl+j for dropdown list of items
to select from.
the auto complete template and link to Context at
http://www.reelmediaproductions.com/pb
(the template is easy to modify for new commands)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by AndrewC.

Tried ConTEXT, couldn't get it to compile. Also, it is easier if list pops up is automatically instead of pressing Ctrl+J.

Thanks though Wayne1
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plouf.

[quote]
Tried ConTEXT, couldn't get it to compile. Also, it is easier if list pops up is automatically instead of pressing Ctrl+J.


if it auto popedup tehn it may confuse user ex. is if i write
a variable called openwin the auto completion will cahnge this to
openwindow(
(btw the most wanted feature for me in editor is multi window support)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by AndrewC.

Hello plouf

The popup would offer a selection list but you could still type while list is shown. It would be based on an MDI.

I would like to emulate the VB editing environment. Other features would include:

V1.00
Parameter reminder
Syntax Highlighting
Project based MDI

V2.00
Form designer as VB
Extensible architecture for libraries e.g. RichEdit
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
if it auto popedup tehn it may confuse user ex. is if i write
a variable called openwin the auto completion will cahnge this to
openwindow(
I know what you mean. What the editor could do is: when the user presses the
Tab key during a word, the list (or just the closest matching word) could pop
up then. So in your case, if the user typed the word openwin by itself
then nothing would happen, but if you typed openwin and hit Tab then
the word OpenWindow( would replace it. This would solve the problem
for all users, and not clash with variables. Pressing of Tab in this way is
a common technique for many programs, and even games (such as Quake).

It also wouldn't affect indentations because there is no text before the
indent, so pressing Tab on an empty line would just indent as normal.

But this is a lot to ask of Fred...


PB - Registered PureBasic Coder

Edited by - PB on 05 December 2001 15:31:55
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by AndrewC.

It's simpler than that. Just like auto-complete in Word

You just type, a popup lists keywords that start with the same characters.

You select by using cursor keys and pressing tab/enter. You don't have to select anything if you don't want to.

However, as there isn't much interest, I'm not rushing to do it anyway.

Andrew
User avatar
Michael Vogel
Addict
Addict
Posts: 2820
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

AutoHotkey...

Post by Michael Vogel »

Hi,
seems that autocomplete could be done in different ways. I just demonstrate on additional option:

Use the free Autohotkey tool, I wrote a small script for it which is maybe also ok for you. (if you do not know Autohotkey, just copy the two code snipplets into AutoHotkey.ini, start Autohotkey and press "windows-p". If the tray icon gets red, you're on the right way)

It has two parts, one which enables and disables autocomplete (done with hotkey "windows-p"). It also includes a list of words which have to be automatically changed...

Code: Select all

#p::				; Hotkeys für Purebasic aktivieren
if Purekeys
{
	Purekeys:=0
  	SetTimer,PureBasic,Off
	menu,tray,Icon,%A_AhkPath%,6
}
else
{
	p=pro#procedure#endp#endprocedure#retp#procedurereturn#ei#endif#fo#for#ne#next#sele#select#cas#case#ends#endselect#deb#debug
	StringSplit,p,p,#			; p in Array umwandeln
	pp:=p0/2
	Purekeys:=1
	SetTimer,PureBasic,500
	menu,tray,Icon,%A_AhkPath%,4
}
return
The second part is responsible for changing the words (e.g. "pro " will change to "procedure "). This will happen only, if you are in the PureBasic-IDE, but you can change the behaviour (e.g. happens after "shift-space" but not "space" only)...

Code: Select all

PureBasic: 
SetTimer,PureBasic,Off

Input,UserInput,*V,{Return}{Tab}{Space}

IfWinActive, PureBasic		;If GetKeyState("Shift")  
{
If Instr(ErrorLevel,"EndKey:")>0
	{	index=0
		StringLen,path,UserInput
		Loop, %pp%
		{	index++
			temp:=p%index%
			index++
			StringLen,dummy,temp
			dummy:=path-dummy
			{
				If InStr(UserInput,temp,0,dummy)
				{
					StringLen,dummy,temp
					dummy++
					temp:=p%index%
					Send,{Backspace %dummy%}%temp%
					taste:=""	
					stringmid,taste,errorlevel,8,10
					send {%taste%}
					Break
				}
			}
		}
	}
}
SetTimer,PureBasic,On
Return

New: I've enhanced the AutoHotkey script, now it is possible to expand keywords not only with a <space>, but also with <enter> or <tab>

So, now it is possible to enter...

Code: Select all

	pro<space>test()<enter>endp<enter>
to create...

Code: Select all

	Procedure test()
	EndProcedure
Post Reply