Author Topic: am I in an edit buffer?  (Read 4459 times)

mcarlson

  • Community Member
  • Posts: 15
  • Hero Points: 0
am I in an edit buffer?
« on: August 20, 2008, 06:52:25 pm »
I apologize now for not knowing the correct SlickEdit/Slick-C terminology.
I will try to use SE terms as I learn them.

I want a macro to be able to differentiate between focus being in a buffer, and focus being on a command line.
By command line I mean the prompt that I get after type "Esc x" (gnu emacs mode), or the 'edit' file open prompt "Ctrl-x Ctrl-f" (gnu emacs mode).

What can I look at to differentiate these two states?

Thank you,
Matt

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: am I in an edit buffer?
« Reply #1 on: August 20, 2008, 07:00:01 pm »
I'm using this in various macros:
Code: [Select]
   cmdline_active := (_cmdline == p_window_id);

   // e.g. edit fields in dialogs
   in_text_box    := (p_object == OI_TEXT_BOX);
HS2

mcarlson

  • Community Member
  • Posts: 15
  • Hero Points: 0
Re: am I in an edit buffer?
« Reply #2 on: August 20, 2008, 07:48:10 pm »
I've added both of the lines that HS2 suggested and I'm checking them using the debugger.

It seems that they are the same if the _command is invoked either from a keybinding with a buffer focused or from a keybinding with a command line focused.

I'm realizing while writing this that the fact that it's called from a keybinding may have something to do with what I'm seeing, and was probably an important piece of information.

I also found and tried to use command_state() with the same effect (no change, if focus is on buffer or command line)

I did notice however that "edit" gives a different response (it doesn't call my macro from the keybinding).


Thanks again for all the help.
Matt

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: am I in an edit buffer?
« Reply #3 on: January 09, 2009, 02:28:52 pm »
I just got done dealing with this weirdness.

command_state() lies to you if your _command does not have name_info(','VSARG2_CMDLINE|VSARG2_ICON|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)

in particular the VSARG2_CMDLINE