[REBOL] Re: Rebol TUI for Command Line Linux(browse-system.r)/OOPS!
From: tim::johnsons-web::com at: 28-Oct-2003 11:12
Sorry, I keep forgetting that listar strips attachments.
Ben, you can download at
http://www.johnsons-web.com/browse-system.r
tim
* Tim Johnson <[tim--johnsons-web--com]> [031028 08:41]:
> * Ben Minton <[benminton--austarnet--com--au]> [031028 02:49]:
> >
> > Hi List,
> Hi Ben:
> I am attaching browse-system.r
> You might find this to be an example of how to
> a simple text-based interface. It isn't really
> text-cell graphics but it is an understandable
> interface and *also* is a good way to understadn
> the rebol system and resources.
>
> BTW: The author was on the rebol development team
> and is a member and frequent contributor to this
> list.
>
> tj
>
> > I previously posted a question re a rebol web browser
> > for a command line linux install. Both Tom and Tim
> > (thanks to you both), gave a reply or two and
> > suggested that I refine my questions, back to the list.
> >
> > One reply stated that I can 'use ansi escape
> > sequences to build some sort of TUI'.
> >
> > Has anyone had experience with this? I was also
> > suggested to go to rebolforces.com and look
> > at 'Dialecting and the Console' , which I am doing now.
> >
> > Just for info, the reason why I have a command line
> > linux install is I am using old gen PCs and a desire to
> > learn linux, from actually tinkering.
> >
> > Thanks, Ben
> > --
> > To unsubscribe from this list, just send an email to
> > [rebol-request--rebol--com] with unsubscribe as the subject.
>
> --
> Tim Johnson <[tim--johnsons-web--com]>
> http://www.alaska-internet-solutions.com
>
> -- Attached file included as plaintext by Ecartis --
>
> REBOL [
> Title: "System Object Browser"
> Date: 3-Jun-1999
> Author: "Bohdan Lechnowsky"
> Email: [bo--rebol--com]
> File: %browse-system.r
> Purpose: {
> To make browsing the system object safe and easy.
> Also allows changes to be made.
> }
> Category: [script utility]
> ]
>
> align: function [
> "Forms data into a specified number of columns with optional alignment"
> data length /left /right /center] [len] [
> if right [
> return head copy/part
> tail insert/dup head form data " " length
> (length * -1)
> ]
> if center [
> data: head insert/dup head form data " " len: (length / 2)
> data: head insert/dup tail data " " len
> return copy/part at data ((length? data) / 2 - len + 1) length
> ]
> return copy/part head insert/dup tail form data " " length length
> ]
>
> parent-item: func [path] [
> either find path "/" [
> path: tail path
> while [not find/part path "/" 1] [
> path: back path
> ]
> return head clear path
> ][
> print "^/ERROR: You are already at the top of the system object"
> return path
> ]
> ]
>
> protocol-menu: func [path] [
> if not object? path [
> display path
> return none
> ]
>
> if current-path = "system/words" [
> print "^/ERROR: Accessing system/words will lead to an endless recursive loop"
> return none
> ]
>
> protocols: remove copy first path
>
> print [newline "===" current-path "==="]
>
> if current-path <> "system" [print " 0 > PARENT"]
> for index 1 (length? protocols) 1 [
> prin [(align/right index 3) ">" (align pick protocols index 20)]
> if not all [(current-path = "system") ((pick protocols index) = 'words)] [
> if (not find value: mold pick (second path) (index + 1) "^/") [
> prin align value 50
> if (length? value) > 50 [prin " ..."]
> ]
> ]
> prin newline
> ]
> print " 99 > EXIT"
>
> prin newline
>
> while [error? try [choice: to-integer ask "->"]] [
> print "ERROR: Please enter a number from the list above"
> ]
>
> either error? try [field: pick protocols choice] [
> current-path: parent-item current-path
> return none
> ][
> if choice = 99 [halt]
> return field
> ]
> ]
>
> display: func [path] [
> print ["The value of" current-path "is" mold path newline]
>
> choice: ask "Do you want to change this (y/n)? "
>
> if choice = "y" [
> value: load ask "What is the new value: "
> do command: rejoin [current-path ": " mold value]
> print [
> newline "To make this change permanent, add the following"
> "line to your %user.r file:" newline newline command newline
> ]
> choice: ask "Do you want me to add this to your %user.r file (y/n)? "
> if choice = "y" [
> either exists? user: join system/options/home %user.r [
> write/append user append command newline
> print [newline "Made addition to" user]
> ][
> either exists? %user.r [
> write/append %user.r append command newline
> print [newline "Made addition to" join what-dir %user.r]
> ][
> print [newline "ERROR: Could not find %user.r or %../user.r"]
> ]
> ]
> ]
> ]
> ]
>
> start: func [] [
> current-path: "system"
>
> while [true] [
> if error? try [selection: protocol-menu do current-path][
> print [newline "ERROR: Cannot view this item"]
> selection: none
> ]
> either found? selection [
> current-path: rejoin [current-path "/" selection]
> ][
> current-path: parent-item current-path
> ]
> ]
> ]
>
> start
>
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com