nstextview

Disable Option-Enter line breaks in NSTextField?

I want to disallow entering a new-line character in my NSTextField, which by default is possible by typing Option-Enter (or Option-Return). While I found some pages explaining how to allow line breaks without having to use the Option modifier, I couldn't find anything for disabling line breaks altogether. How can this be done? ...

What is the best way to implement syntax highlighting of source code in Cocoa?

I'm working on Cocoa Application that should be able to analyze and highlight a source code written in such languages as Objective-C, SQL, JavaScript, Python etc. The text should be editable too (by using NSTextView, for example). Please advise what is the best way to implement such feature in Mac OS X 10.5. There is no need to support...

NSTextView not refreshed properly on scrolling

Greetings, I have a NSTextView with a sizeable quantity of text. Whenever I scroll however, the view isn't updated properly. There are some artifacts that remain at the top or the bottom of the view. It appears that the view doesn't refresh itself often enough. If I scroll very slowly the view updates correctly though. If I add a border...

How do I find the pixel position of a character in an NSTextView?

I'm currently using the following code to fetch the logical NSView position of glyphs which is working fine however it seems a bit slow and the positions aren't precisely on the character kerning point and baseline. It very well may be the case that all I need to do is iterate the glyphs themselves one by one and build the rect myself. ...

NSTextView won't respond to setString

I'm new to Cocoa, and I've been having a problem that is absolutely maddening. I'm trying to write a simple NSString to an NSTextView, and for some reason it just won't respond. No compiler warnings, no runtime errors, just a blank textview. I'm able to use other methods of NSTextView like selectAll, delete, setSelectedRanges, etc. ...

NSpoint from NSTextView insertion point

I have an NSTextView and require the coordinates of the insertion point to display a view there upon user interaction. There is a function to get the character index from an NSPoint. I am wondering if there is any easy way to do the opposite? Thanks for any help! ...

Core Data bindings with subviews and multiple NIBs

I have a document-based Core Data app. My main Core Data entity has several string fields, most of which are bound to NSTextFields, but one is bound to an NSTextView. I am using the technique for view switching (with multiple view controllers) as explained in the Hillegass book. All of my subviews are controlled by a ManagedViewControll...

Why NSTextView with no code produces memory leaks in Snow Leopard?

Hi! I can't figure out why a NSTextView created with IB in an empty Cocoa application project produces memory leaks when I type in it. I created a new project, then I drew a NSTextView in IB; I compiled and ran my project with Instruments-Leaks and when I typed something a lot of leaks appears in Instruments. Snow leopard, XCode 3.2 An...

How do I know when an attachment attribute is being added to my NSTextView?

Because of the semantics of certain NSTextView attachments in my application, I want to know when they are inserted or deleted from my text storage. My subclass of NSTextView implements the shouldChangeTextInRange:replacementString: method, which allows me to easily see when an attachment is about to be replaced (I can search the text s...

How to find caret position in an NSTextView?

Hi all, I've an NSTextView with with several semi-colon separated strings. I need to find on which of those strings the caret has been placed. How could I do that? ...

How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?

I have a NSTextView that I want to display a horizontal scroll bar. Following some leads on the internet, I have most of it working, except that I am having problems with the vertical scroll bar. What I have done is to find the width of the longest line (in pixels with the given font) and then I resize the NSTextContainer and the NSTex...

NSTextView non-editable areas of text?

Hi, I have an NSTextView that contains data for the user to edit, but I want to surround it with a header and footer of non-editable data to give the user an idea of context. I don't think an NSTextView can handle the concept of mixed editable/non-editable data, so I've come up with a few ideas. a) Use text attachments with a custom c...

Scrolling an NSTextView to an exact rect?

Hi, I've got an NSTextView, inside an NSScrollView, and I want to scroll it to exactly where it used to be after repopulated the NSTextView with new data. So far, I've tried variations on the code below, but it never gets it quite right. What I need is a setDocumentVisibleRect method, but there isn't one. NSRect oldVisibleRect = [[[se...

Bindings MInefield in Xcode and Interface Builder.

All right, after having worked through Cocoa Dev Central's "Build a Core Data Application" tutorial I started experimenting with building my own application, using the code and .nib file from the tutorial as a reference to make sure that things are put together properly. Overall I've been managing pretty well with it, however I seem to ...

How to implement an NSTextView that performs on-the-fly markup to RTF conversions

I'm trying to build an NSTextView that can take "marked up" input that is automatically translated into beautiful RTF-style text while the user types. The idea is to let the user enter text in "plain text" format, but to "beautify" it on the spot, e.g. H1 A quick list: * first item * second item would be translated into a first line ...

How to create skype like message window?

Hi all, I am just trying to design skype like message window , for this I have taken the NSDrawer element. It contains : a table view on left, menu items on top, text field on right bottom and text view at central portion on right side. Using text view I can play with string being displayed but I cannot draw the line between messages or...

Data Detectors in Cocoa

I want to add a data detector in an NSTextField / NSTextView like in Mail (e.g. date, email, URL, etc). Does anyone have an idea how to do this ? I think I saw it in TextEdit's source code but when I checked it was 2005's version and I can't find the new source code. Alex ...

Unable to set text in NSTextView

::Edit:: It works now? haha, maybe I just didn't save my latest IB...who the hell knows. Thanks! Hey, This is my first time playing around with desktop applications (I have experience with iphone applications) and I'm stuck - My text view will not update to show any text: .m: @synthesize textView; NSString *txt = [[[NSString all...

NSTextView syntax highlighting

I'm working on a Cocoa text editor which uses an NSTextView. Is it possible to change the color of certain portions of the text? ...

Custom NSTextView autocompletion menu

How would one implement a custom auto-complete pop-up menu like Xcode has? At the moment I can only put custom auto-completions using - (NSArray *)textView:theTextView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int *)index I want a bit more flexibility than this. Cheers! MT ...