Author Topic: Want to quickly copy the path and filename to your clipboard?  (Read 4878 times)

Mike

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 100
  • Hero Points: 20
//This macro will put the path and filename of the current buffer on the clipboard

#include "slick.sh"

_command void copy_path_filename_to_clipboard() name_info(',')
{
   _str buf_name=p_buf_name;
   int temp_view_id;
   int orig_view_id=_create_temp_view(temp_view_id);
  // say('copy_filename_to_clipboard temp_view_id='temp_view_id);
   p_view_id=temp_view_id;
   _insert_text(buf_name);
   copy_to_clipboard();
   p_view_id=orig_view_id;
   _delete_temp_view(temp_view_id);
}

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 288
Re: Want to quickly copy the path and filename to your clipboard?
« Reply #1 on: July 28, 2006, 06:20:41 am »
I've written these little ones:
Code: [Select]
// clipboard_type == 'CHAR' , 'LINE' or 'BLOCK'
_command int text_to_clipboard (_str text = '', _str clipboard_type = 'CHAR', _str clipboard_name = '')
{
   if ( length ( text ) )
   {
      push_clipboard_itype (clipboard_type,clipboard_name,1,true);
      append_clipboard_text (text);
      return(0);
   }
   else
      return(TEXT_NOT_SELECTED_RC);
}

_command void ccb,copy_current_buffer () name_info (','VSARG2_MARK|VSARG2_TEXT_BOX|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   text_to_clipboard (strip_filename (p_buf_name,'DP'));
   message ( "'" strip_filename (p_buf_name,'DP') "' copied to clipboard")
}
_command void ccbf_copy_current_buffer_full () name_info (','VSARG2_MARK|VSARG2_TEXT_BOX|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   hs2_text_to_clipboard (p_buf_name);
   message ( "'" p_buf_name "' copied to clipboard")
}

_command void ccp,copy_current_proc () name_info (','VSARG2_MARK|VSARG2_TEXT_BOX|VSARG2_REQUIRES_EDITORCTL|VSARG2_READ_ONLY)
{
   _str cur_proc = '', cur_class = '';

   cur_proc = current_proc ( false );
   cur_class = current_class ( false );

   if ( length ( cur_class ) )
      cur_proc = cur_class :+ '::' :+ cur_proc;

   text_to_clipboard ( cur_proc );
   message ( "'" cur_proc "' copied to clipboard")
}

Although the 'temp_view' approach is more versatile.
HS2