1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-03 04:23:42 -05:00

also accept . in ssh hostname

This commit is contained in:
QC 2014-01-26 16:47:26 +01:00
parent 8b6b494830
commit b0ee6ab8dd
4 changed files with 82 additions and 60 deletions

View file

@ -58,13 +58,16 @@ static char * escape_name(const char *mark, ssize_t *length)
char *escaped_mark = malloc( sizeof( char )*( strlen( mark )*2+1 ) );
ssize_t lm = strlen( mark );
*length = 0;
for ( ssize_t iter = 0; iter < lm; iter++ ) {
if ( mark[iter] == '\'' || mark[iter] == '\"' || mark[iter] == '\\' ) {
escaped_mark[( *length )++] = '\\';
}
escaped_mark[( *length )++] = mark[iter];
escaped_mark[( *length )] = '\0';
}
return escaped_mark;
}
@ -73,6 +76,7 @@ static void exec_mark(const char *mark)
{
int s, t, len;
struct sockaddr_un remote;
if ( config.i3_mode == 0 ) {
fprintf( stderr, "Cannot use marks without i3 running\n" );
return ;
@ -134,10 +138,12 @@ static char ** get_mark ( )
{
unsigned int retv_index = 0;
char **retv = NULL;
if ( config.i3_mode == 0 ) {
fprintf( stderr, "Cannot use marks without i3 running\n" );
return retv;
}
#ifdef TIMING
struct timespec start, stop;
clock_gettime( CLOCK_REALTIME, &start );
@ -181,26 +187,34 @@ static char ** get_mark ( )
if ( t == sizeof( head ) ) {
char *result = malloc( sizeof( char )*( head.size+1 ) );
ssize_t index = 0;
// Grab results.
while ( index < head.size ) {
t= recv( s, &result[index], ( head.size-t ), 0 );
if ( t < 0 ) break;
result[index+t] = '\0';
index+=t;
}
for ( int iter_start = 1; iter_start < index-1 ; iter_start++ ) {
// Skip , and opening "
if ( result[iter_start] == '"' || result[iter_start] == ',' ) continue;
int iter_end = iter_start;
// Find closing tag.. make sure to ignore escaped chars.
// Copy the un-escaped string into the first part.
int rindex = 0;
do {
result[rindex++] = result[iter_end];
iter_end++;
if ( result[iter_end] == '\\' ) iter_end+=1;
} while ( result[iter_end] != '"' );
result[rindex] = '\0';
// Add element to list.

View file

@ -1185,11 +1185,14 @@ void run_switcher( int fmode, SwitcherMode mode )
} else if ( mode == SSH_DIALOG ) {
retv = ssh_switcher_dialog( &input );
}
#ifdef I3
else if ( mode == MARK_DIALOG ) {
retv = mark_switcher_dialog ( &input );
}
#endif
if ( retv == NEXT_DIALOG ) {
mode = ( mode+1 )%NUM_DIALOGS;
} else {
@ -1225,11 +1228,14 @@ void handle_keypress( XEvent *ev )
key == sshdialog_keysym ) {
run_switcher( FORK , SSH_DIALOG );
}
#ifdef I3
if ( ( markdialog_modmask == AnyModifier || ev->xkey.state & markdialog_modmask ) &&
key == markdialog_keysym ) {
run_switcher( FORK , MARK_DIALOG );
}
#endif
}

View file

@ -176,7 +176,9 @@ static char ** get_ssh ( )
for ( start=4; isspace( buffer[start] ); start++ );
for ( stop=start; isalnum( buffer[stop] ) || buffer[stop] == '_' ; stop++ );
for ( stop=start; isalnum( buffer[stop] ) ||
buffer[stop] == '_' ||
buffer[stop] == '.' ; stop++ );
int found = 0;