Merge branch 'master' of git://factorcode.org/git/factor
commit
b4bd688d69
|
@ -277,7 +277,7 @@ HELP: append-path
|
||||||
|
|
||||||
HELP: prepend-path
|
HELP: prepend-path
|
||||||
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
{ $values { "str1" "a string" } { "str2" "a string" } { "str" "a string" } }
|
||||||
{ $description "Concatenates two pathnames." } ;
|
{ $description "Appends str1 onto str2 to form a pathname." } ;
|
||||||
|
|
||||||
{ append-path prepend-path } related-words
|
{ append-path prepend-path } related-words
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ IN: ui.backend
|
||||||
|
|
||||||
SYMBOL: ui-backend
|
SYMBOL: ui-backend
|
||||||
|
|
||||||
|
HOOK: do-events ui-backend ( -- )
|
||||||
|
|
||||||
HOOK: set-title ui-backend ( string world -- )
|
HOOK: set-title ui-backend ( string world -- )
|
||||||
|
|
||||||
HOOK: set-fullscreen* ui-backend ( ? world -- )
|
HOOK: set-fullscreen* ui-backend ( ? world -- )
|
||||||
|
|
|
@ -14,18 +14,8 @@ C: <handle> handle
|
||||||
|
|
||||||
SINGLETON: cocoa-ui-backend
|
SINGLETON: cocoa-ui-backend
|
||||||
|
|
||||||
SYMBOL: stop-after-last-window?
|
M: cocoa-ui-backend do-events ( -- )
|
||||||
|
[ [ NSApp do-events ui-wait ] ui-try ] with-autorelease-pool ;
|
||||||
: event-loop? ( -- ? )
|
|
||||||
stop-after-last-window? get-global
|
|
||||||
[ windows get-global empty? not ] [ t ] if ;
|
|
||||||
|
|
||||||
: event-loop ( -- )
|
|
||||||
event-loop? [
|
|
||||||
[
|
|
||||||
[ NSApp do-events ui-wait ] ui-try
|
|
||||||
] with-autorelease-pool event-loop
|
|
||||||
] when ;
|
|
||||||
|
|
||||||
TUPLE: pasteboard handle ;
|
TUPLE: pasteboard handle ;
|
||||||
|
|
||||||
|
@ -112,6 +102,7 @@ M: cocoa-ui-backend ui
|
||||||
"UI" assert.app [
|
"UI" assert.app [
|
||||||
[
|
[
|
||||||
init-clipboard
|
init-clipboard
|
||||||
|
stop-after-last-window? off
|
||||||
cocoa-init-hook get [ call ] when*
|
cocoa-init-hook get [ call ] when*
|
||||||
start-ui
|
start-ui
|
||||||
finish-launching
|
finish-launching
|
||||||
|
|
|
@ -10,6 +10,18 @@ IN: ui
|
||||||
! Assoc mapping aliens to gadgets
|
! Assoc mapping aliens to gadgets
|
||||||
SYMBOL: windows
|
SYMBOL: windows
|
||||||
|
|
||||||
|
SYMBOL: stop-after-last-window?
|
||||||
|
|
||||||
|
: event-loop? ( -- ? )
|
||||||
|
{
|
||||||
|
{ [ stop-after-last-window? get not ] [ t ] }
|
||||||
|
{ [ graft-queue dlist-empty? not ] [ t ] }
|
||||||
|
{ [ windows get-global empty? not ] [ t ] }
|
||||||
|
[ f ]
|
||||||
|
} cond ;
|
||||||
|
|
||||||
|
: event-loop ( -- ) [ event-loop? ] [ do-events ] [ ] while ;
|
||||||
|
|
||||||
: window ( handle -- world ) windows get-global at ;
|
: window ( handle -- world ) windows get-global at ;
|
||||||
|
|
||||||
: window-focus ( handle -- gadget ) window world-focus ;
|
: window-focus ( handle -- gadget ) window world-focus ;
|
||||||
|
@ -201,5 +213,9 @@ MAIN: ui
|
||||||
call
|
call
|
||||||
] [
|
] [
|
||||||
f windows set-global
|
f windows set-global
|
||||||
ui-hook [ ui ] with-variable
|
[
|
||||||
|
ui-hook set
|
||||||
|
stop-after-last-window? on
|
||||||
|
ui
|
||||||
|
] with-scope
|
||||||
] if ;
|
] if ;
|
||||||
|
|
|
@ -387,17 +387,12 @@ SYMBOL: trace-messages?
|
||||||
|
|
||||||
: peek-message? ( msg -- ? ) f 0 0 PM_REMOVE PeekMessage zero? ;
|
: peek-message? ( msg -- ? ) f 0 0 PM_REMOVE PeekMessage zero? ;
|
||||||
|
|
||||||
: event-loop ( msg -- )
|
M: windows-ui-backend do-events
|
||||||
{
|
msg-obj get-global
|
||||||
{ [ windows get empty? ] [ drop ] }
|
dup peek-message? [ drop ui-wait ] [
|
||||||
{ [ dup peek-message? ] [ ui-wait event-loop ] }
|
[ TranslateMessage drop ]
|
||||||
{ [ dup MSG-message WM_QUIT = ] [ drop ] }
|
[ DispatchMessage drop ] bi
|
||||||
[
|
] if ;
|
||||||
dup TranslateMessage drop
|
|
||||||
dup DispatchMessage drop
|
|
||||||
event-loop
|
|
||||||
]
|
|
||||||
} cond ;
|
|
||||||
|
|
||||||
: register-wndclassex ( -- class )
|
: register-wndclassex ( -- class )
|
||||||
"WNDCLASSEX" <c-object>
|
"WNDCLASSEX" <c-object>
|
||||||
|
@ -500,10 +495,11 @@ M: windows-ui-backend set-title ( string world -- )
|
||||||
M: windows-ui-backend ui
|
M: windows-ui-backend ui
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
stop-after-last-window? on
|
||||||
init-clipboard
|
init-clipboard
|
||||||
init-win32-ui
|
init-win32-ui
|
||||||
start-ui
|
start-ui
|
||||||
msg-obj get event-loop
|
event-loop
|
||||||
] [ cleanup-win32-ui ] [ ] cleanup
|
] [ cleanup-win32-ui ] [ ] cleanup
|
||||||
] ui-running ;
|
] ui-running ;
|
||||||
|
|
||||||
|
|
|
@ -183,15 +183,10 @@ M: world client-event
|
||||||
ui-wait wait-event
|
ui-wait wait-event
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
: do-events ( -- )
|
M: x11-ui-backend do-events
|
||||||
wait-event dup XAnyEvent-window window dup
|
wait-event dup XAnyEvent-window window dup
|
||||||
[ [ 2dup handle-event ] assert-depth ] when 2drop ;
|
[ [ 2dup handle-event ] assert-depth ] when 2drop ;
|
||||||
|
|
||||||
: event-loop ( -- )
|
|
||||||
windows get empty? [
|
|
||||||
[ do-events ] ui-try event-loop
|
|
||||||
] unless ;
|
|
||||||
|
|
||||||
: x-clipboard@ ( gadget clipboard -- prop win )
|
: x-clipboard@ ( gadget clipboard -- prop win )
|
||||||
x-clipboard-atom swap
|
x-clipboard-atom swap
|
||||||
find-world world-handle x11-handle-window ;
|
find-world world-handle x11-handle-window ;
|
||||||
|
@ -254,6 +249,7 @@ M: x11-ui-backend ui ( -- )
|
||||||
[
|
[
|
||||||
f [
|
f [
|
||||||
[
|
[
|
||||||
|
stop-after-last-window? on
|
||||||
init-clipboard
|
init-clipboard
|
||||||
start-ui
|
start-ui
|
||||||
event-loop
|
event-loop
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
USING: alien.syntax ;
|
||||||
|
|
||||||
|
IN: unix.ffi
|
||||||
|
|
||||||
|
FUNCTION: int open ( char* path, int flags, int prot ) ;
|
|
@ -2,7 +2,10 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: alien alien.c-types alien.syntax kernel libc structs
|
USING: alien alien.c-types alien.syntax kernel libc structs
|
||||||
math namespaces system combinators vocabs.loader unix.types ;
|
math namespaces system combinators vocabs.loader unix.ffi unix.types
|
||||||
|
qualified ;
|
||||||
|
|
||||||
|
QUALIFIED: unix.ffi
|
||||||
|
|
||||||
IN: unix
|
IN: unix
|
||||||
|
|
||||||
|
@ -75,7 +78,17 @@ FUNCTION: void* mmap ( void* addr, size_t len, int prot, int flags, int fd, off_
|
||||||
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
FUNCTION: int munmap ( void* addr, size_t len ) ;
|
||||||
FUNCTION: uint ntohl ( uint n ) ;
|
FUNCTION: uint ntohl ( uint n ) ;
|
||||||
FUNCTION: ushort ntohs ( ushort n ) ;
|
FUNCTION: ushort ntohs ( ushort n ) ;
|
||||||
FUNCTION: int open ( char* path, int flags, int prot ) ;
|
FUNCTION: char* strerror ( int errno ) ;
|
||||||
|
|
||||||
|
TUPLE: open-error path flags prot message ;
|
||||||
|
|
||||||
|
: open ( path flags prot -- int )
|
||||||
|
[ ] [ unix.ffi:open ] 3bi
|
||||||
|
dup 0 >=
|
||||||
|
[ nip nip nip ]
|
||||||
|
[ drop err_no strerror open-error boa throw ]
|
||||||
|
if ;
|
||||||
|
|
||||||
FUNCTION: int pclose ( void* file ) ;
|
FUNCTION: int pclose ( void* file ) ;
|
||||||
FUNCTION: int pipe ( int* filedes ) ;
|
FUNCTION: int pipe ( int* filedes ) ;
|
||||||
FUNCTION: void* popen ( char* command, char* type ) ;
|
FUNCTION: void* popen ( char* command, char* type ) ;
|
||||||
|
@ -96,7 +109,6 @@ FUNCTION: int setreuid ( uid_t ruid, uid_t euid ) ;
|
||||||
FUNCTION: int setsockopt ( int s, int level, int optname, void* optval, socklen_t optlen ) ;
|
FUNCTION: int setsockopt ( int s, int level, int optname, void* optval, socklen_t optlen ) ;
|
||||||
FUNCTION: int setuid ( uid_t uid ) ;
|
FUNCTION: int setuid ( uid_t uid ) ;
|
||||||
FUNCTION: int socket ( int domain, int type, int protocol ) ;
|
FUNCTION: int socket ( int domain, int type, int protocol ) ;
|
||||||
FUNCTION: char* strerror ( int errno ) ;
|
|
||||||
FUNCTION: int symlink ( char* path1, char* path2 ) ;
|
FUNCTION: int symlink ( char* path1, char* path2 ) ;
|
||||||
FUNCTION: int system ( char* command ) ;
|
FUNCTION: int system ( char* command ) ;
|
||||||
FUNCTION: int unlink ( char* path ) ;
|
FUNCTION: int unlink ( char* path ) ;
|
||||||
|
|
|
@ -18,6 +18,8 @@ const char *vm_executable_path(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SYS_inotify_init
|
||||||
|
|
||||||
int inotify_init(void)
|
int inotify_init(void)
|
||||||
{
|
{
|
||||||
return syscall(SYS_inotify_init);
|
return syscall(SYS_inotify_init);
|
||||||
|
@ -32,3 +34,25 @@ int inotify_rm_watch(int fd, u32 wd)
|
||||||
{
|
{
|
||||||
return syscall(SYS_inotify_rm_watch, fd, wd);
|
return syscall(SYS_inotify_rm_watch, fd, wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int inotify_init(void)
|
||||||
|
{
|
||||||
|
not_implemented_error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int inotify_add_watch(int fd, const char *name, u32 mask)
|
||||||
|
{
|
||||||
|
not_implemented_error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int inotify_rm_watch(int fd, u32 wd)
|
||||||
|
{
|
||||||
|
not_implemented_error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue