#include "options.hpp" slop::Options* options = new slop::Options(); slop::Options::Options() { m_version = "v2.0.2"; m_borderSize = 10; m_padding = 0; m_xdisplay = ":0"; m_tolerance = 4; m_red = 0; m_green = 0; m_blue = 0; m_gracetime = 0.4; m_keyboard = true; m_decorations = true; } void slop::Options::printHelp() { printf( "Usage: slop [options]\n" ); printf( "Print user selected region to stdout. Pressing keys or right-clicking cancels selection.\n" ); printf( "\n" ); printf( "Options\n" ); printf( " -h, --help Show this message.\n" ); printf( " -nkb, --nokeyboard Disables the ability to cancel selections with the keyboard.\n" ); printf( " -b=INT, --bordersize=INT Set selection rectangle border size.\n" ); printf( " -p=INT, --padding=INT Set padding size for selection.\n" ); printf( " -t=INT, --tolerance=INT How far in pixels the mouse can move after clicking and still be detected\n" ); printf( " as a normal click. Setting to zero will disable window selections.\n" ); printf( " -x=STRING, --xdisplay=STRING Set x display (STRING must be hostname:number.screen_number format)\n" ); printf( " -c=COLOR, --color=COLOR Set selection rectangle color, COLOR is in format FLOAT,FLOAT,FLOAT\n" ); printf( " -g=FLOAT, --gracetime=FLOAT Set the amount of time before slop will check for keyboard cancellations\n" ); printf( " in seconds.\n" ); printf( " -nd, --nodecorations attempts to remove decorations from window selections.\n" ); printf( " -v, --version prints version.\n" ); printf( "\n" ); printf( "Examples\n" ); printf( " $ # Gray, thick border for maximum visiblity.\n" ); printf( " $ slop -b=20 -c=0.5,0.5,0.5\n" ); printf( "\n" ); printf( " $ # Remove window decorations.\n" ); printf( " $ slop -nd\n" ); printf( "\n" ); printf( " $ # Disable window selections. Useful for selecting individual pixels.\n" ); printf( " $ slop -t=0\n" ); } int slop::Options::parseOptions( int argc, char** argv ) { // Simple command parsing. Just uses sscanf to read each argument. // It looks complicated because you have to have spaces for delimiters for sscanf. for ( int i=0; i