Author Topic: Global Edit window Setting.  (Read 8087 times)

pmgroen

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Global Edit window Setting.
« on: August 14, 2006, 09:37:09 am »
Hi All,

I'm fairly new to Slickedit (Always used some 'vi' deriverate) and I was wondering if it is possible to have the 'Special Chars' option from the view-menu and the 'Line Numbers' set globally. For every file (Don't work with projects yet) I open, I have to set this again.

Is there a way to do this?

Kind regards,

Peter

Graeme

  • Senior Community Member
  • Posts: 2389
  • Hero Points: 314
Re: Global Edit window Setting.
« Reply #1 on: August 15, 2006, 01:41:18 am »

If you look in the help under tutorials for macro programming  (search for _buffer_add_ViewLineNumbers if you can't find the topic), you'll see it mentions in the section just before that, that line numbers can be enabled for each extension by choosing the Tools > Options > File Extension Setup > General > Display line numbers.

If you record a macro and turn on line numbers and special chars, you'll get the following.


_command show_line_numbers_and_special_chars() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
   execute('view-specialchars-toggle');
   execute('view-line-numbers-toggle');
}

In the key bindings dialog you'll see you can bind a shortcut to view-special... and view-line... if you want a quick way to turn on/off.
If you type fp view-specialchars-toggle at the command line you'll see the code for it.

You can use this macro to get special chars shown when you open a new file  - however, this only applies when a new file is opened that wasn't already in the workspace - so if you open a project, the files that are already open in that workspace won't have special chars enabled by the following macro

void _buffer_add_View_SpecialChars()
{
    p_ShowSpecialChars=SHOWSPECIALCHARS_ALL;
}

As explained in the tutorial section in the help I mentioned before, the _buffer_add prefix has special meaning.

There's also a _switchbuf prefix

void _switchbuf_add_View_SpecialChars()
{
    p_ShowSpecialChars=SHOWSPECIALCHARS_ALL;
}

which means whenever you switch to a new buffer, any functions that begin with _switchbuf get executed.
This might turn out to be inconvenient though.  Another thing you can do is write a macro to iterate through all open buffers and turn special chars on or off

int turn_on_special_chars()
{
   p_ShowSpecialChars=SHOWSPECIALCHARS_ALL;
   return 0;
}

_command void show_special_chars_for_all_buffers() name_info(',')
{
   _mdi.p_child.for_each_buffer( 'turn_on_special_chars' );
}


Graeme





hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: Global Edit window Setting.
« Reply #2 on: August 15, 2006, 08:15:47 am »
Very good explanation Graeme [thumb-up] - should be merged into the manual ...
However, I'll copy it to my own 'HowTo' snippets - thx !
HS2

pmgroen

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Global Edit window Setting.
« Reply #3 on: August 15, 2006, 10:43:44 am »
Graeme,

Thanx a million! It worked like a charm.

Happy Hacking

Peter

Dswag89

  • Community Member
  • Posts: 63
  • Hero Points: 4
Re: Global Edit window Setting.
« Reply #4 on: August 15, 2006, 12:50:38 pm »
Hey all,

I've used SlickEdit for about 8 years now (have been using Version 6 for most of those), but have never really gotten into Macro writing... the interface has always seemed cryptic to me... I'll create a macro for "one time use" and then forget about it.  I'm trying to use the example given here, in conjunction with the "Guide" in the Help, for creating the "turn on special chars and line numbers" to learn some about Macro creation.  I cut-and-pasted the two functions (turn_on_special_chars and show_special_chars_for_all_buffers), first into my vusrmacs.e file, and then into a test file (test.e) where I created the "Hello World" macro (as described in the Guide).  It appears as though the only way I can "load" the macros and compile them is to use the command line "load" command (or does Macro... Load Module do the same thing?).

Anyway, when I tried the "load" command on my test.e file, it complained that SHOWSPECIALCHARS_ALL was not initialized.  I assumed this to be a "defined value" within SlickEdit.  I figured out, from comparing the new file to vusrmacs.e that I needed to add the include of slick.sh, and successfully ran my command from the command-line.  I expected it to turn on line numbers as well (but it didn't).  I guess I could add the other text into the turn_on_special_chars function to see if that works...

The other thing that I don't quite understand is, why don't these new functions show up in the list when I select the Macro... List Macro menu?

So, to summarize my questions:
1.  Is the "load" command from the command line the only way to "compile and load" a macro?
2.  How do items show up in the "Macro List"?
3.  Is there an easy primer I can use (besides the Guide, which clearly has me confused) to give me a better understanding?

Thanks,

Dan

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Global Edit window Setting.
« Reply #5 on: August 15, 2006, 03:44:36 pm »

1.  Is the "load" command from the command line the only way to "compile and load" a macro?
2.  How do items show up in the "Macro List"?
3.  Is there an easy primer I can use (besides the Guide, which clearly has me confused) to give me a better understanding?


1)  Macro->Load Module... does what you want -- compile the .e file and load the resulting .ex.
2)  I think it has to do with the name_info() args, but I'm not sure exactly which flags (VSARG2_MACRO?) allow the macro to show up in the Macros->List Macros list.
3)  I find the SlickEdit help to be not very well organized.  (Currently, my Help installation is broken; most of the time I get "Internet Explorer cannot display the webpage".)  People on this forum are probably your best resource.  Spelunking in the existing macro files is another way to learn about how SlickEdit works.

Good luck.

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: Global Edit window Setting.
« Reply #6 on: August 15, 2006, 08:42:09 pm »
Hi Dswag89,

take a look into Tools->Options->Key Bindings. This is the global list of all avail. Slick-C macros curr. loaded.
(They can also be invoked from cmdline.)

The mentioned 'Macro -> List Macros ' does only 'List user recorded macros and allows them to be bound to keys, edited, or run.' Means this manages your recorded macros.
@Wanderer:
If a macro function gets compiled w/o errors there is only 1 pitfall preventing the cool fct. to appear on the list.
the missing _command attribute ;) (happens to me from time to time ...)
name_info can be used to adjust/restrict the calling context of a macro.

HS2

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Global Edit window Setting.
« Reply #7 on: August 15, 2006, 09:15:55 pm »
@Wanderer:
If a macro function gets compiled w/o errors there is only 1 pitfall preventing the cool fct. to appear on the list.
the missing _command attribute ;) (happens to me from time to time ...)
name_info can be used to adjust/restrict the calling context of a macro.


My comment was based on tinkering with these two signatures:
_command cb_read_only(...) name_info(','VSARG2_EDITORCTL)
_command void quickfileopen() name_info(','VSARG2_MACRO)

quickfileopen() appears in Macro->List Macros, but cb_read_only() does not.  If I add VSARG2_MACRO to cb_read_only(), it appears in the list.

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: Global Edit window Setting.
« Reply #8 on: August 15, 2006, 09:36:27 pm »
I've to admit that I don't do a lot w/ self-recorded macros.
Only sometimes for lengthy manual stuff.

But @see slick.sh
Code: [Select]
#define VSARG2_MACRO     0x100      // This is a recorded macro command. Used for completion.
Seems to be used for special purposes like 'filtering' (I'm sure it's not the perfect term for it) the 'recorded macos' in the 'Macros -> List ..' dialog. I've never used it ...

HS2