I've read the documentation and done some searching and haven't found the answer to this.
For shell init scripts and various other purposes, I'd like to be able to "type" characters like ⌃[ or ⌃G. You know, the kind of thing you would precede with ⌃V in the Terminal. It seems that Cocoa has a key binding for this (NSQuotedKeystrokeBinding, which is ⌃Q by default), but it is used for another purpose in Textmate. Has the functionality been remapped or do I need to try to define it for Textmate myself? It doesn't seem to be set…
rob@kendra ~> defaults read com.macromates.Textmate NSQuotedKeystrokeBinding 2006-11-29 14:47:10.910 defaults[6713] The domain/default pair of (com.macromates.Textmate, NSQuotedKeystrokeBinding) does not exist
On a related note, I'd like to be able to "see" these characters as well, or perhaps toggle them of and on (with ⌥⌘I ideally). Texmate is better than most Cocoa apps, as it seems to display a space in place of such characters instead of nothing at all, but I'd like to know what that space represents. Has anyone tried enabling [NSTextShowsControlCharacters][] in Textmate? I'm guessing there would be undesired side-effects.
Should I have asked these questions before Allan took off? :)
[NSTextShowsControlCharacters]: http://developer.apple.com/ documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/ chapter_9_section_4.html#//apple_ref/doc/uid/20000468-610689
--- Rob
Rob McBroom wrote:
For shell init scripts and various other purposes, I'd like to be able to "type" characters like ⌃[ or ⌃G. You know, the kind of thing you would precede with ⌃V in the Terminal. It seems that Cocoa has a key binding for this (NSQuotedKeystrokeBinding, which is ⌃Q by default), but it is used for another purpose in Textmate. Has the functionality been remapped or do I need to try to define it for Textmate myself? It doesn't seem to be set…
I'm pretty sure TextMate's text control doesn't support that, but you can try.
rob@kendra ~> defaults read com.macromates.Textmate
NSQuotedKeystrokeBinding 2006-11-29 14:47:10.910 defaults[6713] The domain/default pair of (com.macromates.Textmate, NSQuotedKeystrokeBinding) does not exist
On a related note, I'd like to be able to "see" these characters as well, or perhaps toggle them of and on (with ⌥⌘I ideally). Texmate is better than most Cocoa apps, as it seems to display a space in place of such characters instead of nothing at all, but I'd like to know what that space represents. Has anyone tried enabling [NSTextShowsControlCharacters][] in Textmate? I'm guessing there would be undesired side-effects.
Did you try showing invisibles? I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.
In any case, you should be able to copy/paste them into a textmate control from another window, or make a command to insert them, something that takes the previous letter ("[" for instance), and turns it into the control sequence ("⌃[").
-Jacob
Why do you want to type control codes directly? It's a lot safer to use escape sequences.
Bash even has a string quote form $'string', which supports escapes, and an escape \cx which stands for the control-x character. This means you can represent the ^[ character as $'\c['.
On Nov 29, 2006, at 4:17 PM, Jacob Rus wrote:
Rob McBroom wrote:
For shell init scripts and various other purposes, I'd like to be able to "type" characters like ⌃[ or ⌃G. You know, the kind of thing you would precede with ⌃V in the Terminal. It seems that Cocoa has a key binding for this (NSQuotedKeystrokeBinding, which is ⌃Q by default), but it is used for another purpose in Textmate. Has the functionality been remapped or do I need to try to define it for Textmate myself? It doesn't seem to be set…
I'm pretty sure TextMate's text control doesn't support that, but you can try.
rob@kendra ~> defaults read com.macromates.Textmate
NSQuotedKeystrokeBinding 2006-11-29 14:47:10.910 defaults[6713] The domain/default pair of (com.macromates.Textmate, NSQuotedKeystrokeBinding) does not exist On a related note, I'd like to be able to "see" these characters as well, or perhaps toggle them of and on (with ⌥⌘I ideally). Texmate is better than most Cocoa apps, as it seems to display a space in place of such characters instead of nothing at all, but I'd like to know what that space represents. Has anyone tried enabling [NSTextShowsControlCharacters][] in Textmate? I'm guessing there would be undesired side-effects.
Did you try showing invisibles? I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.
In any case, you should be able to copy/paste them into a textmate control from another window, or make a command to insert them, something that takes the previous letter ("[" for instance), and turns it into the control sequence ("⌃[").
I don't know if this is what you're looking for but over at subtleGradient they have a TextGlyphs bundle. You can check it out using subversion or you can use the copy I'm attaching. The address for the subtleGradient SVN repository is: http://textmate.svn.subtlegradient.com/
Hope that helps!
-Brian –––––––––––––––––––––––––––––––––––– Brian Landau UNC - Chapel Hill School of Library and Information Science (SILS) http://macevangelism.blogspot.com/ http://www.claimid.com/brianjlandau AIM: Zippi Bat ––––––––––––––––––––––––––––––––––––
On 11/29/06, Kevin Ballard kevin@sb.org wrote:
Why do you want to type control codes directly? It's a lot safer to use escape sequences.
Bash even has a string quote form $'string', which supports escapes, and an escape \cx which stands for the control-x character. This means you can represent the ^[ character as $'\c['.
On Nov 29, 2006, at 4:17 PM, Jacob Rus wrote:
Rob McBroom wrote:
For shell init scripts and various other purposes, I'd like to be able to "type" characters like ⌃[ or ⌃G. You know, the kind of thing you would precede with ⌃V in the Terminal. It seems that Cocoa has a key binding for this (NSQuotedKeystrokeBinding, which is ⌃Q by default), but it is used for another purpose in Textmate. Has the functionality been remapped or do I need to try to define it for Textmate myself? It doesn't seem to be set…
I'm pretty sure TextMate's text control doesn't support that, but you can try.
rob@kendra ~> defaults read com.macromates.Textmate
NSQuotedKeystrokeBinding
2006-11-29 14:47:10.910 defaults[6713] The domain/default pair of (com.macromates.Textmate,
NSQuotedKeystrokeBinding) does not exist
On a related note, I'd like to be able to "see" these characters as well, or perhaps toggle them of and on (with ⌥⌘I ideally). Texmate is better than most Cocoa apps, as it seems to display a space in place of such characters instead of nothing at all, but I'd like to know what that space represents. Has anyone tried enabling [NSTextShowsControlCharacters][] in Textmate? I'm guessing there would be undesired side-effects.
Did you try showing invisibles? I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.
In any case, you should be able to copy/paste them into a textmate control from another window, or make a command to insert them, something that takes the previous letter ("[" for instance), and turns it into the control sequence ("⌃[").
-- Kevin Ballard http://kevin.sb.org kevin@sb.org http://www.tildesoft.com
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Nov 29, 2006, at 6:39 PM, Kevin Ballard wrote:
Why do you want to type control codes directly? It's a lot safer to use escape sequences.
Bash even has a string quote form $'string', which supports escapes, and an escape \cx which stands for the control-x character. This means you can represent the ^[ character as $'\c['.
Good to know, but I don't use `bash` and in any case, I can't assume that `bash` will always be the thing that's interpreting a file.
On Nov 29, 2006, at 4:17 PM, Jacob Rus wrote:
Did you try showing invisibles? I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.
Yes, I did. It shows the same diamond you would see for a regular space. I'll probably set up a dummy account and mess with some of these obscure settings when I get a chance. Should I share what I discover, or does no one care? :)
In any case, you should be able to copy/paste them into a textmate control from another window, or make a command to insert them, something that takes the previous letter ("[" for instance), and turns it into the control sequence ("⌃[").
Well, I can actually type these things into most Textmate controls using the ⌃Q trick. For example, create a file with the string "foobar" in it somewhere, bring up the Find dialogue and type "foo⌃Q⎋bar" and search. You won't see the escape, but it is there because the strings won't match. It's typing in the document window itself that I'm wondering about.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
Rob McBroom wrote:
On Nov 29, 2006, at 6:39 PM, Kevin Ballard wrote:
Why do you want to type control codes directly? It's a lot safer to use escape sequences.
Let me just emphasize this. *Why* do you need control codes? For what? Is there a use case, or is this just for the fun of it?
On Nov 29, 2006, at 4:17 PM, Jacob Rus wrote:
Did you try showing invisibles? I believe these show up as different from spaces or tabs, but I don't remember exactly what they look like.
Yes, I did. It shows the same diamond you would see for a regular space.
It doesn't show anything at all for a regular space, so there is indeed a difference. But all your control characters are going to show up as diamonds.
In any case, you should be able to copy/paste them into a textmate control from another window, or [...]
Well, I can actually type these things into most Textmate controls using the ⌃Q trick. For example, create a file with the string "foobar" in it somewhere, bring up the Find dialogue
Yes, because the find dialog uses a regular Cocoa text box. The textmate control I'm referring to is the main editor window.
-Jacob
On Nov 30, 2006, at 12:48 PM, Jacob Rus wrote:
Let me just emphasize this. *Why* do you need control codes? For what? Is there a use case, or is this just for the fun of it?
* A script that changes the Terminal's window title has to send some control characters before and after the title text
* A script that maps keys to internal shell commands (like `history-search-backward`, `spell-line` or `normalize-ccommand` in `tcsh`) would need them. For example, the function keys are all an escape followed by some string. Yes, I could just paste the escape from somewhere else and type the rest, but I'd have to have the code for each F-key memorized. I'd rather just hit ⌃Q or ⌃V or whatever then hit the key.
* And an admittedly weird example from something a co-worker was trying to do that led me on this quest in the first place: He wanted to use the same command on several files in `vim` in a row by just pasting the command to the Terminal (I know there are a dozen better ways) and he wanted it to "hit" Escape for him to get out of insert mode. From looking into it, I now know he could have composed the string using the ⌃Q trick in most NSTextView areas, but when looking for a "scratch" area to whip out some text, we automatically think to use Textmate, so I just wondered if it could be done.
It doesn't show anything at all for a regular space, so there is indeed a difference. But all your control characters are going to show up as diamonds.
Yeah, I noticed that when I started looking at it more closely in a new account. By the way, neither of the prefs I mentioned before seem to have an effect on Texmate's behavior.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
Rob McBroom wrote:
A script that changes the Terminal's window title...
A script that maps keys to internal shell commands...
And an admittedly weird example from something a co-worker was trying to do that led me on this quest in the first place: He wanted to use the same command on several files in `vim` in a row by just pasting the command to the Terminal ...
Well, the first two of these cases are in some shell scripting language presumably, which probably has its own convention for writing control characters, and as for the third, while he probably should be using TextMate instead of vim anyway ;), doesn't vim have some ways of recording macros, etc?
In any case, as was already said, control characters really aren't meant for copying and pasting. They're meant for controlling things. Unless you're really careful, you could do lots of stuff you don't want to do when you copy/paste control characters. It's a non-transparent process with potentially dangerous side effects, for which numerous better solutions exist... so, I suggest against it.
-Jacob
On Nov 30, 2006, at 3:52 PM, Jacob Rus wrote:
Well, the first two of these cases are in some shell scripting language presumably, which probably has its own convention for writing control characters,
No, this is standard terminal emulation stuff (for controlling window title, color, etc). Nothing to do with a particular shell.
and as for the third, while he probably should be using TextMate instead of vim anyway ;), doesn't vim have some ways of recording macros, etc?
Yeah, I agree usually. I think this was some quick and dirty job on a remote machine is all. And yes, mapping a command in vim is really easy (you can even use strings like `<ESC>` and `<F6>` in the command and it will know what you mean) and would have been second nature to me a few months ago, but I suppose I've gotten rusty from using some other editor.
In any case, as was already said, control characters really aren't meant for copying and pasting. They're meant for controlling things. Unless you're really careful, you could do lots of stuff you don't want to do when you copy/paste control characters. It's a non-transparent process with potentially dangerous side effects, for which numerous better solutions exist... so, I suggest against it.
I agree, but I never said I wanted to copy and paste these things. I said I wanted to "type" and "see" them. Copy/paste was a suggested work-around that I agreed might work in some cases. Since it's such a bad idea, I won't mention who originally suggested it. ;)
FYI, I think there may be another way to store these things as plain text (using something like `\033` to represent escape, for example). My wild guesses at syntax haven't been very successful so far, but I'm still looking into it. Anyway, thanks for the help.
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
On Nov 30, 2006, at 5:22 PM, Rob McBroom wrote:
On Nov 30, 2006, at 3:52 PM, Jacob Rus wrote:
Well, the first two of these cases are in some shell scripting language presumably, which probably has its own convention for writing control characters,
No, this is standard terminal emulation stuff (for controlling window title, color, etc). Nothing to do with a particular shell.
Shell or not, you're still writing in some language, and you're pretty much guaranteed to have some fashion of constructing control characters in a given language.