Author Topic: goback through buffers  (Read 3575 times)

Graeme

  • Senior Community Member
  • Posts: 2443
  • Hero Points: 322
goback through buffers
« on: October 23, 2013, 08:02:19 am »
This macro uses a _switchbuf call-list function to maintain a list of buffers visited in the order that you visit them.  If you visit a buffer, that buffer gets moved to the front of the list.

This may well be duplicating functionality that slickedit v18 already has - I haven't really checked, but slickedit didn't have it when I wrote it a few years ago.  It should work on most versions of slickedit.


// switch to the previous buffer
_command void goback_last_buffer()

Calling goback_last_buffer repeatedly alternates between the last two buffers visited.

// goback_step_thru_buffer_list steps through the buffers recently visited.
//    F12 cycles the two most recent buffers
//    C-F12 cycles 3 most recent buffers
//    Numeric keys (n) 1 - 9 cycle that number with immediate jump to buffer n
//    Up, down, left, right cycle the full list
//    ESC exits
//    Any other key exits and is currently ignored - if you want such keys to
//    be processed, uncomment the call to call_key.
//
// if parameter cmode is true, the previous buffer is switched to, with immediate exit
_command void goback_step_thru_buffer_list(boolean cmode = false)


goback_step_thru_buffer_list allows you to step through the list of buffers.  It has some hard-coded "key bindings" that do various things  - left-arrow right-arrow step through the list.

There are two files to load, first dlinklist.e, then GFilemanGoback.e.
dlinklist.e is the same as used in the xretrace macro.

This macro also includes the following function which you need to use instead of alt_gtbookmark() if you find going to a bookmark doesn't update the goback buffer list.

Code: [Select]
_command alt_gtbookmark_new() name_info(','VSARG2_LASTKEY|VSARG2_EDITORCTL)
{
    alt_gtbookmark();
    _switchbuf_goback_buffer();
}


Graeme

  • Senior Community Member
  • Posts: 2443
  • Hero Points: 322
Re: goback through buffers
« Reply #1 on: April 18, 2015, 09:10:59 am »
If you're using multiple windows it's better to use the following code from RobertH2 for switching between the last two buffers.
https://community.slickedit.com/index.php/topic,11324.msg47726.html#msg47726

Code: [Select]
static boolean IsGotoNextBuffer=true;

_command void my_back() name_info(',')
{
    if (IsGotoNextBuffer) {
        back();           
    } else {               
        forward();         
    }                     
   IsGotoNextBuffer = !IsGotoNextBuffer;
}