Changeset 5789230 for fmtext.c


Ignore:
Timestamp:
Jun 5, 2003, 2:26:51 PM (18 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
aac889a
Parents:
ae4cd12
Message:
'isloginout' and 'isprivate' are now message attributes
improved 'info' function lists seperate info for zephyr, aim and
   also prints all message attributes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    rf2f9314 r5789230  
    55static const char fileIdent[] = "$Id$";
    66
    7 void owl_fmtext_init_null(owl_fmtext *f) {
     7void owl_fmtext_init_null(owl_fmtext *f)
     8{
    89  f->textlen=0;
    910  f->textbuff=owl_strdup("");
     
    1516
    1617
    17 void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last) {
     18void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last)
     19{
    1820  int i;
    1921  for (i=first; i<=last; i++) {
     
    2224}
    2325
    24 void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last) {
     26void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last)
     27{
    2528  int i;
    2629  for (i=first; i<=last; i++) {
     
    2932}
    3033
    31 void _owl_fmtext_set_color(owl_fmtext *f, int color, int first, int last) {
     34void _owl_fmtext_set_color(owl_fmtext *f, int color, int first, int last)
     35{
    3236  int i;
    3337  for (i=first; i<=last; i++) {
     
    3741
    3842
    39 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color) {
     43void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color)
     44{
    4045  int newlen;
    4146
     
    5257
    5358
    54 void owl_fmtext_append_normal(owl_fmtext *f, char *text) {
     59void owl_fmtext_append_normal(owl_fmtext *f, char *text)
     60{
    5561  owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT);
    5662}
    5763
    58 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color) {
     64void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color)
     65{
    5966  owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, color);
    6067}
    6168
    6269
    63 void owl_fmtext_append_bold(owl_fmtext *f, char *text) {
     70void owl_fmtext_append_bold(owl_fmtext *f, char *text)
     71{
    6472  owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT);
    6573}
    6674
    6775
    68 void owl_fmtext_append_reverse(owl_fmtext *f, char *text) {
     76void owl_fmtext_append_reverse(owl_fmtext *f, char *text)
     77{
    6978  owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE, OWL_COLOR_DEFAULT);
    7079}
    7180
    7281
    73 void owl_fmtext_append_reversebold(owl_fmtext *f, char *text) {
     82void owl_fmtext_append_reversebold(owl_fmtext *f, char *text)
     83{
    7484  owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE | OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT);
    7585}
    7686
    7787
    78 void owl_fmtext_addattr(owl_fmtext *f, int attr) {
     88void owl_fmtext_addattr(owl_fmtext *f, int attr)
     89{
    7990  /* add the attribute to all text */
    8091  int i, j;
     
    8697}
    8798
    88 void owl_fmtext_colorize(owl_fmtext *f, int color) {
     99void owl_fmtext_colorize(owl_fmtext *f, int color)
     100{
    89101  /* everywhere the color is OWL_COLOR_DEFAULT, change it to be 'color' */
    90102  int i, j;
     
    97109
    98110
    99 void owl_fmtext_append_ztext(owl_fmtext *f, char *text) {
     111void owl_fmtext_append_ztext(owl_fmtext *f, char *text)
     112{
    100113  int stacksize, curattrs, curcolor;
    101114  char *ptr, *txtptr, *buff, *tmpptr;
     
    216229      } else {
    217230        /* if we didn't understand it, we'll print it.  This is different from zwgc
    218            but zwgc seems to be smarter about some screw cases than I am */
     231         * but zwgc seems to be smarter about some screw cases than I am
     232         */
    219233        owl_fmtext_append_attr(f, "@", curattrs, curcolor);
    220234        txtptr++;
     
    282296}
    283297
    284 void owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) {
     298/* This is used internally to fmtext.  Use owl_fmtext_append_fmtext()
     299 * (no initial underscore) externally */
     300void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop)
     301{
    285302  int newlen, i;
    286303
     
    299316}
    300317
    301 void owl_fmtext_append_spaces(owl_fmtext *f, int nspaces) {
     318void owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in)
     319{
     320  _owl_fmtext_append_fmtext(f, in, 0, in->textlen);
     321
     322}
     323
     324void owl_fmtext_append_spaces(owl_fmtext *f, int nspaces)
     325{
    302326  int i;
    303327  for (i=0; i<nspaces; i++) {
     
    310334 * If format_fn is specified, passes it the list element value
    311335 * and it will return a string which this needs to free. */
    312 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*)) {
     336void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*))
     337{
    313338  int i, size;
    314339  void *elem;
     
    335360
    336361/* caller is responsible for freeing */
    337 char *owl_fmtext_print_plain(owl_fmtext *f) {
     362char *owl_fmtext_print_plain(owl_fmtext *f)
     363{
    338364  return owl_strdup(f->textbuff);
    339365}
    340366
    341367
    342 void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w) {
     368void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w)
     369{
    343370  char *tmpbuff;
    344371  int position, trans1, trans2, len, lastsame;
     
    395422
    396423
    397 int owl_fmtext_truncate_lines(owl_fmtext *in, int aline, int lines, owl_fmtext *out) {
     424int owl_fmtext_truncate_lines(owl_fmtext *in, int aline, int lines, owl_fmtext *out)
     425{
    398426  /* start with line aline (where the first line is 0) and print
    399427   *  'lines' lines
     
    420448    offset=ptr1-in->textbuff;
    421449    if (!ptr2) {
    422       owl_fmtext_append_fmtext(out, in, offset, in->textlen-1);
     450      _owl_fmtext_append_fmtext(out, in, offset, in->textlen-1);
    423451      return(-1);
    424452    }
    425     owl_fmtext_append_fmtext(out, in, offset, (ptr2-ptr1)+offset);
     453    _owl_fmtext_append_fmtext(out, in, offset, (ptr2-ptr1)+offset);
    426454    ptr1=ptr2+1;
    427455  }
     
    430458
    431459
    432 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out) {
     460void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out)
     461{
    433462  char *ptr1, *ptr2, *last;
    434463  int len, offset;
     
    468497
    469498    offset=ptr1-in->textbuff;
    470     owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len);
     499    _owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len);
    471500
    472501    ptr1=ptr2+1;
     
    475504
    476505
    477 int owl_fmtext_num_lines(owl_fmtext *f) {
     506int owl_fmtext_num_lines(owl_fmtext *f)
     507{
    478508  int lines, i;
    479509
     
    492522
    493523
    494 char *owl_fmtext_get_text(owl_fmtext *f) {
     524char *owl_fmtext_get_text(owl_fmtext *f)
     525{
    495526  return(f->textbuff);
    496527}
    497528
    498 void owl_fmtext_set_char(owl_fmtext *f, int index, int ch) {
     529void owl_fmtext_set_char(owl_fmtext *f, int index, int ch)
     530{
    499531  /* set the charater at 'index' to be 'char'.  If index is out of
    500532   * bounds don't do anything */
     
    503535}
    504536
    505 void owl_fmtext_free(owl_fmtext *f) {
     537void owl_fmtext_free(owl_fmtext *f)
     538{
    506539  if (f->textbuff) owl_free(f->textbuff);
    507540  if (f->fmbuff) owl_free(f->fmbuff);
     
    510543
    511544
    512 void owl_fmtext_copy(owl_fmtext *dst, owl_fmtext *src) {
     545void owl_fmtext_copy(owl_fmtext *dst, owl_fmtext *src)
     546{
    513547  dst->textlen=src->textlen;
    514548  dst->textbuff=owl_malloc(src->textlen+5);
     
    521555
    522556
    523 int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string) {
    524   /* highlight all instance of "string".  Return the number of
    525    * instances found.  This is case insensitive. */
     557/* highlight all instance of "string".  Return the number of
     558 * instances found.  This is case insensitive.
     559 */
     560int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string)
     561{
    526562
    527563  int found, len;
     
    545581}
    546582
    547 int owl_fmtext_search(owl_fmtext *f, char *string) {
    548   /* return 1 if the string is found, 0 if not.  This is case
    549    *  insensitive */
     583/* return 1 if the string is found, 0 if not.  This is case
     584 *  insensitive
     585 */
     586int owl_fmtext_search(owl_fmtext *f, char *string)
     587{
    550588
    551589  if (stristr(f->textbuff, string)) return(1);
Note: See TracChangeset for help on using the changeset viewer.