Hipe : HTML Interface Pipe
How Hipe Works  |  Installation  |  Running hiped  |  Hipe API

The Hipe API
Including libhipe
libhipe functions
C++ extensions
Multithreading considerations
Hipe instructions
Interprocess communication
Tags, attributes and styles
Locations
HIPE_OP_ADD_FONT
HIPE_OP_ADD_STYLE_RULE
HIPE_OP_ADD_STYLE_RULE_SRC
HIPE_OP_APPEND_TAG
HIPE_OP_APPEND_TEXT
HIPE_OP_ATTRIBUTE_RETURN
HIPE_OP_AUDIOVIDEO_STATE
HIPE_OP_CANVAS_ACTION
HIPE_OP_CANVAS_QUERY
HIPE_OP_CANVAS_QUERY_RETURN
HIPE_OP_CANVAS_SET_PROPERTY
HIPE_OP_CARAT_POSITION
HIPE_OP_CLEAR
HIPE_OP_CONTAINER_GRANT
HIPE_OP_CONTENT_RETURN
HIPE_OP_DELETE
HIPE_OP_DIALOG
HIPE_OP_DIALOG_INPUT
HIPE_OP_DIALOG_RETURN
HIPE_OP_EDIT_ACTION
HIPE_OP_EDIT_CONTEXT_REQUEST
HIPE_OP_EDIT_STATUS
HIPE_OP_EVENT
HIPE_OP_EVENT_CANCEL
HIPE_OP_EVENT_REQUEST
HIPE_OP_FIFO_ADD_ABILITY
HIPE_OP_FIFO_CLOSE
HIPE_OP_FIFO_DROP_PEER
HIPE_OP_FIFO_GET_PEER
HIPE_OP_FIFO_INFO
HIPE_OP_FIFO_OPEN
HIPE_OP_FIFO_REMOVE_ABILITY
HIPE_OP_FIFO_RESPONSE
HIPE_OP_FILE_RETURN
HIPE_OP_FIND_RESULT
HIPE_OP_FIND_TEXT
HIPE_OP_FRAME_CLOSE
HIPE_OP_FRAME_EVENT
HIPE_OP_FREE_LOCATION
HIPE_OP_GEOMETRY_RETURN
HIPE_OP_GET_ATTRIBUTE
HIPE_OP_GET_AUDIOVIDEO_STATE
HIPE_OP_GET_BY_ID
HIPE_OP_GET_CARAT_POSITION
HIPE_OP_GET_CONTENT
HIPE_OP_GET_FIRST_CHILD
HIPE_OP_GET_FRAME_KEY
HIPE_OP_GET_GEOMETRY
HIPE_OP_GET_LAST_CHILD
HIPE_OP_GET_NEXT_SIBLING
HIPE_OP_GET_PREV_SIBLING
HIPE_OP_GET_RANGE_GEOMETRY
HIPE_OP_GET_SCROLL_GEOMETRY
HIPE_OP_GET_SELECTION
HIPE_OP_GET_STYLE
HIPE_OP_INSERT_TAG
HIPE_OP_GET_X11_XID
HIPE_OP_INSERT_TAG
HIPE_OP_KEY_RETURN
HIPE_OP_LOCATION_RETURN
HIPE_OP_MEASURE_TEXT
HIPE_OP_MESSAGE
HIPE_OP_OPEN_LINK
HIPE_OP_RANGE_GEOMETRY
HIPE_OP_REMOVE_ATTRIBUTE
HIPE_OP_REQUEST_CONTAINER
HIPE_OP_SCROLL_BY
HIPE_OP_SCROLL_TO
HIPE_OP_SERVER_DENIED
HIPE_OP_SERVER_NOTICE
HIPE_OP_SET_ATTRIBUTE
HIPE_OP_SET_CURSOR
HIPE_OP_SET_FOCUS
HIPE_OP_SET_ICON
HIPE_OP_SET_SRC
HIPE_OP_SET_STYLE
HIPE_OP_SET_STYLE_SRC
HIPE_OP_SET_TEXT
HIPE_OP_SET_TITLE
HIPE_OP_SRC_RETURN
HIPE_OP_STYLE_RETURN
HIPE_OP_TAKE_SNAPSHOT
HIPE_OP_TEXT_METRICS
HIPE_OP_TOGGLE_CLASS
HIPE_OP_USE_CANVAS
HIPE_OP_X11_XID_RETURN

Locations

A location is a number that names one element of your frame. Instructions act on the element named by their location field. Location 0 is the body element.

Who gives an element its location

Your application does, through libhipe, without asking the display server. Each session has its own pool of numbers. An element gets a location only when you give it one:

How the element is createdHow it gets its location
HIPE_OP_APPEND_TAG, HIPE_OP_INSERT_TAGAutomatically. Read it with hipe_newest_location() straight after sending.
Markup (HIPE_OP_SET_TEXT / HIPE_OP_APPEND_TEXT mode 3)Reserve numbers with hipe_reserve_location() or hipe_reserve_locations(), write hipe-loc="N" on the elements, and list the numbers in arg[2], e.g. with hipe_send_markup().
Anything else: markup elements without hipe-loc, elements the HTML parser adds, elements created by the user's editing or pastingNone. They can't be named in instructions.

Lookups (HIPE_OP_GET_BY_ID, HIPE_OP_GET_FIRST_CHILD, HIPE_OP_GET_LAST_CHILD, HIPE_OP_GET_NEXT_SIBLING, HIPE_OP_GET_PREV_SIBLING) return an element's location, or 0 if it has none. They never give an element a location.

Each element has at most one location and each location names at most one element, so two locations are equal exactly when they name the same element.

Numbering markup

hipe_loc rows = hipe_reserve_locations(session, 3);
hipe_loc list[3] = {rows, rows+1, rows+2};
/* markup: <div hipe-loc="(rows)">...</div><div hipe-loc="(rows+1)">...</div>... */
hipe_send_markup(session, fileList, markup, 0, list, 3);
hipe_send(session, HIPE_OP_EVENT_REQUEST, 0, rows, 1, "click"); /* usable straight away */
CaseResult
A listed number is on an elementThe element gets that location. The hipe-loc attribute is removed.
A listed number is on no element (the HTML parser dropped the element, or the number wasn't used)The location names no element: instructions sent to it do nothing. Free it as usual. The server reports it (see "Errors and notices").
A listed number is on two elementsThe first gets it. Reported.
A hipe-loc number that isn't listedIgnored, and the attribute is removed.
A listed number is already in use, or the list is malformedFatal: your application is disconnected (see "Errors and notices").

hipe-loc never stays in the document. It is removed as markup is inserted, and HIPE_OP_SET_ATTRIBUTE refuses it. So HTML you pass through, such as text a user pasted, can't take over your locations.

A list in arg[2] (and in HIPE_OP_FREE_LOCATION) is comma-separated numbers and ranges, with no spaces: "57", "57,58,93", "1000-1499", "57,1000-1499". Each number may appear once.

Freeing locations

Free a location with HIPE_OP_FREE_LOCATION when you no longer need it. Many at once: arg[0] = "1000-1499". All of a session's locations are freed when it closes.

Locations in removed content stay in use until you free them. Only your application knows which copies of a number it still holds, so a number never becomes free by itself. When HIPE_OP_SET_TEXT replaces an element's contents, or an element is deleted, locations inside it still name the removed elements while anything keeps them (for example the undo history, which may bring them back); instructions sent to them have no visible effect. Once nothing keeps them, they name no element. To re-render a region, free its old locations in one instruction and reserve new ones.

Freeing a location also takes it off its element. If the element comes back into the document later (for example, the user undoes the deletion of a paragraph), it comes back with no location, so it can never be confused with an element you have since given that number.

Locations and events

Limits

LimitValue
Locations in use in one frame4,194,304. Going over is fatal.
Location numbers1 and up, below 263 (the top bit is reserved). libhipe always gives valid numbers.

Errors and notices

KindWhat happens
Fatal: a number already in use, a malformed list, too many locationsThe server sends HIPE_OP_SERVER_DENIED with the reason and disconnects. libhipe prints the reason to stderr, and hipe_last_error() returns it.
Not fatal: a listed number found on no element, or used twiceThe server sends HIPE_OP_SERVER_NOTICE. libhipe prints it to stderr.