Changeset 43324 in vbox
- Timestamp:
- Sep 13, 2012 9:33:37 PM (12 years ago)
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgConsole.cpp
r38814 r43324 146 146 147 147 VBoxDbgConsoleInput::VBoxDbgConsoleInput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/) 148 : QComboBox(pParent), m_iBlankItem(0), m_hGUIThread(RTThreadNativeSelf()) 149 { 150 insertItem(m_iBlankItem, ""); 148 : QComboBox(pParent), m_hGUIThread(RTThreadNativeSelf()) 149 { 150 addItem(""); /* invariant: empty command line is the last item */ 151 151 152 setEditable(true); 152 153 setInsertPolicy(NoInsert); … … 181 182 { 182 183 Assert(m_hGUIThread == RTThreadNativeSelf()); 184 185 QString command = currentText(); 186 /* TODO: trim whitespace? */ 187 if (command.isEmpty()) { 188 return; 189 } 190 183 191 /* deal with the current command. */ 184 QString Str = currentText(); 185 emit commandSubmitted(Str); 186 187 /* update the history and clear the entry field */ 188 QString PrevStr = m_iBlankItem > 0 ? itemText(m_iBlankItem - 1) : ""; 189 if (PrevStr != Str) 190 { 191 setItemText(m_iBlankItem, Str); 192 if ( m_iBlankItem > 0 193 && m_iBlankItem >= maxCount() - 1) 194 removeItem(m_iBlankItem - maxCount() - 1); 195 insertItem(++m_iBlankItem, ""); 196 } 197 198 clearEditText(); 199 setCurrentIndex(m_iBlankItem); 192 emit commandSubmitted(command); 193 194 195 /* 196 * Add current command to history. 197 */ 198 bool needsAppending = true; 199 200 /* invariant: empty line at the end */ 201 int lastItem = count() - 1; 202 Assert(itemText(lastItem).isEmpty()); 203 204 /* have previous command? check duplicate. */ 205 if (lastItem > 0) { 206 const QString prevCommand(itemText(lastItem - 1)); 207 if (command == prevCommand) { 208 needsAppending = false; 209 } 210 } 211 212 if (needsAppending) { 213 /* history full? drop the oldest command. */ 214 if (count() == maxCount()) { 215 removeItem(0); 216 --lastItem; 217 } 218 219 /* insert before the empty line. */ 220 insertItem(lastItem, command); 221 } 222 223 /* invariant: empty line at the end */ 224 int newLastItem = count() - 1; 225 Assert(itemText(newLastItem).isEmpty()); 226 227 /* select empty line to present "new" command line to the user */ 228 setCurrentIndex(newLastItem); 200 229 } 201 230 -
trunk/src/VBox/Debugger/VBoxDbgConsole.h
r38813 r43324 118 118 119 119 protected: 120 /** The current blank entry. */121 int m_iBlankItem;122 120 /** The handle to the GUI thread. */ 123 121 RTNATIVETHREAD m_hGUIThread;
Note:
See TracChangeset
for help on using the changeset viewer.