More 156_WorldName____________(Read)_(Active: n)_(Log)_(Mail)_(Over)_12:34
The status_fields variable contains a list of descriptions of fields to be displayed on the status line. Each description consists of:
Fields without names are used to indicate padding between named fields. Field names enclosed in quotes (", ', or `) are displayed literally; use the \ character to escape a quote inside the string. Field names beginning with "@" correspond to internal states. Other field names correspond to the variable with the same name. TF will monitor the internal state or variable corresponding to each internal and variable field, and update those fields whenever the monitored item changes. Also, the entire status line will be updated whenever the screen is redrawn or the status_fields variable is modified.
The actual format of an internal or
variable field displayed on the
status line is determined by evaluating the
expression contained in the
variable
status_int_name
(for internal state
@name
) or
status_var_name
(for variable name
).
Also, for variable
fields, if status_var_name
is not
set, the value of the variable
will be displayed directly. Changing a format variable will not cause
the status line to update; to force an update, you can
"/dokey redraw
" (^L), or
"/test
status_fields :=
status_fields
".
A field's width determines how many columns it will take up on the screen. If the width of a string literal field field is omitted, it defaults to the length of the string literal. One other field width may be omitted, which means that field will use whatever columns are unused by the other fields. Normally, fields are left-justified within the width, but a negative field width will right-justify the field within the absolute value of the width. If the formatted text is wider than the field width, it will be truncated to fit within the specified width. Fields may also be truncated if they would not fit on the screen.
The attributes are applied to the field text when it is displayed, but are not applied to the padding used to bring the field to the specified width.
Any variable may be monitored, but there is a fixed list of internal statuses. The internal statuses available are:
@more
@world
@read
@active
@log
@mail
@clock
The entire status line, including padding, is displayed with the attributes given by %status_attr, which is none by default. Individual field attributes are combined with %status_attr attributes.
To bring fields up to their specified width, they are padded with %status_pad, which is "_" by default. By setting status_pad to " " and status_attr to "r", you can create a status line that looks more like the one in emacs or the irc client.
All this may sound rather complex, so an example might help. The default value of status_fields is:
@more:8:Br :1 @world :1 @read:6 :1 @active:11 :1 @log:5 :1 @mail:6 :1 insert:6 :1 @clock:5and the corresponding format variables are:
/set status_int_more \ moresize() == 0 ? "" : \ moresize() > 9999 ? "MuchMore" : \ pad("More", 4, moresize(), 4) /set status_int_world ${world_name} /set status_int_read nread() ? "(Read)" : "" /set status_int_active nactive() ? pad("(Active:",0,nactive(),2,")") : "" /set status_int_log nlog() ? "(Log)" : "" /set status_int_mail \ !nmail() ? "" : \ nmail()==1 ? "(Mail)" : \ pad("Mail", 0, nmail(), 2) /set status_var_insert insert ? "" : "(Over)" /set status_int_clock ftime("%I:%M", time())
The first field is "@more:8:Br
". So, whenever the number of
unseen lines changes, TF looks for the
variable
status_int_more
, and evaluates the
expression it contains.
The result of the expression
is printed in the first 8 columns of the status line, with
attributes "Br" (bold and reverse).
The expression was carefully
written so that it will never be more than 8 characters, because it would be
confusing to generate something like "More:12345
" and then have
it truncated to "More:123
" because of the field width of 8.
Since the "@world
" field has no explicit width, its width
is determined dynamically.
The fields on its left are pushed to the left side of the screen,
the fields on its right are pushed to the right side of the screen, and
the "@world
" field uses whatever space remains in the middle.
The unnamed fields with width 1 are used to display a pad character between the named fields.
Another example: Say your mud has a
prompt like
"H:42 M:17>
" that shows your hit points and mana,
and you want it displayed on the status line like
" 42, 17
".
To do this, add "hp_mana:7
" to the
status_fields
variable,
and define a prompt
hook:
/def -mregexp -h"PROMPT ^H:([^ ]*) M:([^ ]*)> $" hp_mana_hook = \ /set hp=%P1%; \ /set mana=%P2%; \ /set hp_mana=$[pad(hp, 3, ",", 0, mana, 3)]%; \ /test prompt({*})
See: visual