30 lines
623 B
Plaintext
30 lines
623 B
Plaintext
_window = 1
|
|
begin enum 1
|
|
_scrollView
|
|
_textView
|
|
end enum
|
|
|
|
void local fn BuildWindow
|
|
CGRect r = {0,0,550,400}
|
|
window _window, @"Read Entire File", r
|
|
scrollview _scrollView, r
|
|
ViewSetAutoresizingMask( _scrollView, NSViewWidthSizable + NSViewHeightSizable )
|
|
textview _textView,, _scrollView
|
|
end fn
|
|
|
|
local fn ReadTextFile
|
|
CFStringRef string
|
|
CFURLRef url = openpanel 1, @"Select text file..."
|
|
if ( url )
|
|
string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
|
|
TextSetString( _textView, string )
|
|
else
|
|
// user cancelled
|
|
end if
|
|
end fn
|
|
|
|
fn BuildWindow
|
|
fn ReadTextFile
|
|
|
|
HandleEvents
|