Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/chat/src/orxonox/ChatInputHandler.cc @ 6776

Last change on this file since 6776 was 6776, checked in by smerkli, 15 years ago

Added ChatInputHandler facilities and started implementing them.

File size: 4.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Sandro 'smerkli' Merkli
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "ChatInputHandler.h"
30
31namespace orxonox
32{
33  /* constructor */
34  void ChatInputHandler::ChatInputHandler()
35  {
36    /* create necessary objects */
37    this->inpbuf = new InputBuffer();
38
39                configureInputBuffer();
40  }
41
42  void ChatInputHandler::configureInputBuffer()
43  {
44          /* input has changed */
45    this->inputBuffer_->registerListener(this, &ChatInputHandler::inputChanged, true);
46               
47                /* add a line */
48    this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
49    this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
50
51                /* backspace */
52    this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
53    this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
54
55                /* exit the chatinputhandler thingy (tbd) */
56    this->inputBuffer_->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
57
58                /* delete character */
59    this->inputBuffer_->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
60
61                /* cursor movement */
62    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
63    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
64    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
65    this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
66  }
67
68  /* callbacks for InputBuffer */
69  void ChatInputHandler::inputChanged()
70  {
71    //this->updateListeners<&ShellListener::inputChanged>();
72    //this->updateListeners<&ShellListener::cursorChanged>();
73  }
74
75  void ChatInputHandler::addline()
76  {
77    /* MARK MARK */
78
79    /* actually do send what was input */
80    /* a) get the string out of the inputbuffer */
81
82    /* b) clear the input buffer */
83
84    /* c) send the chat via some call */
85
86    /* d) stop listening to input  */
87  }
88
89  void ChatInputHandler::backspace()
90  {
91    this->inputBuffer_->removeBehindCursor();
92    //this->updateListeners<&ShellListener::inputChanged>();
93    //this->updateListeners<&ShellListener::cursorChanged>();
94  }
95
96  void ChatInputHandler::deleteChar()
97  {
98    this->inputBuffer_->removeAtCursor();
99    //this->updateListeners<&ShellListener::inputChanged>();
100  }
101
102  void ChatInputHandler::cursorRight()
103  {
104    this->inputBuffer_->increaseCursor();
105    //this->updateListeners<&ShellListener::cursorChanged>();
106  }
107 
108  void ChatInputHandler::cursorLeft()
109  {
110    this->inputBuffer_->decreaseCursor();
111    //this->updateListeners<&ShellListener::cursorChanged>();
112  }
113 
114  void ChatInputHandler::cursorEnd()
115  {
116    this->inputBuffer_->setCursorToEnd();
117    //this->updateListeners<&ShellListener::cursorChanged>();
118  }
119
120  void ChatInputHandler::cursorHome()
121  {
122    this->inputBuffer_->setCursorToBegin();
123    //this->updateListeners<&ShellListener::cursorChanged>();
124  }
125
126  void ChatInputHandler::exit()
127  {
128    //if (this->inputBuffer_->getSize() > 0)
129    //{
130      //this->clearInput();
131      //return;
132    //}
133
134    //this->clearInput();
135    //this->scrollPosition_ = 0;
136    //this->scrollIterator_ = this->outputLines_.begin();
137
138    //this->updateListeners<&ShellListener::exit>();
139  }
140
141}
Note: See TracBrowser for help on using the repository browser.