Author Topic: tutorial don't work (view line numbers)  (Read 10285 times)

picnic

  • Community Member
  • Posts: 25
  • Hero Points: 0
tutorial don't work (view line numbers)
« on: March 05, 2008, 10:21:40 AM »
hi
I was looking for a solution to turn on line numbers automatically for all files. Sandra refered in another post
  • to a SE tutorial.


I was following the steps in the tutorial but it don't work:

1. creating a script ViewLineNumbers.e
---------------------------------------------------------------
#include "slick.sh"
 
void _buffer_add_ViewLineNumbers()
{
    p_LCBufFlags|=VSLCBUFFLAG_LINENUMBERS;
}
---------------------------------------------------------------

2. Loading the macro

3. Macro successfully loaded, ViewLineNumbers.ex is built

4. restart SE

The files are still without any line numbers ...
any ideas?

regards
picnic



Sandra

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 754
  • Hero Points: 36
Re: tutorial don't work (view line numbers)
« Reply #1 on: March 05, 2008, 02:27:34 PM »
If you open a file from within the editor (either close and reopen a file or just open a new one), does that file have line numbers? 

picnic

  • Community Member
  • Posts: 25
  • Hero Points: 0
Re: tutorial don't work (view line numbers)
« Reply #2 on: March 05, 2008, 11:37:47 PM »
interesting...

the line numbers only show up when I open a file, but not if I make a new one. is that on purpose?


hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: tutorial don't work (view line numbers)
« Reply #3 on: March 05, 2008, 11:51:58 PM »
@picnic: Try '_switchbuf' instead of '_buffer_add'. Maybe it's working better for you. - HS2

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: tutorial don't work (view line numbers)
« Reply #4 on: March 05, 2008, 11:58:02 PM »
This should work:
Code: [Select]
void _switchbuf_force_linenumbers (_str oldbuffname, _str flag)
{
   if ( (flag != 'W') && (flag != 'Q') )  p_LCBufFlags|=VSLCBUFFLAG_LINENUMBERS;
}
HS2
« Last Edit: March 06, 2008, 12:00:35 AM by hs2 »

picnic

  • Community Member
  • Posts: 25
  • Hero Points: 0
Re: tutorial don't work (view line numbers)
« Reply #5 on: March 08, 2008, 07:11:58 PM »
hi hs2
I really appreciate your support, but unfortunately it still doesn't work.

yes it loads the makro, but the lines are not set if I make a new file.

any ideas?

picnic

picnic

  • Community Member
  • Posts: 25
  • Hero Points: 0
Re: tutorial don't work (view line numbers)
« Reply #6 on: March 08, 2008, 07:13:16 PM »
one question since I'm not too familiar with SE hacking ...

Is there a special convention for filenames in cases like this?



jbhurst

  • Senior Community Member
  • Posts: 405
  • Hero Points: 33
Re: tutorial don't work (view line numbers)
« Reply #7 on: March 08, 2008, 09:17:10 PM »
Hi picnic,

You can name your macro file nearly anything you want. By convention they end in ".e".

Be careful not to use the same name as any supplied macro file. (They are under macros/ in your installation directory. For example, if you name your file "util.e" (the same as a supplied macro) and compile it, it will replace the definitions in the supplied util.e, which will be very bad. (It is easy to fix if you do it by accident, just reload (recompile) the supplied macro.)

The simplest thing to do is prefix your own files with something unique, such as "picnic_".

Regards

John Hurst
Wellington, New Zealand

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: tutorial don't work (view line numbers)
« Reply #8 on: March 08, 2008, 09:59:31 PM »
yes it loads the makro, but the lines are not set if I make a new file.


How do you "make" the new file?

Try having both _buffer_add and _switchbuf as in the code below.  If it still doesn't work for you, try uncommenting the lines that call 'say' - they will output to a diagnostic window and let you see whether your callback is being called.  (this code works for me).  I think there are times when _switchbuf doesn't get called - e.g. when a file is opened by using a bookmark.  If you want line numbers for all the special slick files that start with '.' (e.g. .search0) or untitled buffers whose name is empty, then change the want_line_numbers function.

Graeme


Code: [Select]
static boolean want_line_numbers()
{
   if (_mdi.p_child.p_buf_flags & HIDE_BUFFER) {
      return false;
   }

   _str possible_last_buffer = _mdi.p_child.p_buf_name;

   if (possible_last_buffer == '') {
      return false;
   }

   // don't add line numbers to special slick buffers whose name starts with '.'
   if (pos('.',possible_last_buffer) == 1) {
      return false;
   }

   /***************************************************************
   if (possible_last_buffer == '.command') {
      return false;
   }
   if (possible_last_buffer == '.process') {
      return false;
   }
   if (possible_last_buffer == '.slickc_stack') {
      return false;
   }
   if (possible_last_buffer == '.References Window Buffer') {
      return false;
   }
   if (possible_last_buffer == '.Tag Window Buffer') {
      return false;
   }
   if (pos('.search',possible_last_buffer) != 0) {
      return false;
   }
   *****************************************************************/
   return true;
}
 
void _buffer_add_ViewLineNumbers()
{
    //say('buffer add - ' :+ p_buf_name);
    if (want_line_numbers()) {
       p_LCBufFlags|=VSLCBUFFLAG_LINENUMBERS;
    }
}

void _switchbuf_ViewLineNumbers()
{
    //say('switch buffer - ' :+ p_buf_name);
    if (want_line_numbers()) {
       p_LCBufFlags|=VSLCBUFFLAG_LINENUMBERS;
    }
}