Author Topic: Perform a command on all files in a workspace?  (Read 750 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Perform a command on all files in a workspace?
« on: September 09, 2020, 08:52:38 pm »
How can I do some command (beautify, tabs-to-spaces, etc) on
All files in project,
All files in workspace
or some other selection of files?

Graeme

  • Senior Community Member
  • Posts: 2718
  • Hero Points: 337
Re: Perform a command on all files in a workspace?
« Reply #1 on: September 09, 2020, 10:54:41 pm »
You could use the file manager  - or see this function in xxutils - you might be able to customise it.

Code: [Select]
_command void xbeautify_project(boolean ask = true, boolean no_preview = false, boolean autosave = true) name_info(',')
{
   _str files_to_beautify [];

   //_GetWorkspaceFiles(_workspace_filename, files_to_beautify);
   _getProjectFiles( _workspace_filename, _project_get_filename(), files_to_beautify, 1);

   if (ask && !no_preview) {
      activate_preview();
   }

   int k;
   for (k = 0; k < files_to_beautify._length(); ++k) {
      if (ask) {

         if (!no_preview) {
            struct VS_TAG_BROWSE_INFO cm;
            tag_browse_info_init(cm);
            cm.member_name = files_to_beautify[k];
            cm.file_name = files_to_beautify[k];
            cm.line_no = 1;
            cb_refresh_output_tab(cm, true, false, false);
            _UpdateTagWindowDelayed(cm, 0);
         }

         _str res = _message_box("Beautify " :+ files_to_beautify[k], "Beautify project", MB_YESNOCANCEL|IDYESTOALL);
         if (res == IDCANCEL) return;
         if (res == IDNO) continue;
         if (res == IDYESTOALL) ask = false;
      }

      if (edit("+B " :+ files_to_beautify[k]) == 0) {
         beautify();
         if (autosave) save();
      }
      else
      {
         edit(files_to_beautify[k]);
         beautify();
         if (autosave) save();
         quit();
      }
   }
}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6273
  • Hero Points: 484
Re: Perform a command on all files in a workspace?
« Reply #2 on: September 10, 2020, 05:17:05 pm »
How can I do some command (beautify, tabs-to-spaces, etc) on
All files in project,
All files in workspace
or some other selection of files?

List and select the files in the File Manager, then File>File Manager>Repeat Command

edit-with "%f" beautify

The only bad thing about edit-with is it prompts to save every time (No go/all option). I'll see if I can add that.





jporkkahtc

  • Senior Community Member
  • Posts: 2509
  • Hero Points: 206
  • Text
Re: Perform a command on all files in a workspace?
« Reply #3 on: September 10, 2020, 06:48:30 pm »
Thanks.
I hadn't thought of the file-manager....its something I've just never got into using.

History question: Is the file-manager a really old feature from the early days of slick, maybe pre-windows even?

LBCEi

  • Senior Community Member
  • Posts: 232
  • Hero Points: 21
Re: Perform a command on all files in a workspace?
« Reply #4 on: September 11, 2020, 12:25:11 am »
File manager is a feature that I was completely unaware of. 

Where in the documentation would I find an overview of what it can do so that I might learn if it would be useful?  Sounds like it might if I only knew about it.