webbrowser: let's change the name open-file -> open-item

Because the word can open more stuff than just files.
char-rename
Björn Lindqvist 2016-12-18 03:23:24 +01:00
parent 88015e9632
commit 5f5098617a
9 changed files with 17 additions and 22 deletions

View File

@ -81,7 +81,7 @@ IN: tools.deploy.macosx
bundle-name
[ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi
open-directory-after-deploy? get [ bundle-name open-file ] when ;
open-directory-after-deploy? get [ bundle-name open-item ] when ;
: deploy-app-bundle? ( vocab -- ? )
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;

View File

@ -15,7 +15,7 @@ M: unix deploy*
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
[ nip open-directory-after-deploy? get [ open-file ] [ drop ] if ]
[ nip open-directory-after-deploy? get [ open-item ] [ drop ] if ]
} 2cleave ;
M: unix deploy-path

View File

@ -33,7 +33,7 @@ M: windows deploy*
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
[ nip open-directory-after-deploy? get [ open-file ] [ drop ] if ]
[ nip open-directory-after-deploy? get [ open-item ] [ drop ] if ]
} 2cleave ;
M: windows deploy-path

View File

@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ;
IN: webbrowser.linux
M: linux open-file ( path -- )
M: linux open-item ( item -- )
present "xdg-open" swap 2array run-detached drop ;

View File

@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ;
IN: webbrowser.macosx
M: macosx open-file ( path -- )
M: macosx open-item ( item -- )
present "open" swap 2array run-detached drop ;

View File

@ -1,16 +1,14 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: help.markup help.syntax strings webbrowser ;
USING: help.markup help.syntax kernel present strings ;
IN: webbrowser
HELP: open-file
{ $values { "path" string } }
HELP: open-item
{ $values { "item" object } }
{ $description
"Open a specified file or directory in a detached process using "
"the default application, similar to double-clicking the file's icon."
} ;
"Opens an item, which is either a file, directory or url in a detached process using the default application, similar to double-clicking the file's icon. item is any object that has the " { $link present } " method." } ;
HELP: open-url
{ $values { "url" string } }

View File

@ -1,4 +1,4 @@
USING: tools.test ;
USING: io.pathnames tools.test ;
IN: webbrowser
{ t } [ "http://reddit.com" url-string? ] unit-test
@ -6,3 +6,5 @@ IN: webbrowser
{ t } [ "ftp://reddit.com" url-string? ] unit-test
{ f } [ "moo" url-string? ] unit-test
{ f } [ 123 url-string? ] unit-test
{ } [ "" absolute-path open-item ] unit-test

View File

@ -1,22 +1,17 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: accessors io.pathnames kernel sequences strings system
ui.operations urls vocabs ;
IN: webbrowser
HOOK: open-file os ( path -- )
HOOK: open-item os ( item -- )
"webbrowser." os name>> append require
: open-url ( url -- )
>url open-file ;
[ pathname? ] \ open-file H{ } define-operation
[ url? ] \ open-url H{ } define-operation
>url open-item ;
PREDICATE: url-string < string >url protocol>> >boolean ;
[ url-string? ] \ open-url H{ } define-operation
[ pathname? ] \ open-item H{ } define-operation
[ [ url? ] [ url-string? ] bi or ] \ open-url H{ } define-operation

View File

@ -4,6 +4,6 @@ USING: io.pathnames kernel present system webbrowser windows.shell32
windows.user32 ;
IN: webbrowser.windows
M: windows open-file ( path -- )
M: windows open-item ( item -- )
absolute-path [ f "open" ] dip present f f
SW_SHOWNORMAL ShellExecute drop ;