2002-08-20 02:05:17 +00:00
|
|
|
// FbRun.hh
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-08-20 02:05:17 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
#ifndef FBRUN_HH
|
|
|
|
#define FBRUN_HH
|
|
|
|
|
2003-08-27 14:04:12 +00:00
|
|
|
#include "FbTk/EventHandler.hh"
|
|
|
|
#include "FbTk/Font.hh"
|
|
|
|
#include "FbTk/FbWindow.hh"
|
|
|
|
#include "FbTk/TextBox.hh"
|
|
|
|
#include "FbTk/GContext.hh"
|
|
|
|
#include "FbTk/FbPixmap.hh"
|
2002-08-20 02:05:17 +00:00
|
|
|
|
|
|
|
#include <string>
|
2002-11-12 19:20:31 +00:00
|
|
|
#include <vector>
|
2002-08-20 02:05:17 +00:00
|
|
|
|
|
|
|
/**
|
2002-12-05 00:07:39 +00:00
|
|
|
Creates and managed a run window
|
2002-08-20 02:05:17 +00:00
|
|
|
*/
|
2003-08-27 00:20:19 +00:00
|
|
|
class FbRun: public FbTk::TextBox {
|
2002-08-20 02:05:17 +00:00
|
|
|
public:
|
2002-12-05 00:07:39 +00:00
|
|
|
FbRun(int x = 0, int y = 0, size_t width = 200);
|
|
|
|
~FbRun();
|
|
|
|
void setTitle(const std::string &title);
|
2003-08-27 00:20:19 +00:00
|
|
|
void resize(unsigned int width, unsigned int height);
|
2008-10-04 21:01:31 +00:00
|
|
|
void setPrint(bool print) { m_print = print; }
|
2016-07-23 06:18:26 +00:00
|
|
|
void setAutocomplete(bool complete) { m_autocomplete = complete; }
|
2018-03-04 10:17:31 +00:00
|
|
|
void setPadding(int padding);
|
2003-08-25 01:16:41 +00:00
|
|
|
|
2002-12-05 00:07:39 +00:00
|
|
|
/// load and reconfigure for new font
|
|
|
|
bool loadFont(const std::string &fontname);
|
2003-08-25 01:16:41 +00:00
|
|
|
void setForegroundColor(const FbTk::Color &color);
|
- Usage of xft-fonts is prefered, except a font-description starts with '-'
- Removed "antialias"-option completly, to enable/disable "antialias"
use either <fontname>:antialias=<bool> in the style or use
Xft.antialias: <bool> in your .Xdefaults
- Added new styleresources:
*.font.effect: <halo|shadow>
*.font.shadow.x : <int> - shadow x offset
*.font.shadow.y : <int> - shadow y offset
*.font.shadow.color : <color> - color of shadow
*.font.halo.color : <color> - color of halo
- Removed 'shadow' and 'halo' options from fontdefinitions:
!! Style authors have to update their styles !!
- Simplified XmbFontImp to not try all possible fonts to match locale
- Style authors may specify multiple fonts:
<font1>|<font2>|<font3>
if loading of font1 fails, fluxbox probes <font2>, etc. The last font is
"fixed". Hints for style authors:
- if xft tries to load a font it will _ALWAYS_ return a valid font,
it doesnt have to look like the one you want to have, read more
about it: http://fontconfig.org/fontconfig-user.html
- export XFT_DEBUG=1 before running fluxbox helps to see
which fonts are picked.
eg:
*.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*-
if fluxbox is compiled with xft this will NEVER try to
load "-artwiz-snap-*-" since xft gives for sure a font,
most likely Verdana or Arial but noone knows. So, if
fluxbox has no xft support the first fontpattern fails
and fluxbox tries the next one, which might be successful.
if everything fails, it will use "fixed"
- Added caching of fonts, fonts are only loaded once.
- Fixed #1090902 (slow utf8 start)
2005-06-03 07:25:48 +00:00
|
|
|
void setAntialias(bool val) { /*m_font.setAntialias(val);*/ }
|
2002-12-05 00:07:39 +00:00
|
|
|
const FbTk::Font &font() const { return m_font; }
|
|
|
|
/// execute command and exit
|
|
|
|
void run(const std::string &execstring);
|
|
|
|
/// is this application done?
|
|
|
|
bool end() const { return m_end; }
|
|
|
|
/**
|
|
|
|
loads history file.
|
|
|
|
@return true on success, else false
|
|
|
|
*/
|
|
|
|
bool loadHistory(const char *filename);
|
2016-07-23 14:39:44 +00:00
|
|
|
bool loadCompletion(const char *filename);
|
2002-12-05 00:07:39 +00:00
|
|
|
/**
|
|
|
|
@name events
|
|
|
|
*/
|
|
|
|
///@{
|
|
|
|
void keyPressEvent(XKeyEvent &ev);
|
|
|
|
///@}
|
2003-06-24 10:22:42 +00:00
|
|
|
|
2006-04-17 14:00:28 +00:00
|
|
|
/// set no maximizable for this window
|
|
|
|
void lockPosition(bool size_too);
|
|
|
|
|
2002-08-20 02:05:17 +00:00
|
|
|
private:
|
2002-12-05 00:07:39 +00:00
|
|
|
void nextHistoryItem();
|
|
|
|
void prevHistoryItem();
|
|
|
|
void drawString(int x, int y, const char *text, size_t len);
|
|
|
|
void getSize(size_t &width, size_t &height);
|
2003-06-24 10:22:42 +00:00
|
|
|
void createWindow(int x, int y, size_t width, size_t height);
|
|
|
|
void redrawLabel();
|
2002-08-20 02:05:17 +00:00
|
|
|
|
2003-08-27 00:20:19 +00:00
|
|
|
void insertCharacter(char key);
|
2003-06-24 10:22:42 +00:00
|
|
|
void adjustStartPos();
|
|
|
|
void adjustEndPos();
|
|
|
|
void firstHistoryItem();
|
|
|
|
void lastHistoryItem();
|
2016-07-22 22:30:25 +00:00
|
|
|
void tabComplete(const std::vector<std::string> &list, int ¤t, bool reverse = false);
|
2004-04-18 14:16:09 +00:00
|
|
|
void tabCompleteApps();
|
2003-06-24 10:22:42 +00:00
|
|
|
|
2008-10-04 21:01:31 +00:00
|
|
|
bool m_print; ///< the input should be printed to stdout rather than run
|
2002-12-05 00:07:39 +00:00
|
|
|
FbTk::Font m_font; ///< font used to draw command text
|
|
|
|
Display *m_display; ///< display connection
|
2003-08-27 00:20:19 +00:00
|
|
|
int m_bevel;
|
2018-03-04 10:17:31 +00:00
|
|
|
int m_padding;
|
2003-08-27 14:04:12 +00:00
|
|
|
FbTk::GContext m_gc; ///< graphic context
|
2002-12-05 00:07:39 +00:00
|
|
|
bool m_end; ///< marks when this object is done
|
2016-07-22 22:30:25 +00:00
|
|
|
|
2002-12-05 00:07:39 +00:00
|
|
|
std::vector<std::string> m_history; ///< history list of commands
|
|
|
|
std::string m_history_file; ///< holds filename for command history file
|
2016-07-22 22:30:25 +00:00
|
|
|
int m_current_history_item; ///< holds current position in command history
|
|
|
|
|
|
|
|
std::vector<std::string> m_files;
|
|
|
|
int m_current_files_item;
|
|
|
|
std::string m_last_completion_path; ///< last prefix we completed on
|
|
|
|
|
|
|
|
std::vector<std::string> m_apps;
|
|
|
|
int m_current_apps_item; ///< holds current position in apps-history
|
|
|
|
|
|
|
|
size_t m_completion_pos;
|
2016-07-23 06:18:26 +00:00
|
|
|
bool m_autocomplete;
|
2016-07-22 22:30:25 +00:00
|
|
|
|
2003-03-22 11:33:04 +00:00
|
|
|
Cursor m_cursor;
|
2003-06-24 10:22:42 +00:00
|
|
|
|
2003-08-27 14:04:12 +00:00
|
|
|
FbTk::FbPixmap m_pixmap;
|
2002-08-20 02:05:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FBRUN_HH
|