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
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "FbRun.hh"
|
||||||
|
|
||||||
|
@ -42,7 +42,8 @@ m_display(BaseDisplay::getXDisplay()),
|
||||||
m_bevel(4),
|
m_bevel(4),
|
||||||
m_gc(DefaultGC(m_display, DefaultScreen(m_display))),
|
m_gc(DefaultGC(m_display, DefaultScreen(m_display))),
|
||||||
m_end(false),
|
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());
|
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);
|
assert(m_win);
|
||||||
XResizeWindow(m_display, m_win, width, height);
|
XResizeWindow(m_display, m_win, width, height);
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height + m_bevel;
|
m_height = height;
|
||||||
setNoMaximize();
|
setNoMaximize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ void FbRun::redrawLabel() {
|
||||||
assert(m_win);
|
assert(m_win);
|
||||||
|
|
||||||
XClearWindow(m_display, 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());
|
m_runtext.c_str(), m_runtext.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,7 +165,18 @@ void FbRun::drawString(int x, int y,
|
||||||
const char *text, size_t len) {
|
const char *text, size_t len) {
|
||||||
assert(m_win);
|
assert(m_win);
|
||||||
assert(m_gc);
|
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,20 +214,23 @@ void FbRun::handleEvent(XEvent * const xev) {
|
||||||
} else if (ks == XK_Return) {
|
} else if (ks == XK_Return) {
|
||||||
run(m_runtext);
|
run(m_runtext);
|
||||||
m_runtext = ""; // clear text
|
m_runtext = ""; // clear text
|
||||||
} else if (ks == XK_BackSpace && m_runtext.size() != 0) {
|
} else if (ks == XK_BackSpace) {
|
||||||
m_runtext.erase(m_runtext.size()-1);
|
if (m_runtext.size() != 0) { // we can't erase what we don't have ;)
|
||||||
redrawLabel();
|
m_runtext.erase(m_runtext.size()-1);
|
||||||
|
redrawLabel();
|
||||||
|
}
|
||||||
} else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
|
} else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
|
||||||
m_runtext+=keychar[0]; // append character
|
m_runtext+=keychar[0]; // append character
|
||||||
redrawLabel();
|
redrawLabel();
|
||||||
} else if (IsCursorKey(ks)) {
|
} else if (IsCursorKey(ks)) {
|
||||||
|
|
||||||
switch (ks) {
|
switch (ks) {
|
||||||
case XK_Up:
|
case XK_Up:
|
||||||
prevHistoryItem();
|
prevHistoryItem();
|
||||||
break;
|
break;
|
||||||
case XK_Down:
|
case XK_Down:
|
||||||
nextHistoryItem();
|
nextHistoryItem();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
redrawLabel();
|
redrawLabel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef FBRUN_HH
|
||||||
#define FBRUN_HH
|
#define FBRUN_HH
|
||||||
|
@ -77,11 +77,12 @@ private:
|
||||||
std::string m_runtext; ///< command to execute
|
std::string m_runtext; ///< command to execute
|
||||||
size_t m_width, m_height; ///< size of window
|
size_t m_width, m_height; ///< size of window
|
||||||
int m_bevel; ///< distance to window edge from font in pixels
|
int m_bevel; ///< distance to window edge from font in pixels
|
||||||
GC m_gc;
|
GC m_gc; ///< graphic context
|
||||||
bool m_end;
|
bool m_end; ///< marks when this object is done
|
||||||
std::vector<std::string> m_history; ///< history list of commands
|
std::vector<std::string> m_history; ///< history list of commands
|
||||||
size_t m_current_history_item;
|
size_t m_current_history_item; ///< holds current position in command history
|
||||||
std::string m_history_file;
|
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
|
#endif // FBRUN_HH
|
||||||
|
|
Loading…
Reference in a new issue