fbrun, add horizontal padding option

This commit is contained in:
Pete Beardmore 2018-03-04 10:17:31 +00:00 committed by Mathias Gumz
parent ed7ea14167
commit 248b15c25f
3 changed files with 14 additions and 0 deletions

View file

@ -62,6 +62,7 @@ FbRun::FbRun(int x, int y, size_t width):
m_font("fixed"), m_font("fixed"),
m_display(FbTk::App::instance()->display()), m_display(FbTk::App::instance()->display()),
m_bevel(4), m_bevel(4),
m_padding(0),
m_gc(*this), m_gc(*this),
m_end(false), m_end(false),
m_current_history_item(0), m_current_history_item(0),
@ -251,6 +252,11 @@ void FbRun::resize(unsigned int width, unsigned int height) {
FbTk::TextBox::resize(width, height); FbTk::TextBox::resize(width, height);
} }
void FbRun::setPadding(int padding) {
m_padding = padding;
FbTk::TextBox::setPadding(padding);
}
void FbRun::redrawLabel() { void FbRun::redrawLabel() {
clear(); clear();
} }

View file

@ -43,6 +43,7 @@ public:
void resize(unsigned int width, unsigned int height); void resize(unsigned int width, unsigned int height);
void setPrint(bool print) { m_print = print; } void setPrint(bool print) { m_print = print; }
void setAutocomplete(bool complete) { m_autocomplete = complete; } void setAutocomplete(bool complete) { m_autocomplete = complete; }
void setPadding(int padding);
/// load and reconfigure for new font /// load and reconfigure for new font
bool loadFont(const std::string &fontname); bool loadFont(const std::string &fontname);
@ -89,6 +90,7 @@ private:
FbTk::Font m_font; ///< font used to draw command text FbTk::Font m_font; ///< font used to draw command text
Display *m_display; ///< display connection Display *m_display; ///< display connection
int m_bevel; int m_bevel;
int m_padding;
FbTk::GContext m_gc; ///< graphic context FbTk::GContext m_gc; ///< graphic context
bool m_end; ///< marks when this object is done bool m_end; ///< marks when this object is done

View file

@ -58,6 +58,7 @@ void showUsage(const char *progname) {
" -print Print result to stdout"<<endl<< " -print Print result to stdout"<<endl<<
" -w [width] Window width in pixels"<<endl<< " -w [width] Window width in pixels"<<endl<<
" -h [height] Window height in pixels"<<endl<< " -h [height] Window height in pixels"<<endl<<
" -pad [size] Padding size in pixels"<<endl<<
" -display [display string] Display name"<<endl<< " -display [display string] Display name"<<endl<<
" -pos [x] [y] Window position in pixels"<<endl<< " -pos [x] [y] Window position in pixels"<<endl<<
" -nearmouse Window position near mouse"<<endl<< " -nearmouse Window position near mouse"<<endl<<
@ -76,6 +77,7 @@ int main(int argc, char **argv) {
int x = 0, y = 0; // default pos of window int x = 0, y = 0; // default pos of window
size_t width = 200, height = 32; // default size of window size_t width = 200, height = 32; // default size of window
bool set_height = false, set_width=false; // use height/width of font by default bool set_height = false, set_width=false; // use height/width of font by default
int padding = 0; // default horizontal padding for text
bool set_pos = false; // set position bool set_pos = false; // set position
bool near_mouse = false; // popup near mouse bool near_mouse = false; // popup near mouse
bool center = false; bool center = false;
@ -107,6 +109,8 @@ int main(int argc, char **argv) {
} else if (arg == "-h" && i+1 < argc) { } else if (arg == "-h" && i+1 < argc) {
height = atoi(argv[++i]); height = atoi(argv[++i]);
set_height = true; // mark true else the height of font will be used set_height = true; // mark true else the height of font will be used
} else if (arg == "-pad" && i+1 < argc) {
padding = atoi(argv[++i]);
} else if ((arg == "-display" || arg == "--display") && i+1 < argc) { } else if ((arg == "-display" || arg == "--display") && i+1 < argc) {
display_name = argv[++i]; display_name = argv[++i];
} else if ((arg == "-pos" || arg == "--pos") && i+2 < argc) { } else if ((arg == "-pos" || arg == "--pos") && i+2 < argc) {
@ -180,8 +184,10 @@ int main(int argc, char **argv) {
cerr<<"FbRun Warning: Failed to load completion file: "<<expanded_filename<<endl; cerr<<"FbRun Warning: Failed to load completion file: "<<expanded_filename<<endl;
} }
fbrun.setPadding(padding);
fbrun.setTitle(title); fbrun.setTitle(title);
fbrun.setText(text); fbrun.setText(text);
if (preselect) if (preselect)
fbrun.selectAll(); fbrun.selectAll();