OBJECT
/obj/lib/string
SYNOPSIS
inherit "/obj/lib/string";
(or use call_other to use the functions)
#include "/obj/lib/string.h"
#include "/obj/lib/string_p.h" for the prototypes
...
string mkstr(int len, void|string pattern)
string ladjust(string str, int len, void|string pattern)
string ladjcut(string str, int len, void|string pattern)
string radjust(string str, int len, void|string pattern)
string radjcut(string str, int len, void|string pattern)
string cadjust(string str, int len, void|string pattern)
string cadjcut(string str, int len, void|string pattern)
string string_replace(string str, string old, string new)
string strip_blanks(string str)
int string_compare(str1, str2)
string *sort_strings(string *strs, void|string compare_fun)
string *break_string(string str, int len)
string *break_line(string str, void|int len, void|string prefix)
string wrap(string str,int length,void|int rspace)
string lit_string(string str)
string val_to_str(mixed value, void|int depth)
string mixed_to_string(mixed value, void|int depth)
string stime(int date, void|int fmt)
varargs smore(mixed text, int chunk, object ob, string fun, int end)
void input_text(void|string function,void|object ob,void|object player,
void|string text)
LAST UPDATE
18-May-1995, Thragor
DESCRIPTION
string mkstr(int len, void|string pattern)
Returns a string of length <len> made out of <pattern>, or
of spaces if <pattern> is not defined.
string ladjust(string str, int len, void|string pattern)
Returns <str> adjusted to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given) to its tail. If <str> is longer
than <len>, it remains unchanged.
string ladjcut(string str, int len, void|string pattern)
Returns <str> adjusted to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given) to its tail if <str> is too short,
or by removing extraneous characters from the tail if <str> is too
long.
string radjust(string str, int len, void|string pattern)
Returns <str> adjusted to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given) to its head. If <str> is longer
than <len>, it remains unchanged.
string radjcut(string str, int len, void|string pattern)
Returns <str> adjusted to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given) to its head if <str> is too short,
or by removing extraneous characters from the head if <str> is too
long.
string cadjust(string str, int len, void|string pattern)
Returns <str> centered to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given).
If <str> is longer than <len>, it remains unchanged.
string cadjcut(string str, int len, void|string pattern)
Returns <str> centered to length <len> by repeatedly adding <pattern>
(or spaces if <pattern> isn't given) if <str> is too short, or by
removing extraneous characters from its tail if <str> is too long.
string string_replace(string str, string old, string new)
Return <str> with all occurences of <old> replaced by <new>.
string strip_blanks(string str)
Replace all blank-sequences in <str> by a single blank and return
the result.
string genitive(string word)
Return the word with the correct genetiv-ending, i. e. with
"'" for all words ending with s, x or z and otherwise "'s".
string article(string word)
Return the word with the correct undefined article, i. e. with
"an" for all words beginning with a vocal and otherwise "a".
int string_compare(string str1,string str2)
Return if str1 is lexicographically greater than str2.
This fun is meant mainly for use by sort_strings().
string *sort_strings (string *strs, void|string|closure compare_fun)
Sort an array <strs> of strings by using <compare_fun> (default is
the closure "'>) and return the sorted array.
<compare_fun> should be of type int (string, string) and return
nonzero if the first string is 'greater' than the second.
string *break_string (string str, int len)
Break <str> into parts of length <len> and return an array of these
parts.
string *break_line (string str, void|int len, void|string prefix)
Clips a <text> (w/o newlines!) wordwise down to a linelength <len>
(default 78) and return the array of the resulting lines.
Any additional line is prefixed with <prefix> if given.
If a single word itself is longer than <len>, it will be splitted as
well.
string wrap(string str,void|int length,void|int lspace)
Adds newlines to a string, if one part of the string is
longer than <length>-<lspace> chars. <lspace> spaces will
be added in front of the line. This is except for the first
line. This line will have <length> chars and start in the
first column.
Default length: 78.
string lit_string (string str)
Replace any control characters (tab, \, newline, CR) in <str> by their
LPC-notation (\t, \\, \n, \r) and return the result.
string val_to_str (mixed value, void|int depth)
Make a printable string from any value.
An integer returns as "<value>".
A string returns as "'<text>'".
An object returns as "[<object_object_name>]".
An array returns "({ <array_contents> })", with the contents
recursively expanded.
In max are <depth>-1 recursions, then the contents are hinted by "..".
<depth> == 0 expands any depth.
string mixed_to_string (mixed value, void|int depth)
Makes a string in LPC-notation from any value.
An integer returns as "<value>".
A string returns as ""<text>"" with the inner " explicitely given.
An object returns as "[<object_object_name>]".
An array returns "({ <array_contents> })", with the contents
recursively expanded.
In max are <depth>-1 recursions, then the contents are hinted by "..".
<depth> == 0 expands any depth.
string stime (int date, void|int fmt)
Like cdate() this returns a numeric <date> converted into a string,
but in a more european manner like 'Mon 15-Jun-1992 20:00:00'.
<fmt> specifies which parts appear by or'ing the approbiate constants:
SD_WDAY : day of the week
SD_DATE : the date itself
SD_SDATE : the date itself, but w/o the century
SD_TIME : the time
A zero <fmt> defaults to (SD_WDAY | SD_DATE | SD_TIME) == SD_FULL.
static string *_smore_text;
An array of the text lines to display by (_even_)smore().
static int _smore_line;
The current line smore is at.
static int _smore_size;
The size of _smore_text.
static int _smore_chunk;
The size of one page to display.
varargs smore (mixed text, int chunk, object ob, string fun, int end)
Mores the <text> to the player in chunks of <chunk> lines.
Default for <chunk> is 16 lines per page or the player's pagesize.
<text> may be one single string, each line terminated by a \n,
or an string-array containing the lines.
The more accepts following commands:
[CR], d : next page
u , b : last page
f : go to the first page
l : go to the last page
<nr> : go to line <nr>
/<regexp>: scan forward until line matching <regexp>
/ : repeats last /<regexp> command
a : redisplay actual page
p : print asynchronously all remaining text (in chunks of
40 lines)
? : a list of these commands
q : quits more.
There is a macro SMore(text) defined in string.h, which automatically
asks this_player() for her PAGESIZE-Property.
In detail, smore() just displays the first page, inits the vars
and then gives input_to() to _even_smore().
If <ob> and <fun> was given then in _even_smore() the function fun in
object ob is called by call_other.
If <end> is given then _even_smore() will abruptly stop at the end of
the text. Otherwise you will get one more prompt before the EOF.
The data for smore() is stored in this_player() as the
property "_SMore_<filename>", so smore() is multi-user
secure.
void smore_prompt (int actline, int maxline)
Print the prompt for smore. <firstline>, <lastline> specify the
printed page, <maxline> the highest line-no
void smore_help (int chunksize)
Print the list of commands available at the prompt.
int _even_smore (string str)
Execute the smore-command given in string and display the 'next' page
of the text inited by smore().
void input_text(void|string function,void|object ob,void|object player,
void|string text)
This is an editor which may be used by any object. You simply have
to call the function input_text() in it. This may be done via
inherit or just call the function via call_other. Minimal arguments
are none. In this case all will be replaced by default values.
The default-values are:
function = "input_done"
player = this_player()
ob = this_object() or, if this_object() is the same
as the editor-file, the previous_object() is
taken. This allows you to call it via call_other
without specifying to which object it should
return.
text = empty text
The parameters are in detail:
function: This is the function which will be called in the
specified object ob, if the input is finished. It
will get the whole text as argument.
player: This is the player who's editing.
ob: The object in which the function <function> will be
called, when the input is finished.
text: If specified, this is the text which can the player
can edit. E. g. if the player already wrote a text
and now wants to append some lines, you may give the
old text as argument here.
The editor offers some functions like help-page, delete of the
last line and redisplay of the text. If the input comes to an
abnormal end, e. g. if the player canceled the message with '~q'
the argument returned to the function <function> will be 0.
As you see the minimum call to use the edit-function is simply:
input_text();
All other settings will be done automatically.
When reaching the input_text() statement, all is done like in
input_to(), i. e. the function calling input_text() will continue.
The input_text() just means that the next inputs will be handled
by the editor and not the parser and that, if the text is complete,
the function <function> will be called.
INHERITANCE TREE
string
EXAMPLES
/players/thragor/item/input_exm
SEE ALSO
input_to(E), number(L)