fixed horiz scrolling and height position
This commit is contained in:
parent
598ff7125d
commit
a47b6927bb
2 changed files with 31 additions and 15 deletions
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: FbRun.cc,v 1.4 2002/11/12 19:20:31 fluxgen Exp $
|
||||
// $Id: FbRun.cc,v 1.5 2002/11/13 16:43:52 fluxgen Exp $
|
||||
|
||||
#include "FbRun.hh"
|
||||
|
||||
|
@ -42,7 +42,8 @@ m_display(BaseDisplay::getXDisplay()),
|
|||
m_bevel(4),
|
||||
m_gc(DefaultGC(m_display, DefaultScreen(m_display))),
|
||||
m_end(false),
|
||||
m_current_history_item(0) {
|
||||
m_current_history_item(0),
|
||||
m_drawstart_x(0) {
|
||||
createWindow(x, y, width + m_bevel, m_font.height());
|
||||
}
|
||||
|
||||
|
@ -137,7 +138,7 @@ void FbRun::resize(size_t width, size_t height) {
|
|||
assert(m_win);
|
||||
XResizeWindow(m_display, m_win, width, height);
|
||||
m_width = width;
|
||||
m_height = height + m_bevel;
|
||||
m_height = height;
|
||||
setNoMaximize();
|
||||
}
|
||||
|
||||
|
@ -155,7 +156,7 @@ void FbRun::redrawLabel() {
|
|||
assert(m_win);
|
||||
|
||||
XClearWindow(m_display, m_win);
|
||||
drawString(m_bevel/2, m_height - m_bevel/2,
|
||||
drawString(m_bevel/2, m_font.ascent() + m_bevel/2,
|
||||
m_runtext.c_str(), m_runtext.size());
|
||||
|
||||
}
|
||||
|
@ -164,7 +165,18 @@ void FbRun::drawString(int x, int y,
|
|||
const char *text, size_t len) {
|
||||
assert(m_win);
|
||||
assert(m_gc);
|
||||
m_font.drawText(m_win, DefaultScreen(m_display), m_gc, text, len, x, y);
|
||||
// check right boundary
|
||||
// and adjust text drawing
|
||||
size_t text_width = m_font.textWidth(text, len);
|
||||
size_t startpos = 0;
|
||||
if (text_width > m_width) {
|
||||
for (; startpos < len; ++startpos) {
|
||||
if (m_font.textWidth(text+startpos, len-startpos) < m_width)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_font.drawText(m_win, DefaultScreen(m_display), m_gc, text + startpos, len-startpos, x, y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,13 +214,16 @@ void FbRun::handleEvent(XEvent * const xev) {
|
|||
} else if (ks == XK_Return) {
|
||||
run(m_runtext);
|
||||
m_runtext = ""; // clear text
|
||||
} else if (ks == XK_BackSpace && m_runtext.size() != 0) {
|
||||
} else if (ks == XK_BackSpace) {
|
||||
if (m_runtext.size() != 0) { // we can't erase what we don't have ;)
|
||||
m_runtext.erase(m_runtext.size()-1);
|
||||
redrawLabel();
|
||||
}
|
||||
} else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
|
||||
m_runtext+=keychar[0]; // append character
|
||||
redrawLabel();
|
||||
} else if (IsCursorKey(ks)) {
|
||||
|
||||
switch (ks) {
|
||||
case XK_Up:
|
||||
prevHistoryItem();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: FbRun.hh,v 1.3 2002/11/12 19:20:31 fluxgen Exp $
|
||||
// $Id: FbRun.hh,v 1.4 2002/11/13 16:43:52 fluxgen Exp $
|
||||
|
||||
#ifndef FBRUN_HH
|
||||
#define FBRUN_HH
|
||||
|
@ -77,11 +77,12 @@ private:
|
|||
std::string m_runtext; ///< command to execute
|
||||
size_t m_width, m_height; ///< size of window
|
||||
int m_bevel; ///< distance to window edge from font in pixels
|
||||
GC m_gc;
|
||||
bool m_end;
|
||||
GC m_gc; ///< graphic context
|
||||
bool m_end; ///< marks when this object is done
|
||||
std::vector<std::string> m_history; ///< history list of commands
|
||||
size_t m_current_history_item;
|
||||
std::string m_history_file;
|
||||
size_t m_current_history_item; ///< holds current position in command history
|
||||
std::string m_history_file; ///< holds filename for command history file
|
||||
int m_drawstart_x; ///< for scrolling if cursor is to far to the right
|
||||
};
|
||||
|
||||
#endif // FBRUN_HH
|
||||
|
|
Loading…
Reference in a new issue