Skip to content

Instantly share code, notes, and snippets.

@moebiuseye
Created January 3, 2013 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moebiuseye/4440406 to your computer and use it in GitHub Desktop.
Save moebiuseye/4440406 to your computer and use it in GitHub Desktop.
/**
* @brief Converts the current selection to hexadecimal
* @param w
* @param data
* @returns 0 on success
*/
int str2hex( GtkWidget *w, gpointer data ){ init();
int i;
substitution = malloc( sizeof( char ) * strlen( selection ) * 2 + 1 );
strcpy( substitution, "");
for (i = 0; i < strlen( selection ) ; i++){
char *hex_str = malloc( 3 );
sprintf( hex_str , "%02x" , selection[i]);
strcat( substitution, hex_str );
free( hex_str );
}
sci_replace_sel( _c_document->editor->sci , substitution );
//~ msgwin_status_add( substitution );
free( selection );
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment