Author Topic: Creating a key binding for obtaining file or path name  (Read 5116 times)

Strugar

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Creating a key binding for obtaining file or path name
« on: October 30, 2012, 08:14:31 PM »
On the file tab, right clicking brings up a menu item which states "Copy Full Path to Clipboard".
I would like to know the following in order to create a key-binding for this function (and a filename copy):
1) Is there a global property which gives the name and/or path of the currently selected file (buffer)?
2) Is there some method similar to "copy_to_clipboard" which can be used to place this name or path on the clipboard?
I have tried searching the online documentation, but as usual, spent vast amounts of time and came up empty-handed.
Can anyone help?

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: Creating a key binding for obtaining file or path name
« Reply #1 on: October 31, 2012, 03:57:56 AM »
I searched for "Copy &Full" in macros\*.e
It found exactly one hit, in bufftabs.e
It invokes the command buff-menu-clipboard

Invoking that command directly gives an error (it only works from the Files tabs themselves).

But you can use "fp buff-menu-clipboard" from the SE command line (hit ESC in most keyboard emulations to activate the SE command line), and examine its source code to understand what it does, and then copy/paste/modify to make your own macro.

Strugar

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Creating a key binding for obtaining file or path name
« Reply #2 on: November 05, 2012, 06:06:05 PM »
Thanks, chrisant. I'll give that a try. Didn't think to look for "Copy &Full"; but can view the bufftabs.e file, and it looks promising.

MindprisM

  • Senior Community Member
  • Posts: 127
  • Hero Points: 8
Re: Creating a key binding for obtaining file or path name
« Reply #3 on: December 30, 2012, 06:03:41 AM »
Code: [Select]
      _command int clip_bufname() name_info(','VSARG2_REQUIRES_EDITORCTL){
          push_clipboard_itype ('CHAR','',1,true);
          append_clipboard_text (p_buf_name);
          return(0);
      }

shadowbane

  • Community Member
  • Posts: 85
  • Hero Points: 4
Re: Creating a key binding for obtaining file or path name
« Reply #4 on: January 29, 2013, 10:17:16 PM »
I did the same sequence of push_clipboard_type() followed by push_clipboard_text() only to find push_clipboard() which does both.  Fairly convenient for one line clipboard copies.

flethuseo

  • Senior Community Member
  • Posts: 177
  • Hero Points: 2
Re: Creating a key binding for obtaining file or path name
« Reply #5 on: February 05, 2013, 05:21:39 PM »
Probably irrelevant  but the function  keyin_buf_name() types the buffer's full name in the current line.
« Last Edit: February 05, 2013, 05:25:26 PM by flethuseo »