Hi everyone,
I've been looking for this option.. to close parenthesis as soon as I type the open parenthesis
and put the cursor in the middle, same with the quotes (l) "l", I like it that way better because
I don't have to keep track of parenthesis.
Thanks,
Ed.
There's no configuration option that provides this AFAICS. There's a couple of possibilities.
The safest way is to define a macro like this
_command void my_paren() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
_insert_text('()');
left();
}
and bind a key to it such as Ctrl-Shift-P
Alternatively, you could have
_command void my_paren() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
_insert_text(')');
left();
keyin('(');
}
and bind to Ctrl-Shift-P, which has the advantage of performing the special processing you normally get when typing an opening paren (I think).
Another way is to modify the code in c.e c_paren() as follows - the lines followed by "// <<<<<<<<<<<<<<<< added" have been added.
If you want to try this, on the slick cmd line, type fp c_paren and you will be taken to the c_paren function in c.e. After changing the code, you can load it by using the load module command on the macro menu.
_command void c_paren() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE|VSARG2_LASTKEY)
{
// Called from command line?
if (command_state()) {
call_root_key('(');
return;
}
// Handle Assembler embedded in C
typeless orig_values;
int embedded_status=_EmbeddedStart(orig_values,'');
if (embedded_status==1) {
call_key(last_event());
_EmbeddedEnd(orig_values);
return;
}
_insert_text(')'); // <<<<<<<<<<<<<<<< added
left(); // <<<<<<<<<<<<<<<< added
// Check syntax expansion options
typeless expand, be_style, indent_fl;
parse name_info(_edit_window().p_index) with . expand . . be_style indent_fl .;
if (expand && p_SyntaxIndent>=0 && !_in_comment() &&
!c_expand_space(p_SyntaxIndent,be_style,indent_fl)) {
return;
}
// not the syntax expansion case, so try function help
auto_functionhelp_key();
}
Yet another way is to define a macro like this
_command void my_paren() name_info(','VSARG2_REQUIRES_EDITORCTL|VSARG2_CMDLINE)
{
_insert_text(')');
left();
if (p_extension == 'Slick-C') {
slick_paren();
}
else
{
c_paren();
}
}
You could bind the '(' key to this macro,
however, you will have to unbind the '(' from both c_paren and slick_paren commands to get this to work and once you've done that
there's no way to get the normal bindings of '(' back (I haven't found one so far anyway!) so I don't recommend this.
I can't guarantee your computer won't self destruct or that slick won't misbehave when you try these things so I strongly recommend you backup your entire configuration folder first so you can back out any changes if you get stuck.
In case you haven't written a macro before, you can place your macros in a file called vusrmacs.e which should be in your configuration folder and load it using "load module" on the macro menu. Make sure your macro file has #include "slick.sh" at the start.
Graeme