bugGNU Octave - Bugs: bug #61000, clc command does not totally clean...

 
 

bug #61000: clc command does not totally clean the command window. The history can still be traversed using the scroll bar.

Submitter:  None
Submitted:  Sun 01 Aug 2021 09:59:36 PM UTC
   
 
Category:  GUI Severity:  2 - Minor
Priority:  1 - Later Item Group:  Other
Status:  Need Info Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 17 Apr 2022 01:11:52 AM UTC, comment #10: 

Rick and John, it seems that you may have missed a distinction Giang may have been trying to express with regards to the "history".

It seems Octave keeps clc() and home() the same, while Matlab differentiates between the two.  Matlab's home() does exactly what Octave clc() currently does (home the cursor, make window empty, scrollbar at the bottom), while Matlab" clc() additionally clears the terminal of text ("CLear Command window"), while keeping the up-arrow "command history".

This additional functionality of clc() enables the full output of a single program run to be easily seen with the full scroll bar.  For a comparison, try running rand(50) a dozen times and then try using the scroll bar to just view one output. 

In summary, in Matlab, if you want the "reset cursor position" option, you can use home(), and if you want the "reset cursor position and clear all output history" option, you can use clc().  Octave does not currently have this distinction.

Octave help for clc() and home(): Clear the terminal screen and move the cursor to the upper left corner.

Matlab help for clc(): clc clears all the text from the Command Window, resulting in a clear screen. After running clc, you cannot use the scroll bar in the Command Window to see previously displayed text. You can, however, use the up-arrow key ↑ in the Command Window to recall statements from the command history. Use clc in a MATLAB® code file to always display output in the same starting position on the screen.

Matlab help for home(): home moves the cursor to the upper-left corner of the Command Window. home also scrolls all visible text in the Command Window out of view, giving the appearance of clearing the screen without deleting any text. After running the home command, you can use the scroll bar to view the previously displayed text. Use home in a MATLAB® code file to always display output in the same starting position on the screen without clearing the Command Window.

Arnold Wright <ironeagl>
Sat 21 Aug 2021 06:48:08 PM UTC, comment #9: 

Can this report be closed.  Seems like Octave is just following established UNIX standards, and the behavior is going will probably change again when a replacement terminal widget is developed.

Rik <rik5>
Group administrator
Thu 05 Aug 2021 10:00:33 PM UTC, comment #8: 

Many thanks John Eaton for the hint. I'm trying to build a custom Octave with the "clear and reset" effect. I remove the part "Add entire screen to history" of clearEntireScreen() but it does not work. Can you give a hint to modify this function such that the effect works? I hope this feature will be viable in some way for future releases.

Giang <vryy>
Mon 02 Aug 2021 02:34:43 PM UTC, comment #7: 

Whether running in a terminal window in CLI mode or in the GUI (also inside a somewhat capable terminal emulator) Octave normally calls a readline function to clear the terminal.  It just writes whatever escape sequence that terminfo has registered for the "clear" capability.  Then the terminal does whatever it does to clear the screen.  For the QTerminal widget that Octave is currently using, the function that ultimately does the job is Screen::clearEntireScreen in libgui/qterminal/libqterminal/unix/Screen.cpp:


void Screen::clearEntireScreen()
{
  // Add entire screen to history
  for (int i = 0; i < (lines-1); i++)
  {
    addHistLine(); scrollUp(0,1);
  }

  clearImage(loc(0,0),loc(columns-1,lines-1),' ');
}


As noted in comment #5, this is also what bash does because it uses readline.  But what actually happens in the terminal window where bash is running is up to the terminal.  That might be hardware or some teriminal emulation program like xterm or gnome terminal, etc.

Perhaps in the future when we switch to a different type of terminal interface we might do something different.  But for now, I don't think it is worth the effort to change this behavior.  See also https://octave.discourse.group/t/new-command-window-widget/501 for a discussion about the possibility of a new terminal widget.

John W. Eaton <jwe>
Group administrator
Mon 02 Aug 2021 02:12:06 PM UTC, comment #6: 

In fact this comment is for GUI mode. In CLI, I would also prefer doing "clear and reset" as you did.

Giang <vryy>
Mon 02 Aug 2021 01:40:47 PM UTC, comment #5: 

This comment is for CLI not GUI.

For all the years I've used octave, I've usually used the terminal window's "clear and reset" function if I want to eliminate the history. Octave's clc is similar to bash's clear, and neither will remove past commands from history. There isn't a command for that as far as I know because command history is the responsibility of the terminal not the program sending things to the terminal.

I would argue that retaining that behavior is better than combining the two behaviors into clc. Sometimes I only want to clear the screen but not reset history, and sometimes I want to do both.

When Matlab is invoked in CLI mode (e.g. running Matlab server-side through a shell instead of locally) it behaves the same, not clearing command history.

Anonymous
Mon 02 Aug 2021 06:47:20 AM UTC, comment #4: 

Here is the description of Matlab's clc. This is exactly what I want to say: "After running clc, you cannot use the scroll bar in the Command Window to see previously displayed text."

https://de.mathworks.com/help/matlab/ref/clc.html

Giang <vryy>
Mon 02 Aug 2021 06:44:39 AM UTC, comment #3: 


comment #2:

> Does Matlab behave any differently?  My understanding is that clc() is only about clearing visual clutter from the terminal window, and not about clearing history.  In effect, the cursor should be in the upper left, the window should be empty, and the scrollbar should be positioned at the very bottom.


Matlab behaves differently. It will clear the command window output history. It is not the same as command history. You still can access the command history on a separate window. But the command window will be totally empty and not be able to traverse back.

Giang <vryy>
Sun 01 Aug 2021 11:54:05 PM UTC, comment #2: 

Does Matlab behave any differently?  My understanding is that clc() is only about clearing visual clutter from the terminal window, and not about clearing history.  In effect, the cursor should be in the upper left, the window should be empty, and the scrollbar should be positioned at the very bottom.

Rik <rik5>
Group administrator
Sun 01 Aug 2021 10:04:35 PM UTC, comment #1: 

Typo: "story" should be "history"

Giang <vryy>
Sun 01 Aug 2021 09:59:36 PM UTC, original submission:  


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ironeagl (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by vryy (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-08-03 rik5 Carbon-CopyRemoved 72865 -
    2021-08-03 rik5 Priority5 - Normal 1 - Later
        Release6.2.0 dev
    2021-08-01 rik5 CategoryNone GUI
        Severity3 - Normal 2 - Minor
        StatusNone Need Info
    2021-08-01 rik5 Summaryclc command does not totally clean the command window. The story can still be traversed using the scroll bar. clc command does not totally clean the command window. The history can still be traversed using the scroll bar.

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code