[rkward-cvs] rkward/rkward rkconsole.cpp,1.17,1.18

Thomas Friedrichsmeier tfry at users.sourceforge.net
Tue Oct 18 11:48:26 UTC 2005


Update of /cvsroot/rkward/rkward/rkward
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15405/rkward

Modified Files:
	rkconsole.cpp 
Log Message:
New setting to limit number of lines in console. Fix crash related to limited command history

Index: rkconsole.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rkconsole.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rkconsole.cpp	16 Oct 2005 22:01:48 -0000	1.17
--- rkconsole.cpp	18 Oct 2005 11:48:24 -0000	1.18
***************
*** 112,115 ****
--- 112,116 ----
  
  QString RKConsole::currentCommand () {
+ 	RK_TRACE (APP);
  	QString s = text (paragraphs () - 1).right (paragraphLength (paragraphs () - 1) - prefix.length () + 1);
  	s = s.stripWhiteSpace ();
***************
*** 119,122 ****
--- 120,124 ----
  
  void RKConsole::setCurrentCommand (QString command) {
+ 	RK_TRACE (APP);
  	removeParagraph (paragraphs () - 1);
  	append (prefix + command);
***************
*** 125,132 ****
--- 127,136 ----
  
  void RKConsole::cursorAtTheEnd () {
+ 	RK_TRACE (APP);
  	setCursorPosition (paragraphs () - 1, paragraphLength (paragraphs () - 1));
  }
  
  void RKConsole::submitCommand () {
+ 	RK_TRACE (APP);
  	// If we added an item to the list, we delete it here.
  	if (!(commands_history.getLast () == commands_history.current ())){
***************
*** 150,153 ****
--- 154,158 ----
  
  void RKConsole::commandsListUp () {
+ 	RK_TRACE (APP);
  	if (commands_history.getFirst () == commands_history.current ()) {		// already at topmost item
  		return;
***************
*** 163,166 ****
--- 168,172 ----
  
  void RKConsole::commandsListDown () {
+ 	RK_TRACE (APP);
  	if (commands_history.getLast () == commands_history.current ()) {		// already at bottommost item
  		return;
***************
*** 177,184 ****
--- 183,192 ----
  
  void RKConsole::cursorAtTheBeginning () {
+ 	RK_TRACE (APP);
  	setCursorPosition (paragraphs () - 1, prefix.length ());
  }
  
  void RKConsole::rCommandDone (RCommand *command) {
+ 	RK_TRACE (APP);
  	if (command->hasOutput ()) {
  		append (command->output ());
***************
*** 204,207 ****
--- 212,216 ----
  
  void RKConsole::submitBatch (QString batch) {
+ 	RK_TRACE (APP);
  	// splitting batch, not allowing empty entries.
  	// TODO: hack something so we can have empty entries.
***************
*** 211,216 ****
--- 220,232 ----
  
  void RKConsole::tryNextInBatch (bool add_new_line) {
+ 	RK_TRACE (APP);
  	if (add_new_line) {	
  		append (prefix);
+ 		if (RKSettingsModuleConsole::maxConsoleLines ()) {
+ 			uint c = (uint) paragraphs ();
+ 			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
+ 				removeParagraph (0);
+ 			}
+ 		}
  		cursorAtTheEnd ();
  	}
***************
*** 234,237 ****
--- 250,254 ----
  
  void RKConsole::paste () {
+ 	RK_TRACE (APP);
  	QClipboard *cb = QApplication::clipboard ();
  	submitBatch (cb->text ());
***************
*** 239,242 ****
--- 256,260 ----
  
  void RKConsole::clear () {
+ 	RK_TRACE (APP);
  	KTextEdit::clear ();
  	tryNextInBatch ();
***************
*** 244,258 ****
  
  void RKConsole::addCommandToHistory (const QString &command) {
  	commands_history.append (new QString (command.latin1 ()));
  
  	if (RKSettingsModuleConsole::maxHistoryLength ()) {
  		uint c = commands_history.count ();
! 		for (uint ui = c; c > RKSettingsModuleConsole::maxHistoryLength (); --ui) {
  			commands_history.removeFirst ();
  		}
  	}
  }
  
  QPopupMenu *RKConsole::createPopupMenu (const QPoint &pos) {
  	QPopupMenu *mp;
  	emit (fetchPopupMenu (&mp));
--- 262,279 ----
  
  void RKConsole::addCommandToHistory (const QString &command) {
+ 	RK_TRACE (APP);
  	commands_history.append (new QString (command.latin1 ()));
  
  	if (RKSettingsModuleConsole::maxHistoryLength ()) {
  		uint c = commands_history.count ();
! 		for (uint ui = c; ui > RKSettingsModuleConsole::maxHistoryLength (); --ui) {
  			commands_history.removeFirst ();
  		}
+ 		commands_history.last ();
  	}
  }
  
  QPopupMenu *RKConsole::createPopupMenu (const QPoint &pos) {
+ 	RK_TRACE (APP);
  	QPopupMenu *mp;
  	emit (fetchPopupMenu (&mp));





More information about the rkward-tracker mailing list