#include "options.hpp" slop::Options* options = new slop::Options(); slop::Options::Options() { m_version = "v2.0.5"; m_borderSize = 10; m_padding = 0; m_xdisplay = ":0"; m_tolerance = 2; m_red = 0; m_green = 0; m_blue = 0; m_gracetime = 0.4; m_keyboard = true; m_decorations = true; m_minimumsize = 0; } 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( " -m=INT, --minimumsize=INT sets the minimum output of width or height values, useful to avoid outputting 0\n" ); printf( " widths or heights.\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