Changeset 1313 for code/branches/console/src/core/InputBuffer.cc
- Timestamp:
- May 17, 2008, 3:58:19 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/InputBuffer.cc
r1312 r1313 45 45 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 46 46 this->buffer_ = ""; 47 this->cursor_ = 0; 47 48 } 48 49 … … 52 53 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 53 54 this->buffer_ = ""; 54 } 55 56 void InputBuffer::set(const std::string& input) 55 this->cursor_ = 0; 56 } 57 58 void InputBuffer::unregisterListener(InputBufferListener* listener) 59 { 60 for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) 61 { 62 if ((*it).listener_ == listener) 63 this->listeners_.erase(it++); 64 else 65 ++it; 66 } 67 } 68 69 void InputBuffer::set(const std::string& input, bool update) 70 { 71 this->clear(false); 72 this->insert(input, update); 73 } 74 75 void InputBuffer::insert(const std::string& input, bool update) 76 { 77 for (unsigned int i = 0; i < input.size(); ++i) 78 { 79 this->insert(input[i], false); 80 81 if (update) 82 this->updated(input[i], false); 83 } 84 85 if (update) 86 this->updated(); 87 } 88 89 void InputBuffer::insert(const char& input, bool update) 90 { 91 if (this->charIsAllowed(input)) 92 { 93 this->buffer_.insert(this->cursor_, 1, input); 94 ++this->cursor_; 95 } 96 97 if (update) 98 this->updated(input, true); 99 } 100 101 void InputBuffer::clear(bool update) 57 102 { 58 103 this->buffer_ = ""; 59 this->append(input); 60 } 61 62 void InputBuffer::append(const std::string& input) 63 { 64 for (unsigned int i = 0; i < input.size(); i++) 65 { 66 if (this->charIsAllowed(input[i])) 67 this->buffer_ += input[i]; 68 69 this->updated(input[i], false); 70 } 71 this->updated(); 72 } 73 74 void InputBuffer::append(const char& input) 75 { 76 if (this->charIsAllowed(input)) 77 this->buffer_ += input; 78 79 this->updated(input, true); 80 } 81 82 void InputBuffer::clear() 83 { 84 this->buffer_ = ""; 85 this->updated(); 86 } 87 88 void InputBuffer::removeLast() 89 { 90 this->buffer_ = this->buffer_.substr(0, this->buffer_.size() - 1); 91 this->updated(); 104 this->cursor_ = 0; 105 106 if (update) 107 this->updated(); 108 } 109 110 void InputBuffer::removeBehindCursor(bool update) 111 { 112 if (this->cursor_ > 0) 113 { 114 --this->cursor_; 115 this->buffer_.erase(this->cursor_, 1); 116 117 if (update) 118 this->updated(); 119 } 120 } 121 122 void InputBuffer::removeAtCursor(bool update) 123 { 124 if (this->cursor_ < this->buffer_.size()) 125 { 126 this->buffer_.erase(this->cursor_, 1); 127 128 if (update) 129 this->updated(); 130 } 92 131 } 93 132 … … 130 169 if (e.key == OIS::KC_V) 131 170 { 132 this-> append(fromClipboard());171 this->insert(fromClipboard()); 133 172 return true; 134 173 } … … 149 188 if (e.key == OIS::KC_INSERT) 150 189 { 151 this-> append(fromClipboard());190 this->insert(fromClipboard()); 152 191 return true; 153 192 } … … 160 199 } 161 200 162 this-> append((char)e.text);201 this->insert((char)e.text); 163 202 return true; 164 203 }
Note: See TracChangeset
for help on using the changeset viewer.