Guides/Window Driver/Session Manager

From J Wiki
Jump to navigation Jump to search

Session Manager commands begin wd 'sm ...', and apply to one or more of:

  • term - the term window
  • edit - the current edit window
  • edit2 - the other (i.e. non-current) edit window, if more than one edit window
  • tab - an edit tab, referenced by index, e.g. tab 3
  • tabs - the edit tabs
  • inputlog - the input log

There are 0, 1, or 2 edit windows. If there is one edit window, it is current. If there are two edit windows, one is always current, becoming so when it is created, when the user clicks on it, or by the corresponding sm focus ... or sm open ... command. The current edit window has a title ending edit; the non-current window, if any, has a title ending edit2.

At any time whichever window most recently had focus is said to be active. The active window may or may not have focus.

In the following commands, term and edit direct the operation to the term window or the current edit window. edit may be replaced by edit2 to have the operation directed to the non-current edit window.

sm act; set input focus to the term window (same as sm focus term)

sm active tab index; activate tab number index in the current edit window

sm close edit; close the edit window
sm close tab index; close tab number index in the current edit window

sm focus edit; set input focus on the edit window
sm focus term; set input focus on term window

sm font fontspec; set font for term and edit windows

sm get active; get which window is active
sm get edit; get text, selection, and file name for current tab in the edit window. Result is a table, where the first column describes the value in the second column, as text, select, or file.
sm get inputlog; get the input log text
sm get tabs edit; get tab visibility and file names for the current edit window
sm get term; get text and selection for term window
sm get termcwh; get character width and height for term window
sm get xywh; get xywh positions of windows. Result is a table where each row is windowname;xywh. The windowname is one of term, edit, and edit2.

sm html *text; display html-formatted text, e.g. display "hello" in red: wd 'sm html *<span style="color:red">hello</span>'

sm open edit; open or activate the edit window and give it focus
sm open tab [filename]; opens a tab in the current edit window with optional filename, returning index of tab

sm profont fontspec; set proportional font

sm prompt text; write text to the term window prompt. See addon general/misc/prompt for an input function that uses this.

sm replace edit filename; save the contents of the current tab of the current edit window into the old filename, then open filename in that tab

sm save edit; save the current tab of the current edit window
sm save tabs; save all edit tabs

sm set ... commands have the form: wd 'sm set {window} {type} {parameters}':
sm set edit select 29 46 ; set selection in current tab of edit window
sm set edit scroll 5; scroll edit window to line number (origin-0) or maximum possible if less
sm set edit text *hello world; set text in current tab of edit window
sm set edit xywh 0 0 500 500; set edit window position
sm set edit xywh -1 -1 500 -1; set edit window position where -1 means unchanged
sm set inputlog text *one',LF,'two'; set the input log text
sm set term text *hello world; set text in term window
sm set term xywh 0 0 500 500; set term window position
sm set term xywh -1 -1 500 -1; set term window position where -1 means unchanged

sm style stylename; set Qt application style, e.g. wd 'sm style fusion'