0

OK, this what I have in mind :

  • I have an NSTextView I'm using as a "Console"/"Terminal"
  • I want to be able to process user input on "enter"
  • When user enters something and presses "return", I want to be able to process that input

Is there anything built-in for such a functionality? Do you know of any open-source projects / example code that make use of this feature?

Any ideas?


Please do not mention iTerm2 (unless you've got some really specific piece of code to point me to) - this thing needs either a GPS Navigator or a full month of studying it before I grasp the core points...

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223

1 Answers1

0

What about using NSTask

NSTask Class gives you most of the thing, just put a string which should be a valid shell command or unix command and execute it.

See AppleDocumentation.

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • My question is **not** about the terminal-like function of an `NSTextView` and how to asynchronously execute commands (actually what I need for has nothing to do with "real" executable shell commands); all I'm interested in is how to intercept key events and detect when a new "command" has been entered. (Still experimenting with all sorts of workarounds : subclassing `NSTextView`, playing with Delegate methods, or whatever - but still nothing; `NSTextView` has got to be one of the most horrible Cocoa built-in controls... :S) – Dr.Kameleon Mar 02 '13 at 11:19
  • so u looking for a delegate kind of stuff that should get fire when text gets changed and you hit "Enter" ? – Anoop Vaidya Mar 02 '13 at 11:30
  • 1
    Hmmm... yep. To be honest, I've currently thought of a rather simple workaround (which still fits my goal - perhaps in an even more efficient way) : instead of having the console-like `NSTextView` read user input, I'll leave the `NSTextView` for message output and just add an `NSTextField` (much easier to play with) below it, solely for the purpose of receiving user input. – Dr.Kameleon Mar 02 '13 at 11:47