aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun/FbRun.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-13 16:43:52 (GMT)
committerfluxgen <fluxgen>2002-11-13 16:43:52 (GMT)
commita47b6927bb6161fd358c7f0c92e90f8350afc711 (patch)
treea664ac3d9438b59b854d8de67c5cca521d720083 /util/fbrun/FbRun.cc
parent598ff7125d6b035e16bc854547846ca7b606e590 (diff)
downloadfluxbox-a47b6927bb6161fd358c7f0c92e90f8350afc711.zip
fluxbox-a47b6927bb6161fd358c7f0c92e90f8350afc711.tar.bz2
fixed horiz scrolling and height position
Diffstat (limited to 'util/fbrun/FbRun.cc')
-rw-r--r--util/fbrun/FbRun.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 6a0e6d8..d2f468c 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbRun.cc,v 1.4 2002/11/12 19:20:31 fluxgen Exp $ 22// $Id: FbRun.cc,v 1.5 2002/11/13 16:43:52 fluxgen Exp $
23 23
24#include "FbRun.hh" 24#include "FbRun.hh"
25 25
@@ -42,7 +42,8 @@ m_display(BaseDisplay::getXDisplay()),
42m_bevel(4), 42m_bevel(4),
43m_gc(DefaultGC(m_display, DefaultScreen(m_display))), 43m_gc(DefaultGC(m_display, DefaultScreen(m_display))),
44m_end(false), 44m_end(false),
45m_current_history_item(0) { 45m_current_history_item(0),
46m_drawstart_x(0) {
46 createWindow(x, y, width + m_bevel, m_font.height()); 47 createWindow(x, y, width + m_bevel, m_font.height());
47} 48}
48 49
@@ -137,7 +138,7 @@ void FbRun::resize(size_t width, size_t height) {
137 assert(m_win); 138 assert(m_win);
138 XResizeWindow(m_display, m_win, width, height); 139 XResizeWindow(m_display, m_win, width, height);
139 m_width = width; 140 m_width = width;
140 m_height = height + m_bevel; 141 m_height = height;
141 setNoMaximize(); 142 setNoMaximize();
142} 143}
143 144
@@ -155,7 +156,7 @@ void FbRun::redrawLabel() {
155 assert(m_win); 156 assert(m_win);
156 157
157 XClearWindow(m_display, m_win); 158 XClearWindow(m_display, m_win);
158 drawString(m_bevel/2, m_height - m_bevel/2, 159 drawString(m_bevel/2, m_font.ascent() + m_bevel/2,
159 m_runtext.c_str(), m_runtext.size()); 160 m_runtext.c_str(), m_runtext.size());
160 161
161} 162}
@@ -164,7 +165,18 @@ void FbRun::drawString(int x, int y,
164 const char *text, size_t len) { 165 const char *text, size_t len) {
165 assert(m_win); 166 assert(m_win);
166 assert(m_gc); 167 assert(m_gc);
167 m_font.drawText(m_win, DefaultScreen(m_display), m_gc, text, len, x, y); 168 // check right boundary
169 // and adjust text drawing
170 size_t text_width = m_font.textWidth(text, len);
171 size_t startpos = 0;
172 if (text_width > m_width) {
173 for (; startpos < len; ++startpos) {
174 if (m_font.textWidth(text+startpos, len-startpos) < m_width)
175 break;
176 }
177 }
178
179 m_font.drawText(m_win, DefaultScreen(m_display), m_gc, text + startpos, len-startpos, x, y);
168} 180}
169 181
170 182
@@ -202,20 +214,23 @@ void FbRun::handleEvent(XEvent * const xev) {
202 } else if (ks == XK_Return) { 214 } else if (ks == XK_Return) {
203 run(m_runtext); 215 run(m_runtext);
204 m_runtext = ""; // clear text 216 m_runtext = ""; // clear text
205 } else if (ks == XK_BackSpace && m_runtext.size() != 0) { 217 } else if (ks == XK_BackSpace) {
206 m_runtext.erase(m_runtext.size()-1); 218 if (m_runtext.size() != 0) { // we can't erase what we don't have ;)
207 redrawLabel(); 219 m_runtext.erase(m_runtext.size()-1);
220 redrawLabel();
221 }
208 } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) { 222 } else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
209 m_runtext+=keychar[0]; // append character 223 m_runtext+=keychar[0]; // append character
210 redrawLabel(); 224 redrawLabel();
211 } else if (IsCursorKey(ks)) { 225 } else if (IsCursorKey(ks)) {
226
212 switch (ks) { 227 switch (ks) {
213 case XK_Up: 228 case XK_Up:
214 prevHistoryItem(); 229 prevHistoryItem();
215 break; 230 break;
216 case XK_Down: 231 case XK_Down:
217 nextHistoryItem(); 232 nextHistoryItem();
218 break; 233 break;
219 } 234 }
220 redrawLabel(); 235 redrawLabel();
221 } 236 }