Menu

#1365 Output pane should respect the quiet flag

Committed
closed
nobody
5
2020-09-11
2020-06-28
No

SciTEDoc.html:

A final command property that is currently supported only on windows is command.quiet. A value of 1 indicates that the command I/O should not be echoed to the output pane. This may be useful in combination with command.input and command.replace.selection.

Although it (correctly) doesn't echo the output, it (opinionatedly) still forces a popup on the output pane.

This fixes it.

diff --git a/scite/src/JobQueue.cxx b/scite/src/JobQueue.cxx
index 1e3b168..a6f4834 100644
--- a/scite/src/JobQueue.cxx
+++ b/scite/src/JobQueue.cxx
@@ -258,7 +258,7 @@ void JobQueue::AddCommand(const std::string &command, const FilePath &directory,
            jobUsesOutputPane = false;
        jobQueue[commandCurrent] = Job(command, directory, jobType, input, flags);
        commandCurrent++;

-       if (jobType == jobCLI)
+       if (jobType == jobCLI && !(flags & jobQuiet))
            jobUsesOutputPane = true;
        // For jobExtension, the Trace() method shows output pane on demand.
    }

Discussion

  • Dejan Budimir

    Dejan Budimir - 2020-06-28

    We should also test for the windows platform here, so as not to break expected behavior on non-windows systems. But if this is ok, then the new doc should probably read something like this:

    A final command property[-that is currently supported only on windows-] is command.quiet. A value of 1 indicates that the command I/O should not be echoed to the output [-pane.-]{+pane (on windows systems) and that the output pane should not be toggeled open if it's hidden.+} This may be useful in combination with command.input and command.replace.selection.

     
  • Dejan Budimir

    Dejan Budimir - 2020-06-28

    How best to test it though? I reckon that there should be no platform-specific code in src/.

     
  • Dejan Budimir

    Dejan Budimir - 2020-06-28

    In case we want to use the, provisioned but currently unsued, jobVeryQuiet flag for this (and more), here's a first patch towards making the flag usable.

    diff --git a/scite/src/JobQueue.cxx b/scite/src/JobQueue.cxx
    index 1e3b168..ff60799 100644
    --- a/scite/src/JobQueue.cxx
    +++ b/scite/src/JobQueue.cxx
    @@ -50,7 +50,7 @@ JobSubsystem SubsystemFromChar(char c) noexcept {
     }
    
     JobMode::JobMode(PropSetFile &props, int item, const char *fileNameExt) : jobType(jobCLI), saveBefore(0), isFilter(false), flags(0) {
    
    -   bool quiet = false;
    +   int quiet = 0;
        int repSel = 0;
        bool groupUndo = false;
    
    @@ -90,9 +90,11 @@ JobMode::JobMode(PropSetFile &props, int item, const char *fileNameExt) : jobTyp
    
            if (opt == "quiet") {
                if (value.empty() || value[0] == '1' || value == "yes")
    
    -               quiet = true;
    -           else if (value[0] == '0' || value == "no")
    -               quiet = false;
    +               quiet = 1;
    +           // else if (value[0] == '0' || value == "no")
    +           //  quiet = 0;
    +           else if (value[0] == '2' || value == "extra")
    +               quiet = 2;
            }
    
            if (opt == "savebefore") {
    @@ -114,8 +116,8 @@ JobMode::JobMode(PropSetFile &props, int item, const char *fileNameExt) : jobTyp
            if (opt == "replaceselection") {
                if (value.empty() || value[0] == '1' || value == "yes")
                    repSel = 1;
    
    -           else if (value[0] == '0' || value == "no")
    -               repSel = 0;
    +           // else if (value[0] == '0' || value == "no")
    +           //  repSel = 0;
                else if (value == "auto")
                    repSel = 2;
            }
    @@ -161,9 +163,12 @@ JobMode::JobMode(PropSetFile &props, int item, const char *fileNameExt) : jobTyp
        propName = "command.quiet.";
        propName += itemSuffix;
        if (props.GetWild(propName.c_str(), fileNameExt).length())
    -       quiet = props.GetNewExpandString(propName.c_str(), fileNameExt) == "1";
    -   if (quiet)
    +       quiet = atoi(props.GetNewExpandString(propName.c_str(), fileNameExt).c_str());
    +
    +   if (quiet == 1)
            flags |= jobQuiet;
    +   if (quiet == 2)
    +       flags |= (jobQuiet | jobQuietExtra);
    
        propName = "command.replace.selection.";
        propName += itemSuffix;
    diff --git a/scite/src/JobQueue.h b/scite/src/JobQueue.h
    index ef094d7..9d0a82d 100644
    --- a/scite/src/JobQueue.h
    +++ b/scite/src/JobQueue.h
    @@ -18,14 +18,15 @@ enum JobSubsystem {
     JobSubsystem SubsystemFromChar(char c) noexcept;
    
     enum JobFlags {
    
    -   jobForceQueue = 1,
    -   jobHasInput = 2,
    -   jobQuiet = 4,
    -   // 8 reserved for jobVeryQuiet
    -   jobRepSelMask = 48,
    -   jobRepSelYes = 16,
    -   jobRepSelAuto = 32,
    -   jobGroupUndo = 64
    +   jobForceQueue = 0b00000001, // 1
    +   jobHasInput =   0b00000010, // 2
    +   jobQuiet =      0b00000100, // 4
    +   jobQuietExtra = 0b00001000, // 8
    +   jobRepSelYes =  0b00010000, // 16
    +   jobRepSelAuto = 0b00100000, // 32
    +   jobGroupUndo =  0b01000000, // 64
    +   jobQuietMask =  0b00001100, // 12
    +   jobRepSelMask = 0b00110000, // 48
     };
    
     struct JobMode {
    
     
  • Dejan Budimir

    Dejan Budimir - 2020-06-29

    We should also test for the windows platform here

    How best to test it though?

    I see now that use of #if defined(_WIN32) is common.

     
  • Dejan Budimir

    Dejan Budimir - 2020-06-29

    I'm happy with this:

    diff --git a/scite/src/JobQueue.cxx b/scite/src/JobQueue.cxx
    index 1e3b168..f418a6e 100644
    --- a/scite/src/JobQueue.cxx
    +++ b/scite/src/JobQueue.cxx
    @@ -260,6 +260,10 @@ void JobQueue::AddCommand(const std::string &command, const FilePath &directory,
            commandCurrent++;
            if (jobType == jobCLI)
                jobUsesOutputPane = true;
    +#if defined(_WIN32)
    
    +       if (flags & jobQuiet)
    +           jobUsesOutputPane = false;
    +#endif
            // For jobExtension, the Trace() method shows output pane on demand.
        }
     }
    
     
  • Neil Hodgson

    Neil Hodgson - 2020-07-01

    _WIN32 is actually rarely used nowadays compared to early SciTE. It is almost always a bad idea. The reason that jobQuiet is Windows-only is just that the contributor only wrote that. It would be better to implement jobQuiet on GTK and remove the "windowsonly" documentation.

     
    • Dejan Budimir

      Dejan Budimir - 2020-07-02

      Sure, let's do that. I don't know GTK though, so I hope somebody else steps
      up.

       
  • Neil Hodgson

    Neil Hodgson - 2020-07-06

    Attached is a patch for GTK.

    diff -r 3746e2f2c1dc gtk/SciTEGTK.cxx
    --- a/gtk/SciTEGTK.cxx  Sun Jun 28 09:31:05 2020 +1000
    +++ b/gtk/SciTEGTK.cxx  Mon Jul 06 15:59:48 2020 +1000
    @@ -2579,7 +2579,9 @@
        int count = read(fdFIFO, buf, sizeof(buf) - 1);
        if (count > 0) {
            buf[count] = '\0';
    
    -       OutputAppendString(buf);
    +       if (!(lastFlags & jobQuiet)) {
    +           OutputAppendString(buf);
    +       }
            lastOutput += buf;
        } else if (count == 0) {
            std::string sExitMessage = StdStringFromInteger(WEXITSTATUS(exitStatus));
    
     
  • Neil Hodgson

    Neil Hodgson - 2020-07-06

    Documentation patch.

     

    Last edit: Neil Hodgson 2020-07-06
  • Neil Hodgson

    Neil Hodgson - 2020-08-09
    • labels: --> scite, job
    • Group: Initial --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2020-08-09

    Committed with [d227a2].

     

    Related

    Commit: [d227a2]

  • Neil Hodgson

    Neil Hodgson - 2020-09-11
    • status: open --> closed
     
  • Neil Hodgson

    Neil Hodgson - 2020-09-11

    Committed with [d227a2].

     

    Related

    Commit: [d227a2]

  • Neil Hodgson

    Neil Hodgson - 2020-09-11
     
  • Neil Hodgson

    Neil Hodgson - 2020-09-11

    Committed with [d227a2].

     

    Related

    Commit: [d227a2]


Log in to post a comment.

MongoDB Logo MongoDB