Displaying the contents of a file

22 views
Skip to first unread message

Joe Wollard

unread,
Feb 11, 2012, 9:44:20 PM2/11/12
to Cappuccino & Objective-J
Hey folks - hopefully a quickie here. I'd like to be able to display the contents of a file in some kind of CPScrollView-wrapped element. Ideally this element would also be editable and would preserve line breaks. CPTextField doesn't quite fit the bill in its current state (line breaks are lost upon editing) and nib2cib doesn't understand NSTextView. Ideally, a suitable candidate for my situation would meet the following requirements:

  • display a string of arbitrary length
  • preserves line breaks in both display and edit modes
  • allows the user to scroll through the content
  • would like very much if...
    • KVO support is included
    • Xcode/nib2cib support an added bonus
Obviously I'm not looking for anyone to write something for me, I'm just hoping that there's an easy solution/workaround to this issue that I've just overlooked and/or not Googled appropriately for.

Any ideas?

Thanks!
-- Joe Wollard

daboe01

unread,
Feb 12, 2012, 7:46:08 AM2/12/12
to Cappuccino & Objective-J
hi joe,

you can find something that might fit your needs under <http://aug-
fancy.ukl.uni-freiburg.de/NewApplication>
however, this stuff needs a lot of fixing and profiling.
feel free to help out improving it.
see also <https://github.com/cappuccino/cappuccino/issues/1432>
best greetings,

daniel

On 12 Feb., 03:44, Joe Wollard <joe.woll...@gmail.com> wrote:
> Hey folks - hopefully a quickie here. I'd like to be able to display the
> contents of a file in some kind of CPScrollView-wrapped element. Ideally
> this element would also be editable and would preserve line breaks.
> CPTextField doesn't quite fit the bill in its current state (line breaks
> are lost upon editing) and nib2cib doesn't understand NSTextView. Ideally,
> a suitable candidate for my situation would meet the following requirements:
>
>    - display a string of arbitrary length
>    - preserves line breaks in both display and edit modes
>    - allows the user to scroll through the content
>    - would like very much if...
>       - KVO support is included
>       - Xcode/nib2cib support an added bonus

Evadne Wu

unread,
Feb 12, 2012, 8:25:31 AM2/12/12
to objec...@googlegroups.com
If you’re simply interested in showing content, you can use a vanilla CPWebView, then load some HTML stuff into it. Alternatively, CPView exposes its underlying DOM element, and **I believe** it could be well exploited.

If you’re interested in an editor, try WyzihatKit [1] or my own fork of it [2]. Currently, it wraps around the editor provided in the Google Closure Library, and allows HTML editing. Last time I checked, it works with KVO.

One caveat: It’s an HTML editor, so it will work with HTML. If you’d rather it not work with HTML, it’s probably a better idea to roll your own wrapper around a <textarea>.

[1] https://github.com/aljungberg/WyzihatKit
[2] https://github.com/iridia/WyzihatKit

:)

On Feb 12, 2012, at 10:44 AM, Joe Wollard wrote:

> Hey folks - hopefully a quickie here. I'd like to be able to display the
> contents of a file in some kind of CPScrollView-wrapped element. Ideally
> this element would also be editable and would preserve line breaks.
> CPTextField doesn't quite fit the bill in its current state (line breaks
> are lost upon editing) and nib2cib doesn't understand NSTextView. Ideally,
> a suitable candidate for my situation would meet the following requirements:
>
>

> - display a string of arbitrary length
> - preserves line breaks in both display and edit modes
> - allows the user to scroll through the content
> - would like very much if...


> - KVO support is included

> - Xcode/nib2cib support an added bonus


>
> Obviously I'm not looking for anyone to write something for me, I'm just
> hoping that there's an easy solution/workaround to this issue that I've
> just overlooked and/or not Googled appropriately for.
>
> Any ideas?
>
> Thanks!
> -- Joe Wollard
>

> --
> You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
> To post to this group, send email to objec...@googlegroups.com.
> To unsubscribe from this group, send email to objectivej+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/objectivej?hl=en.
>

KC

unread,
Feb 12, 2012, 11:34:07 AM2/12/12
to Cappuccino & Objective-J
Have you thought about using LKit LPMultiLineTextField? (https://
github.com/luddep/LPKit) You'd have to wrap it in your own
scrollbar.

Kerri

On Feb 11, 6:44 pm, Joe Wollard <joe.woll...@gmail.com> wrote:
> Hey folks - hopefully a quickie here. I'd like to be able to display the
> contents of a file in some kind of CPScrollView-wrapped element. Ideally
> this element would also be editable and would preserve line breaks.
> CPTextField doesn't quite fit the bill in its current state (line breaks
> are lost upon editing) and nib2cib doesn't understand NSTextView. Ideally,
> a suitable candidate for my situation would meet the following requirements:
>
>    - display a string of arbitrary length
>    - preserves line breaks in both display and edit modes
>    - allows the user to scroll through the content
>    - would like very much if...
>       - KVO support is included
>       - Xcode/nib2cib support an added bonus

Joe Wollard

unread,
Feb 12, 2012, 3:54:49 PM2/12/12
to objec...@googlegroups.com, Cappuccino & Objective-J
These are some great suggestions. Thanks! I knew there had to be a project out there that I could use in an effort to avoid reinventing the wheel. I haven't had time to look into any of the suggested options yet, but I'll report back with what I found most useful just to make sure it ends up in the archives

Thanks again!


---
Joe Wollard

Joe Wollard

unread,
Feb 12, 2012, 5:26:12 PM2/12/12
to objec...@googlegroups.com
LPKit for the win! I don't understand how I've missed this gem for so long. Many thanks for pointing it out and many MANY thanks to all of those who put this together! I recognized just about every name on the contributors list from folks on this list - this is an awesome community.
Reply all
Reply to author
Forward
0 new messages