]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' into new_ui
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 10 Feb 2009 22:23:14 +0000 (16:23 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 10 Feb 2009 22:23:14 +0000 (16:23 -0600)
1  2 
basis/cocoa/messages/messages.factor
basis/help/help.factor
basis/help/topics/topics.factor
basis/html/templates/chloe/syntax/syntax.factor
basis/ui/backend/cocoa/cocoa.factor
basis/ui/gadgets/worlds/worlds.factor
core/parser/parser.factor
core/words/words.factor

Simple merge
index eb533af3999c9a68f644e11cecb19e7e59990193,f980032a8b756c1b71293a157283624043195699..27a81f9948b1eb50ac1bf05c1cfef40dcdc649d4
@@@ -122,10 -118,10 +122,10 @@@ M: word set-article-parent swap "help-p
  
  SYMBOL: help-hook
  
- help-hook global [ [ print-topic ] or ] change-at
+ help-hook [ [ print-topic ] ] initialize
  
  : help ( topic -- )
 -    help-hook get call ;
 +    help-hook get call( topic -- ) ;
  
  : about ( vocab -- )
      dup require
Simple merge
index 669e50b6f766b8dd44cb6ae1b0bba7629aa7d0eb,0000000000000000000000000000000000000000..59f78c242d16c63f6656c356535873c06c637802
mode 100755,000000..100755
--- /dev/null
@@@ -1,164 -1,0 +1,164 @@@
- cocoa-init-hook global [
-     [ "MiniFactor.nib" load-nib install-app-delegate ] or
- ] change-at
 +! Copyright (C) 2006, 2009 Slava Pestov.
 +! See http://factorcode.org/license.txt for BSD license.
 +USING: accessors math arrays assocs cocoa cocoa.application
 +command-line kernel memory namespaces cocoa.messages
 +cocoa.runtime cocoa.subclassing cocoa.pasteboard cocoa.types
 +cocoa.windows cocoa.classes cocoa.nibs sequences system ui
 +ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds
 +ui.backend.cocoa.views core-foundation core-foundation.run-loop
 +core-graphics.types threads math.rectangles fry libc
 +generalizations alien.c-types cocoa.views
 +combinators io.thread ;
 +IN: ui.backend.cocoa
 +
 +TUPLE: handle ;
 +TUPLE: window-handle < handle view window ;
 +TUPLE: offscreen-handle < handle context buffer ;
 +
 +C: <window-handle> window-handle
 +C: <offscreen-handle> offscreen-handle
 +
 +SINGLETON: cocoa-ui-backend
 +
 +TUPLE: pasteboard handle ;
 +
 +C: <pasteboard> pasteboard
 +
 +M: pasteboard clipboard-contents
 +    handle>> pasteboard-string ;
 +
 +M: pasteboard set-clipboard-contents
 +    handle>> set-pasteboard-string ;
 +
 +: init-clipboard ( -- )
 +    NSPasteboard -> generalPasteboard <pasteboard>
 +    clipboard set-global
 +    <clipboard> selection set-global ;
 +
 +: world>NSRect ( world -- NSRect )
 +    [ window-loc>> ] [ dim>> ] bi [ first2 ] bi@ <CGRect> ;
 +
 +: gadget-window ( world -- )
 +    dup <FactorView>
 +    2dup swap world>NSRect <ViewWindow>
 +    [ [ -> release ] [ install-window-delegate ] bi* ]
 +    [ <window-handle> ] 2bi
 +    >>handle drop ;
 +
 +M: cocoa-ui-backend set-title ( string world -- )
 +    handle>> window>> swap <NSString> -> setTitle: ;
 +
 +: enter-fullscreen ( world -- )
 +    handle>> view>>
 +    NSScreen -> mainScreen
 +    f -> enterFullScreenMode:withOptions:
 +    drop ;
 +
 +: exit-fullscreen ( world -- )
 +    handle>> view>> f -> exitFullScreenModeWithOptions: ;
 +
 +M: cocoa-ui-backend set-fullscreen* ( ? world -- )
 +    swap [ enter-fullscreen ] [ exit-fullscreen ] if ;
 +
 +M: cocoa-ui-backend fullscreen* ( world -- ? )
 +    handle>> view>> -> isInFullScreenMode zero? not ;
 +
 +: auto-position ( world -- )
 +    dup window-loc>> { 0 0 } = [
 +        handle>> window>> -> center
 +    ] [
 +        drop
 +    ] if ;
 +
 +M: cocoa-ui-backend (open-window) ( world -- )
 +    dup gadget-window
 +    dup auto-position
 +    handle>> window>> f -> makeKeyAndOrderFront: ;
 +
 +M: cocoa-ui-backend (close-window) ( handle -- )
 +    window>> -> release ;
 +
 +M: cocoa-ui-backend close-window ( gadget -- )
 +    find-world [
 +        handle>> [
 +            window>> f -> performClose:
 +        ] when*
 +    ] when* ;
 +
 +M: cocoa-ui-backend raise-window* ( world -- )
 +    handle>> [
 +        window>> dup f -> orderFront: -> makeKeyWindow
 +        NSApp 1 -> activateIgnoringOtherApps:
 +    ] when* ;
 +
 +: pixel-size ( pixel-format -- size )
 +    0 <int> [ NSOpenGLPFAColorSize 0 -> getValues:forAttribute:forVirtualScreen: ]
 +    keep *int -3 shift ;
 +
 +: offscreen-buffer ( world pixel-format -- alien w h pitch )
 +    [ dim>> first2 ] [ pixel-size ] bi*
 +    { [ * * malloc ] [ 2drop ] [ drop nip ] [ nip * ] } 3cleave ;
 +
 +: gadget-offscreen-context ( world -- context buffer )
 +    NSOpenGLPFAOffScreen 1array <PixelFormat>
 +    [ nip NSOpenGLContext -> alloc swap f -> initWithFormat:shareContext: dup ]
 +    [ offscreen-buffer ] 2bi
 +    4 npick [ -> setOffScreen:width:height:rowbytes: ] dip ;
 +
 +M: cocoa-ui-backend (open-offscreen-buffer) ( world -- )
 +    dup gadget-offscreen-context <offscreen-handle> >>handle drop ;
 +
 +M: cocoa-ui-backend (close-offscreen-buffer) ( handle -- )
 +    [ context>> -> release ]
 +    [ buffer>> free ] bi ;
 +
 +GENERIC: (gl-context) ( handle -- context )
 +M: window-handle (gl-context) view>> -> openGLContext ;
 +M: offscreen-handle (gl-context) context>> ;
 +
 +M: handle select-gl-context ( handle -- )
 +    (gl-context) -> makeCurrentContext ;
 +
 +M: handle flush-gl-context ( handle -- )
 +    (gl-context) -> flushBuffer ;
 +
 +M: cocoa-ui-backend offscreen-pixels ( world -- alien w h )
 +    [ handle>> buffer>> ] [ dim>> first2 neg ] bi ;
 +
 +M: cocoa-ui-backend beep ( -- )
 +    NSBeep ;
 +
 +CLASS: {
 +    { +superclass+ "NSObject" }
 +    { +name+ "FactorApplicationDelegate" }
 +}
 +
 +{  "applicationDidUpdate:" "void" { "id" "SEL" "id" }
 +    [ 3drop reset-run-loop ]
 +} ;
 +
 +: install-app-delegate ( -- )
 +    NSApp FactorApplicationDelegate install-delegate ;
 +
 +SYMBOL: cocoa-init-hook
 +
++cocoa-init-hook [
++    [ "MiniFactor.nib" load-nib install-app-delegate ]
++] initialize
 +
 +M: cocoa-ui-backend (with-ui)
 +    "UI" assert.app [
 +        [
 +            init-clipboard
 +            cocoa-init-hook get call
 +            start-ui
 +            f io-thread-running? set-global
 +            init-thread-timer
 +            reset-run-loop
 +            NSApp -> run
 +        ] ui-running
 +    ] with-cocoa ;
 +
 +cocoa-ui-backend ui-backend set-global
 +
 +[ running.app? "ui.tools" "listener" ? ] main-vocab-hook set-global
index 68cee4dc12a9c689a5507b89dcaf61d9683e5516,f57fb60bcd93e8d59c3f6a1d429b0c7771833cc2..749db69b5287cdf75e53007e8e5204268f111fa3
@@@ -77,9 -79,9 +77,9 @@@ C: <world-error> world-erro
  SYMBOL: ui-error-hook
  
  : ui-error ( error -- )
 -    ui-error-hook get [ call ] [ die ] if* ;
 +    ui-error-hook get [ call( error -- ) ] [ die drop ] if* ;
  
- ui-error-hook global [ [ rethrow ] or ] change-at
+ ui-error-hook [ [ rethrow ] ] initialize
  
  : draw-world ( world -- )
      dup draw-world? [
Simple merge
Simple merge