summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp43
1 files changed, 14 insertions, 29 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index 5cfd644..8b4202d 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -285,78 +285,63 @@ void Konsole::initCommandList()
285 // odebug << "Konsole::initCommandList" << oendl; 285 // odebug << "Konsole::initCommandList" << oendl;
286 Config cfg( "Konsole" ); 286 Config cfg( "Konsole" );
287 cfg.setGroup("Commands"); 287 cfg.setGroup("Commands");
288 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 288 // commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
289 commonCombo->clear(); 289 commonCombo->clear();
290 290
291 if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") 291 if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") {
292 {
293 QString histfilename = QString(getenv("HOME")) + "/.bash_history"; 292 QString histfilename = QString(getenv("HOME")) + "/.bash_history";
294 histfilename = cfg.readEntry("ShellHistoryPath",histfilename); 293 histfilename = cfg.readEntry("ShellHistoryPath",histfilename);
295 QFile histfile(histfilename); 294 QFile histfile(histfilename);
296 // note: compiler barfed on: 295 // note: compiler barfed on:
297 // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); 296 // QFile histfile(QString(getenv("HOME")) + "/.bash_history");
298 if (histfile.open( IO_ReadOnly )) 297 if (histfile.open( IO_ReadOnly )) {
299 {
300 QString line; 298 QString line;
301 uint i; 299 uint i;
302 HistoryList items; 300 HistoryList items;
303 301
304 int lineno = 0; 302 int lineno = 0;
305 while(!histfile.atEnd()) 303 while(!histfile.atEnd()) {
306 { 304 if (histfile.readLine(line, 200) < 0) {
307 if (histfile.readLine(line, 200) < 0)
308 {
309 break; 305 break;
310 } 306 }
311 line = line.left(line.length()-1); 307 line = line.left(line.length()-1);
312 lineno++; 308 lineno++;
313 309
314 for(i=0; i<items.count(); i++) 310 for(i=0; i<items.count(); i++) {
315 { 311 if (line == items.at(i)->line) {
316 if (line == items.at(i)->line)
317 {
318 // weight recent commands & repeated commands more 312 // weight recent commands & repeated commands more
319 // by adding up the index of each command 313 // by adding up the index of each command
320 items.at(i)->count += lineno; 314 items.at(i)->count += lineno;
321 break; 315 break;
322 } 316 }
323 } 317 }
324 if (i >= items.count()) 318 if (i >= items.count()) {
325 {
326 items.append(new HistoryItem(lineno, line)); 319 items.append(new HistoryItem(lineno, line));
327 } 320 }
328 } 321 }
329 items.sort(); 322 items.sort();
330 int n = items.count(); 323 int n = items.count();
331 if (n > 40) 324 if (n > 40) {
332 {
333 n = 40; 325 n = 40;
334 } 326 }
335 for(int i=0; i<n; i++) 327 for(int i=0; i<n; i++) {
336 {
337 // should insert start of command, but keep whole thing 328 // should insert start of command, but keep whole thing
338 if (items.at(items.count()-i-1)->line.length() < 30) 329 if (items.at(items.count()-i-1)->line.length() < 30) {
339 {
340 commonCombo->insertItem(items.at(items.count()-i-1)->line); 330 commonCombo->insertItem(items.at(items.count()-i-1)->line);
341 } 331 }
342 } 332 }
343 histfile.close(); 333 histfile.close();
344 } 334 }
345 } 335 }
346 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") 336 if (cfg.readEntry("Commands Set","FALSE") == "FALSE") {
347 { 337 for (int i = 0; commonCmds[i] != NULL; i++) {
348 for (int i = 0; commonCmds[i] != NULL; i++)
349 {
350 commonCombo->insertItem(commonCmds[i]); 338 commonCombo->insertItem(commonCmds[i]);
351 } 339 }
352 } 340 } else {
353 else 341 for (int i = 0; i < 100; i++) {
354 {
355 for (int i = 0; i < 100; i++)
356 {
357 if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) 342 if (!(cfg.readEntry( QString::number(i),"")).isEmpty())
358 commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); 343 commonCombo->insertItem(cfg.readEntry( QString::number(i),""));
359 } 344 }
360 } 345 }
361 346
362 347