Sending Enter key to execute cmdline in FAR 1.75

A place where plug-in developers can share their knowledge and experience.
User avatar
twodev
Posts: 53
Joined: Mon 23 Feb, 2009 00:36
Location: Austria
Contact:

Sending Enter key to execute cmdline in FAR 1.75

Postby twodev » Thu 05 Mar, 2009 18:10

(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: 4458
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 2 times
Been thanked: 105 times
Contact:

Re: Sending Enter key to execute cmdline in FAR 1.75

Postby DrKnS » Thu 05 Mar, 2009 18:29

1. what build of 1.75?
2. attach a sample plugin with sources here.

User avatar
twodev
Posts: 53
Joined: Mon 23 Feb, 2009 00:36
Location: Austria
Contact:

Re: Sending Enter key to execute cmdline in FAR 1.75

Postby twodev » Thu 05 Mar, 2009 18:34

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: 4458
Joined: Thu 04 Aug, 2005 06:44
Location: Kyiv
Has thanked: 2 times
Been thanked: 105 times
Contact:

Re: Sending Enter key to execute cmdline in FAR 1.75

Postby DrKnS » Thu 05 Mar, 2009 18:51

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.

User avatar
twodev
Posts: 53
Joined: Mon 23 Feb, 2009 00:36
Location: Austria
Contact:

Re: Sending Enter key to execute cmdline in FAR 1.75

Postby twodev » Thu 05 Mar, 2009 19:36

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


Return to “Plug-In Developers”

Who is online

Users browsing this forum: No registered users and 1 guest