file chooser in rebol/view
[1/5] from: rishi:picostar at: 19-Sep-2000 14:23
Will REBOL/View eventually support a graphical file-browser?
Rishi
[2/5] from: ryanc:iesco-dms at: 19-Sep-2000 14:56
Good question... I am (slowly and relucantly) working on one for the
time being. The ETA? Dont get your hopes up, I may just ---- can the
idea. Alternatively I will probably have a console picker done very
shortly, free for all to use.
--Ryan
[rishi--picostar--com] wrote:
> Will REBOL/View eventually support a graphical file-browser?
>
> Rishi
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
We are what we think. All that we are arises
with our thoughts. With our thoughts, we make
the world. --Buddha
[3/5] from: allen:rebolforces at: 20-Sep-2000 9:56
----- Original Message -----
From: <[rishi--picostar--com]>
To: <[list--rebol--com]>
Sent: Wednesday, September 20, 2000 7:23 AM
Subject: [REBOL] file chooser in rebol/view
> Will REBOL/View eventually support a graphical file-browser?
>
> Rishi
>
Yes it will, request-file. You would have noticed the button for it in
Requestor Tests in vidtest.r, right?
Cheers,
Allen K
[4/5] from: rishi:picostar at: 19-Sep-2000 19:48
> > Will REBOL/View eventually support a graphical file-browser?
> >
<<quoted lines omitted: 5>>
> Cheers,
> Allen K
Just noticed it. thanks.
rishi
[5/5] from: aparman:scientist at: 21-Sep-2000 15:06
Here is mine sorry attempt. It's no where near as whiz-bang as ropus.r
(cool!), and still needs some work but you may find bits useful.
*****script follows*****
List of functions and <blocks>
ls main function, call this to list directory contents
[setcurrentdir] accepts <directory>, outputs <dircontents> (sorted)
Can't make this a function, it won't work right
<origdir> saves the original directory when ls is called
<space> creates and sets to 0, words to hold length? of info
<spacer> creates and sets to 0, strings of length? of info
<dirinfo> create and empty block to hold info
<scriptnum> word to hold number of script to list, reset to 1
getinfo get info on each file, set up spacing
creates object info with <size> <date> <type>
and appends to dirinfo [scriptnum file size date type]
<printinfo> print the info out, with proper spacing, order easily modified.
whatnow asks for user direction after listing a directory
<wordcases> block holding user choices and their actions
<convert-lines> called with cl, a copy of the convert-lines.r file
;***************************************************************************
REBOL[
file: %ls.r
title: "LiSt directory contents"
purpose: {"List the contents of the current directory,
or optionally the given directory, with type, size,
and date info. Output in columns for ease of
reading."}
version: 0.3.0
date: 23-May-2000/12:24:38-4:00
version1date: 29-Mar-2000/17:18:07-5:00
category: 'utility
author: "alan parman"
email: [aparman--mail--com]
comment: {"I have made this script a function so you can
put this script in or call it from your user.r file
and 'ls' will always be available"}
usage: {"ls
ls %/your/directory/"}
comment: {Version 0.3.0 Complete revamp. Have 'simplified' the main function
by pulling out
discrete pieces and making them functions. Then I call these in the main
function.
Have added functionality to navigate a directory tree in both directions,
to make directories, or to delete directories/files, and to call the
convert-lines.r
script for changing a file to the local line terminator. Next minor version
will allow
deleting and line conversion by number.
}
{"Version 2.0 Have revamped the process of getting the directories info for
printing and have associated numbers with each listing of the directory.
YOU CAN NOW SELECT A DIRECTORY TO CHANGE TO,
OR A SCRIPT TO RUN, BY ITS NUMBER! COOL!
Still need to add ability to distinguish different file types.
Next minor version would like to revamp the spacer printing
process with console functions.}
{"Version 1.0.0 First 'fully functional' version.
Primarily an exercise in learning REBOL, I wanted
a shorter command than 'list-dir' to see a
directories contents. I also wanted all the info
on a file (type size date), shown in columns for
ease of reading. The name is borrowed from the 'ls'
command of Linux and Unix since it is short and easy
to remember. This script will not list *nix directories
which contain files or directories you do not have read permission for.
I tried to include enough notes so
that even beginning REBOLers like me can change the
order in which the info is printed. Please excuse
my lack of correct style. I find that sometimes it
just gets in the way of clarity.
Version 1.1.0 - added some simplification by blocking
repeated code, and refined the 'if - ask' block at end.
Added more comment documentation.
Version 2 will, I hope, print out more than just
'file' or 'directory' for type."}
]
verbose: on ; change to off to stop the wordiness, (make as a switch later)
;***** set-up the functions
cls: does [prin ["^(1B)[J"] print newline] ;clears the screen
space: [
spacef: 0 ;space for file ; these are the lengths of the info
spaces: 0 ;space for size ; found later
spaced: 0 ;space for date
spacet: 0 ;space for type
] do space
spacer: [
spacerf: make string! 0 ; these are the spacers, the
spacers: make string! 0 ; # of spaces to print between columns
spacerd: make string! 0
spacert: make string! 0
] do spacer
getinfo: func [] [
foreach file dircontents [
info: info? file ; get the info
size: mold info/size ; change the info to type! string
date: mold info/date
type: mold info/type
append dirinfo reduce [scriptnum file size date type] ; you need this block
order later!
scriptnum: scriptnum + 1 ;increment scriptnum with each new file
if (length? file) > spacef [spacef: (length? file)] ;find maximum
if (length? size) > spaces [spaces: (length? size)] ;length of all
if (length? date) > spaced [spaced: (length? date)] ;info
if (length? type) > spacet [spacet: (length? type)]
]; end of foreach
];end of getinfo function
printinfo: func [] [
print ["Contents of " what-dir] ; print the path of the listed directory
foreach [scriptnum file size date type] dirinfo [
loop (spacef - (length? file)) [append spacerf " "] ;make the
loop (spaces - (length? size)) [append spacers " "] ;spacers for the
loop (spaced - (length? date)) [append spacerd " "] ;columns the
loop (spacet - (length? type)) [append spacert " "] ;correct length
; You can specify any order you want by modifying the line below
; Use the pattern 'info' spacer,
; --------- alway put scriptnum first for simplicity, it is an integer!---
do [print [scriptnum type spacert file spacerf size spacers date]]
do spacer ; reset the spacers to zero length
];end of foreach
do space ; reset the info lengths
]; end of printinfo function
whatnow: func [] [
print [newline]
if verbose [
if what-dir <> origdir [print ["Enter a <c> to change to" what-dir ",
or" ]]
print "enter <number> to change to that directory or run that script,
or"
print "enter <cl> to convert that script to the local line terminator
or"
print "enter <u> to go up one directory, or"
print "enter a <m> to make a new directory, or <d> to delete a file or
directory or"
print "hit <enter> to exit ls, <q> to quit this REBOL console "
]
answer: load ask "What would you like to do? :>>"
if (type? answer) = block! [; this is the 'enter nothing' - stay in original
directory
change-dir origdir
]
if (type? answer) = integer! [; I know this could be done with a select -
pick combo how?
foreach [scriptnum file size date type] dirinfo [
if scriptnum = answer [
if type = "directory" [
change-dir file do [print ["Changing path to" file]]
directory: 'file
cls
ls
]
if type = "file" [do file]
ls
] ;end of if
];end of foreach
]
if (type? answer) = word! [
do (select wordcases (form answer))
]
]; end of whatnow function
wordcases: [; request action
c
[print ["Changing path to" what-dir]]
q
[quit]
u
[change-dir %../
directory: what-dir
print ["Changing path to" what-dir]
cls
ls
]
m
[newdir: load ask "Name of new directory? :>>"
make-dir newdir
ls
]
d
[del: load ask "Name of file to delete? :>>"
delete del
ls
]
cl
[cl ; do the convert-lines script
ls
]
]
;{convert-lines function if you don't have it
; Title: "Convert file to local Line terminator"
; file: %convert-lines.r
; date: 25-May-2000/15:23:45-4:00
;}
;
;cl: func [
; {Convert a file's line terminators to the local line terminator, detab,
and trim/auto
; Usage cl <%file> (file is optional, you will be prompted)
; }
;
;file [any-type!] "file or nothing"] [
; if (not value? 'file) [
; file: to-file ask "What file do you want to convert? :>> "
; ]
; write file trim/auto detab read file
;]
;***** end set-up
;***** main function*****
ls: func [
{ List the sorted contents of a directory, with file info, in columns.
Usage: ls or ls %/your/directory/here/
}
[catch] directory [any-type!] "directory to list or nothing"
]; end of spec block
[; body block
origdir: what-dir ; store the original directory so can change it back
; you need to change to user's asked dir because
; info? lines don't seem to work from another dir
dirinfo: make block! [] ; set up block to hold info
scriptnum: make integer! 1 ; set up counter for numbering the directory
contents listed
;setcurrentdir
dircontents: throw-on-error [
if value? 'directory
[change-dir :directory] ; remember to change back to origdir at end
read %.
] dircontents: sort dircontents
getinfo
printinfo
whatnow
];end ls body block
*****script ends*****
------Original Message------
From: [ryanc--iesco-dms--com]
To: [list--rebol--com]
Sent: September 19, 2000 9:56:53 PM GMT
Subject: [REBOL] file chooser in rebol/view Re:
Good question... I am (slowly and relucantly) working on one for the
time being. The ETA? Dont get your hopes up, I may just ---- can the
idea. Alternatively I will probably have a console picker done very
shortly, free for all to use.
--Ryan
[rishi--picostar--com] wrote:
> Will REBOL/View eventually support a graphical file-browser?
>
> Rishi
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
We are what we think. All that we are arises
with our thoughts. With our thoughts, we make
the world. --Buddha
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted