Author Topic: Changing keyboard emulation with macro?  (Read 2034 times)

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Changing keyboard emulation with macro?
« on: February 08, 2019, 08:54:12 PM »
Sometimes I get a new user of SlickEdit on my team and they want to change to vi bindings. However, before they do that I have them automatically setup with a default configuration directory that has a bunch of customized key bindings for special things (and I have a macro for configuring these custom key bindings that was automatically executed for them).

In our internal wiki, I instruct the new user how to change their key binding to vi if they like, however it resets my custom key bindings and I also have to include instructions for them on how to reload my custom key bindings.

I'd rather provide them a macro that will do both of, switch to vi bindings, re-initialize my custom key bindings. Then on our wiki I can instruct them to just run this one macro and not have multiple steps.

Is it possible? What macro to use to set vi key bindings? Also emacs?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Changing keyboard emulation with macro?
« Reply #1 on: February 08, 2019, 08:58:56 PM »
The command “emulate vi” switches to vi emulation. Just put that in a macro.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Changing keyboard emulation with macro?
« Reply #2 on: February 08, 2019, 09:05:57 PM »
Thanks Clark.

What about "emacs" and "cua" (in case they want to go back to SE default).

Is it:

emulate emacs
emulate cua

?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Changing keyboard emulation with macro?
« Reply #3 on: February 08, 2019, 09:26:19 PM »
"cua" is the default on windows and linux.
I think you want "gnuemacs" instead of "emacs". "gnuemacs" is more popular these days.
"mac" is the default on macOS. Probably not useful on other platforms though.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Changing keyboard emulation with macro?
« Reply #4 on: February 08, 2019, 09:36:00 PM »
Getting some errors when I try to load the macros:

Code: [Select]
_command void keysvi() name_info(','VSARG2_READ_ONLY)
{
   emulate vi;
}

error: Identifier 'emulate' not declared

Then I tried:
Code: [Select]
_command void keysvi() name_info(','VSARG2_READ_ONLY)
{
   emulate("vi");
}

error: Expecting procedure name - identifier not found - import may be required

It is not clear what I need to import?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6823
  • Hero Points: 526
Re: Changing keyboard emulation with macro?
« Reply #5 on: February 08, 2019, 09:39:41 PM »
I guess this one is tricky. "emulate" is a batch macro. This should work:

execute("emulate vi");

The execute() function is used to execute things like you typed them on the SlickEdit command line. It's mostly useful for batch macros and recording macros where you just want to duplicate what the user did.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Changing keyboard emulation with macro?
« Reply #6 on: February 08, 2019, 09:48:26 PM »
Thanks Clark! That worked!