Name

LogView — scrollable log lines like "tail -f"

Synopsis

LogView ( string label ,
  integer visibleLines ,
  integer maxLines );
 

Parameters

string label

(above the log lines)

integer visibleLines

number of visible lines (without scrolling)

integer maxLines

number of log lines to store (use 0 for "all")

Description

A scrolled output-only text window where ASCII output of any kind can be redirected - very much like a shell window with "tail -f".

The LogView will keep up to "maxLines" of output, discarding the oldest lines if there are more. If "maxLines" is set to 0, all lines will be kept.

"visibleLines" lines will be visible by default (without scrolling) unless you stretch the widget in the layout.

Use ChangeWidget( `id( `log ), `LastLine, "bla blurb...\n" ) to append one or several line(s) to the output. Notice the newline at the end of each line!

Use ChangeWidget( `id( `log ), `Value, "bla blurb...\n" ) to replace the entire contents of the LogView.

Use ChangeWidget( `id( `log ), `Value, "" ) to clear the contents.

Usage

 	`LogView( "Log file", 4, 200 );

Examples

          {
    string part1 =
	"They sought it with thimbles, they sought it with care;\n"	+
	"They pursued it with forks and hope;\n"			+
	"They threatened its life with a railway-share;\n"		+
	"They charmed it with smiles and soap. \n"			+
	"\n";
    
    string part2 =
	"Then the Butcher contrived an ingenious plan\n"		+
	"For making a separate sally;\n"				+
	"And fixed on a spot unfrequented by man,\n"			+
	"A dismal and desolate valley. \n"				+
	"\n";
    
    string part3 =
	"But the very same plan to the Beaver occurred:\n"		+
	"It had chosen the very same place:\n"				+
	"Yet neither betrayed, by a sign or a word,\n"			+
	"The disgust that appeared in his face. \n"			+
	"\n";
    
    string part4 =
	"Each thought he was thinking of nothing but \"Snark\"\n"	+
	"And the glorious work of the day;\n"				+
	"And each tried to pretend that he did not remark\n"		+
	"That the other was going that way. \n"				+
	"\n";
    
    string part5 =
	"But the valley grew narrow and narrower still,\n"		+
	"And the evening got darker and colder,\n"			+
	"Till (merely from nervousness, not from goodwill)\n"		+
	"They marched along shoulder to shoulder. \n"			+
	"\n";
    
    string part6 =
	"Then a scream, shrill and high, rent the shuddering sky,\n"	+
	"And they knew that some danger was near:\n"			+
	"The Beaver turned pale to the tip of its tail,\n"		+
	"And even the Butcher felt queer. \n"				+
	"\n";
    
    string part7 =
	"He thought of his childhood, left far far behind--\n"		+
	"That blissful and innocent state--\n"				+
	"The sound so exactly recalled to his mind\n"			+
	"A pencil that squeaks on a slate! \n"				+
	"\n";
    
    string part8 =
	"\"'Tis the voice of the Jubjub!\" he suddenly cried.\n"	+
	"(This man, that they used to call \"Dunce.\")\n"		+
	"\"As the Bellman would tell you,\" he added with pride,\n"	+
	"\"I have uttered that sentiment once.\n"			+
	"\n";

    string thats_it = "\n\n*** Press [OK] once more to exit. ***";
    
    
    UI::OpenDialog(
	       `VBox(
		     `LogView(`id(`log),
			      "&Excerpt from \"The Hunting Of The Snark\" by Lewis Carroll",
			      5,	// visible lines
			      10),	// lines to store
		     `PushButton(`opt(`default), "&OK")
		     )
	       );

    UI::ChangeWidget(`id(`log), `LastLine, part1 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part2 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part3 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part4 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part5 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part6 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part7 );	UI::UserInput();
    UI::ChangeWidget(`id(`log), `LastLine, part8 );	UI::UserInput();
    
    UI::ChangeWidget(`id(`log), `Value, thats_it); UI::UserInput();
    UI::CloseDialog();
}