From e607410e1f3ff04dc8f849dda4bbb83f42d9ca65 Mon Sep 17 00:00:00 2001 From: urchlay Date: Sat, 25 Jun 2005 01:13:00 +0000 Subject: [PATCH] Label completion behaves almost identical to bash completion now. If you have labels "food" and "foobar", and no others starting with "f", and you type "pr f", it will show you both of them, then leave your prompt looking like "pr foo" with the cursor after the 2nd "o". Differences from bash: - In case of multiple completions, bash's default behaviour requires you to press Tab twice to see them. We only need one Tab. bash can actually be configured to only need one Tab, too. - We don't beep. Ever. - We're case-insensitive. bash is case-sensitive by default, though it can be configured to be insensitive. There's one remaining bug in the completion: when we get to the bottom of the scroll buffer, and the buffer is full (e.g. when the scroll bar handle is at its minimum size), *and* there's only one possible completion, the console prints a new blank line after the new (completed) prompt. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@559 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/EquateList.cxx | 40 ++++++++++++++++++++++++------ stella/src/debugger/EquateList.hxx | 4 ++- stella/src/gui/PromptWidget.cxx | 29 ++++++++++++++-------- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/stella/src/debugger/EquateList.cxx b/stella/src/debugger/EquateList.cxx index dc4091ea9..7b70259ea 100644 --- a/stella/src/debugger/EquateList.cxx +++ b/stella/src/debugger/EquateList.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EquateList.cxx,v 1.15 2005-06-24 00:03:39 urchlay Exp $ +// $Id: EquateList.cxx,v 1.16 2005-06-25 01:13:00 urchlay Exp $ //============================================================================ #include @@ -182,9 +182,11 @@ bool EquateList::saveFile(string file) { out << "--- Symbol List (sorted by symbol)" << endl; - int hardSize = sizeof(hardCodedEquates)/sizeof(struct Equate); + // we don't have these pre-loaded any more. + // int hardSize = sizeof(hardCodedEquates)/sizeof(struct Equate); + // for(int i=hardSize; i= 0) { sprintf(buf, "%-24s %04x \n", ourVcsEquates[i].label, a); @@ -209,13 +211,19 @@ string EquateList::loadFile(string file) { if(!in.is_open()) return "Unable to read symbols from " + file; - int hardSize = sizeof(hardCodedEquates)/sizeof(struct Equate); // Make sure the hard-coded equates show up first ourVcsEquates.clear(); + + /* + // Don't preload these: they cause more trouble than they're worth + // Besides which, any sane symfile will already have them all. + + int hardSize = sizeof(hardCodedEquates)/sizeof(struct Equate); for(int i=0; idebugger().equates()->countCompletions(str + lastSpace + 1); if(possibilities < 1) { delete[] str; break; } + nextLine(); + const char *got = instance()->debugger().equates()->getCompletions(); if(possibilities == 1) { // add to buffer as though user typed it (plus a space) _currentPos = _promptStartPos + lastSpace + 1; while(*got != '\0') { - _buffer[_currentPos++] = *got++; + putcharIntern(*got++); } - _buffer[_currentPos++] = ' '; + putcharIntern(' '); _promptEndPos = _currentPos; } else { - // add to buffer as-is, then add PROMPT plus whatever the user's typed + // add to buffer as-is, then add PROMPT plus whatever we have so far + _currentPos = _promptStartPos + lastSpace + 1; + + print("\n"); print(got); print("\n"); print(PROMPT); - print(str); - int offset = _currentPos - oldPos; - _promptStartPos += offset; - _promptEndPos += offset; + + _promptStartPos = _currentPos; + + for(i=0; idebugger().equates()->getCompletionPrefix() ); + _promptEndPos = _currentPos; } draw(); delete[] str;