summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-02-06 02:25:25 (UTC)
committer llornkcor <llornkcor>2005-02-06 02:25:25 (UTC)
commitc3892e6c1a4ca15383a7da48f6d72b1d7d26f43d (patch) (unidiff)
treef4d401a3479c04923e11da27ef976bd21df4d12c
parent57d3426a26a2695be0d5358c99be3db9a90da806 (diff)
downloadopie-c3892e6c1a4ca15383a7da48f6d72b1d7d26f43d.zip
opie-c3892e6c1a4ca15383a7da48f6d72b1d7d26f43d.tar.gz
opie-c3892e6c1a4ca15383a7da48f6d72b1d7d26f43d.tar.bz2
adding shell history into command combo off by default
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
@@ -288,72 +288,57 @@ void Konsole::initCommandList()
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 }