Sending Enter key to execute cmdline in FAR 1.75

A place where plug-in developers can share their knowledge and experience.
Post Reply
twodev
Posts: 56
Joined: Mon 23 Feb, 2009 00:36

Sending Enter key to execute cmdline in FAR 1.75

Post by twodev »

(this regards the requested format menu plugin compatibility with far 1.7x)

i was wondering why it seems that i cannot make KEY_ENTER in far 1.75 (i'm always testing on the lastest nightly builds) behave just like in far 2.x:

i set the cmdline via FCTL_SETCMDLINE, then send KEY_ENTER - which should in fact simulate the user pressing the enter key. this works well in far 2, but in far 1.75 it enters the folder or runs the file which is currently under cursor in the active panel rather than executing the filled cmdline.

any ideas?
far2 plugins: format menu (discuss) | editor tools (discuss); far2 tools: lngtool
User avatar
DrKnS
Posts: 6114
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 12 times
Been thanked: 426 times

Re: Sending Enter key to execute cmdline in FAR 1.75

Post by DrKnS »

1. what build of 1.75?
2. attach a sample plugin with sources here.
twodev
Posts: 56
Joined: Mon 23 Feb, 2009 00:36

Re: Sending Enter key to execute cmdline in FAR 1.75

Post by twodev »

1. 1.75 RC0 build 2537
2.

Code: Select all

    // bla bla bla, SETCMDLINE, etc.

	Info.AdvControl( Info.ModuleNumber,ACTL_POSTKEYSEQUENCE,&keySeq );

    // This is causing the problem...
	Info.Control( INVALID_HANDLE_VALUE,FCTL_SETCMDLINE,empty ))
		return false;
i've just found out what's causing the problem:

FAR 1.75 doesn't like me clearing the cmdline right after posting KEY_ENTER. it seems FAR will then clear the cmdline _before_ executing the enter key.

FAR 2 seems to do it more sequentially. but this might just be a bad coicidence.

i'll just omit the last setcmdline. that should solve the problem. and the call is really superfluous as well.
far2 plugins: format menu (discuss) | editor tools (discuss); far2 tools: lngtool
User avatar
DrKnS
Posts: 6114
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 12 times
Been thanked: 426 times

Re: Sending Enter key to execute cmdline in FAR 1.75

Post by DrKnS »

it seems FAR will then clear the cmdline _before_ executing the enter key.
Yes, it's even documented:
ACTL_POSTKEYSEQUENCE
...bla-bla-bla...
The keys will be interpreted as soon as the plugin returns control to FAR.
As I know, Far2 should work in the same manner. If not - it seems like a bug in 2.0, not 1.75.
twodev
Posts: 56
Joined: Mon 23 Feb, 2009 00:36

Re: Sending Enter key to execute cmdline in FAR 1.75

Post by twodev »

alright. seems like i've missed that in the docs.
far2 plugins: format menu (discuss) | editor tools (discuss); far2 tools: lngtool
Post Reply

Return to “Plug-In Developers”