#include "options.hpp" slop::Options* options = new slop::Options(); slop::Options::Options() { m_borderSize = 10; m_padding = 0; m_xdisplay = ":0"; m_tolerance = 4; m_red = 0; m_green = 0; m_blue = 0; m_gracetime = 0.3; m_keyboard = true; m_decorations = true; m_offsetx = 0; m_offsety = 0; m_offsetw = 0; m_offseth = 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( " -o=GEOMETRY, --offset=GEOMETRY Offsets window selections, but only if --nodecorations is active and if the\n" ); printf( " window's decorations were successfully detected. Has a very specific use of\n" ); printf( " removing shadows from Gnome's window selections right now. GEOMETRY is in\n" ); printf( " format WxH+X+Y\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, but include the 28px titlebar. Useful to remove the arbitrarily sized shadows in Gnome where they are included in window geometry for whatever reason.\n" ); printf( " $ slop -nd -o=0x28+0-28\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