[TxMt] Getting one character from the keyboard for use in Commands

Chris Insinger lucent1 at mac.com
Tue Feb 20 11:21:02 UTC 2007


Hi all,

I'm new to TM and trying to implement a Command that fills the  
current selection with a character. Right now I have a simple program  
that replaces every character in the current selection with a space  
character (but skips CR/LF), so far so good.

main()
{
	char *x=getenv("TM_SELECTED_TEXT");
	char c=32; /* Space character - this is what I'd like to be able to  
replace at invokation time */
	for ( ;x && *x;x++) putchar((*x==10 || *x==13) ? *x:c);
}


Now I'd like it to fill the selection not just with a space, but with  
a user-entered character...

Ideally I'd like to:

1) select an area of text
2) press ^F (or whatever)
3) get a character from the keyboard
4) use that character to fill the selection

How do I accomplish #3 above?

Thanks for any pointers,

Chris




More information about the textmate mailing list