1.1.0 • Published 7 years ago

xresourcemanager v1.1.0

Weekly downloads
-
License
Unlicense
Repository
-
Last release
7 years ago
This program provides implementation of X resource manager in JavaScript.
For example it can be used with the Node.js X11 client library, but it can
even be used standalone without any connection to any X server. Program is
written purely in JavaScript and does not use any I/O, DOM, FFI, etc, with
the exception that it does set module.exports to the XRM function.

In this program, a "quark" means either a string or a symbol. The quark
"?" is special. A resource access consists of two lists of quarks, one for
names and one for classes.

XRM function (the exported value of this module) can be called as a
constructor to create a new empty resource database. Can have an optional
argument to set the value of the root node. Each node is also a XRM object
with the same properties methods; the nodes are automatically created.

The instance then has the properties/methods:

.enumerate()
  A generator function; yields the key/value pairs for each key/value pair
  in the database. These pairs are returned as arrays of two elements,
  where the first is the binding/quark list and the second is the value.
  (Not the same as XrmEnumerateDatabase().)

.get(names,[classes])
  Get value of resource, given a list of names and of classes; the list of
  classes may be omitted.

.load(text,[override])
  Load resources from the text, in the X resource manager file format, but
  #include is not supported. If override is true or omitted then it will
  overwrite conflicting entries; if false then existing entries will have
  priority over new ones.

.loose
  A object with no prototype. The keys of this object are the quarks for
  loose bindings at this level.

.merge(db,[override])
  Merge the given database into this one. Can specify whether or not to
  override existing entries; by default it is true.

.put(key,value,[override])
  Put a value to the database. The key is the binding/quark list, which
  is an array of alternating bindings and quarks where bindings can be "."
  or "*" and the quarks can be any string or symbol. Value can be any
  JavaScript value. If undefined or omitted, deletes it (the node itself
  continues to exist though). If override is true or omitted then it will
  write even if the entry already exists, but if false then it will write
  only if the entry is not already exist.

.save()
  Returns a string representation of the database. Won't work if it
  contains any unique quarks or non-string values.

.search(names,classes)
  A generator function that yields resource database node objects. The
  names and classes are two arrays of the same length, containing the list
  of the quarks in the path to search for. The objects it yields are the
  nodes where a match is possible, in order of best priority to worse
  priority. May even yield nodes that lack a value.

.tight
  Similar to loose but for tight bindings.

.value
  The value of this node, or undefined if it has no value.

Static properties of the XRM constructor itself include:

.load(text)
  Load a new database from a string; #include is not supported.

.loadFile(filename)
  Load a new database from a file; #include is supported.

See also:
 https://www.x.org/releases/current/doc/libX11/libX11/libX11.html#Resource_Manager_Functions