Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
mpmxyz

cbrowse - inspecting lua components and other objects

Recommended Posts

Introduction

 

cbrowse is a program you can use to inspect and modify the lua environment and components - the latter one being the reason I developed such a complex program in the first place.

You can find a detailed description in the man page.

To get a quick overview I recommend the following picture series:

Viewing and Editing

 

example_1a.png

(creating and viewing a new table)

example_1b.png

(editing it)

example_1c.png

Default Screens

 

example_2_startup.png

(startup screen)

example_2_components.png

(contents of "directories")

example_2_libraries.png

(contents of "libraries"; also: some libraries hinting at my next project)

Other Features

 

example_3_indexing.png

(indexing the table using "_V" to choose the values column and ".cn" to chose the cell containing the number 44.)

example_3_colors.png

(a selection of values to show the color highlighting)

example_2_long_strings.png

(a screen showing a string value)

 

Man Page

 

NAME
  cbrowse - inspecting lua components and other objects
   
SYNOPSIS
  cbrowse [options] [commands...]
   
DESCRIPTION
  cbrowse is a development tool with a heavy focus on inspecting Lua objects.
   
  It features a single command line as input that accepts Lua code or - when using the prefix "sh " including the space - shell commands.
  (includes tab autocompletion for Lua code)
  After hitting enter the command is executed and a list of returned values is displayed if there were any.
  You can return to the previous display via Ctrl+C. The program itself is closed by exiting the top level or via an interrupt. (Ctrl+Alt+C)
  You can reload the display by hitting F5.
  Scrolling is done via Page down/up or via using the mouse wheel.
   
  There are 3 types of displays:
    list
      This contains a list of values - showing their type in one column and some text to describe their value in another one. (used as default)
      Each value has got a 1 or 2 letter identifier shown to ease access from Lua commands.
      (-> use _V.a to access the first value via Lua, _V.b for the second etc.)
    table
      This contains a combination of keys and values and is used to display Lua tables. (used when a single table is returned)
      Each key value pair has got a 1 or 2 letter identifier as described in the previous paragraph.
      (-> use _K.a to access the first key, _V.b for the second value)
    string
      This shows a Lua string with character based line wrapping. (used when a single string is returned)
   
  You are able to access a special environment using Lua commands.
  It is a proxy merging the currently viewed object with the global environment and some extra values.
  Since there may be collisions it is necessary to prioritize the contents:
    1st: special values (overrides the other contents)
      There are up to 5 of them:
        _OBJ: the currently displayed object
        _G: the global environment
        _K: a list of keys (if available)
        _V: a list of values (if available)
        _REG: a special registry table used by cbrowse to display names for non primitive values
          When using the name as an index you get the object associated with the name.
          When using an object as an index you get its name.
          You can use the registry for the following types:
            type      name format
            function  "f1234"
            userdata  "u1234"
            thread    "T1234"
            table     "t1234"
    2nd: current object (a list of values is just a table using integer indices)
    3rd: a sandboxed global environment - with automatic require
     
  Writing access uses the same priority but defaults to the current object as a target if the reading operation didn't find a non nil value.
  (This implies that there IS a reading operation before every writing operation. Use one of the special values to bypass that behaviour.)
   
  When a command calls a gpu function that might modify the screen it will make cbrowse enter a graphics debug mode:
    -The screen is cleared before the function is executed.
    -After finishing the command the screen will freeze until you hit a key.
  Changes in primary GPU and screen or resolution are also detected. (->The screen is redrawn.)
   
  cbrowse also supports left and right clicks on keys or values.
    A left click inserts a reference to the clicked object.
    A right click inserts "=reference" and hits enter for you.
      That way you can immediately look at an object you are interested in.
      Functions behave a bit differently:
      "=reference()" is insered and the cursor is moved one character to the left to allow you to type in parameters.
       
OPTIONS
  --clean
    disables loading libraries and components on startup
    This is highly recommended if you don't have a lot of memory installed.
   
  --noevent
    disables updates to the list of components
     
  --env
    uses the first non option parameter as a global environment (_G)
   
  For non option parameters it tries to find a value by using the parameter:
    1st: as a component address
    2nd: to get a primary component
    3rd: as a library name
    4th: as code executed via the cbrowse command line
  Using the --raw option disables this behaviour and instead uses arguments without processing. (useful if you call cbrowse for debugging your own program)
   
EXAMPLES
  cbrowse
    starts cbrowse in the default screen
     
  cbrowse --clean
    starts cbrowse without loading all libraries and components available on the computer
      sh ls
        executes command "ls" in the shell
        cbrowse is waiting for a key input after execution because ls printed some output. (You should have a chance to read it after all.)
  cbrowse redstone
    The initial screen now contains a reference "==default==" to the default object and a reference "redstone" to a redstone component proxy.
      =redstone
        move to the loaded redstone component
      =getInput(sides.north)
        show the redstone input at the northern side of the redstone component
 
DEBUGGING
  cbrowse can be used as a debugging aid by executing it from within your program:
    local a, b, c = "test", 3.14, os
    require"cbrowse".view(a, b, c)
  Some words of advice though:
    1st
      It will consume events using event.pull. (like term.read)
      If you expect to pull some events after running it, it might change the programs behaviour.
    2nd
      Due to a limitation of shell.execute you can't have nil values as a parameter. All values after a nil value are just ignored.
      (The library is just a shortcut for a shell.execute call.)
      If you need that function, consider using a table:
        require"cbrowse".view{a, b, c}

 

 

Depencencies

 

Software

All required libraries are included in the download.

 

Hardware

GPU +  screen: min. 20x7 monochrome, 80x25 with colors recommended

RAM: min. 384 KiB, recommended: >=512 KiB

 

Installation

 

Simply download the tar archive and extract it into the root directory.

All files should then be there where they should be.

 

Download (last update: 13.04.17)

 

github

 

Ingame:

wget 'https://raw.githubusercontent.com/mpmxyz/ocprograms/master/tars/cbrowse.tar'
tar -xf cbrowse.tar

OR

oppm install cbrowse

Known Issues

 

There is no shell autocompletion. (I still need to look into it.)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.