home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / mxterm.zip / mxterm / tabs.c < prev    next >
C/C++ Source or Header  |  1992-10-17  |  2KB  |  107 lines

  1. /*
  2.  *    $XConsortium: tabs.c,v 1.4 91/05/06 17:12:18 gildea Exp $
  3.  */
  4.  
  5. /*
  6.  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  7.  *
  8.  *                         All Rights Reserved
  9.  *
  10.  * Permission to use, copy, modify, and distribute this software and its
  11.  * documentation for any purpose and without fee is hereby granted,
  12.  * provided that the above copyright notice appear in all copies and that
  13.  * both that copyright notice and this permission notice appear in
  14.  * supporting documentation, and that the name of Digital Equipment
  15.  * Corporation not be used in advertising or publicity pertaining to
  16.  * distribution of the software without specific, written prior permission.
  17.  *
  18.  *
  19.  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  21.  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  22.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  23.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  24.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  25.  * SOFTWARE.
  26.  */
  27.  
  28. /* tabs.c */
  29.  
  30. #include "ptyx.h"
  31.  
  32. /*
  33.  * This file presumes 32bits/word.  This is somewhat of a crock, and should
  34.  * be fixed sometime.
  35.  */
  36.  
  37. /*
  38.  * places tabstops at only every 8 columns
  39.  */
  40. TabReset(tabs)
  41. Tabs    tabs;
  42. {
  43.     register int i;
  44.  
  45.     for (i=0; i<TAB_ARRAY_SIZE; ++i)
  46.         tabs[i] = 0;
  47.  
  48.     for (i=0; i<MAX_TABS; i+=8)
  49.         TabSet(tabs, i);
  50. }    
  51.  
  52.  
  53. /*
  54.  * places a tabstop at col
  55.  */
  56. TabSet(tabs, col)
  57.     Tabs    tabs;
  58.     int        col;
  59. {
  60.     tabs[col >> 5] |= (1 << (col & 31));
  61. }
  62.  
  63. /*
  64.  * clears a tabstop at col
  65.  */
  66. TabClear(tabs, col)
  67.     Tabs    tabs;
  68.     int        col;
  69. {
  70.     tabs[col >> 5] &= ~(1 << (col & 31));
  71. }
  72.  
  73. /*
  74.  * returns the column of the next tabstop
  75.  * (or MAX_TABS - 1 if there are no more).
  76.  * A tabstop at col is ignored.
  77.  */
  78. TabNext (tabs, col)
  79.     Tabs    tabs;
  80.     int        col;
  81. {
  82.     extern XtermWidget term;
  83.     register TScreen *screen = &term->screen;
  84.  
  85.     if(screen->curses && screen->do_wrap && (term->flags & WRAPAROUND)) {
  86.         Index(screen, 1);
  87.         col = screen->cur_col = screen->do_wrap = 0;
  88.     }
  89.     for (++col; col<MAX_TABS; ++col)
  90.         if (tabs[col >> 5] & (1 << (col & 31)))
  91.             return (col);
  92.  
  93.     return (MAX_TABS - 1);
  94. }
  95.  
  96. /*
  97.  * clears all tabs
  98.  */
  99. TabZonk (tabs)
  100. Tabs    tabs;
  101. {
  102.     register int i;
  103.  
  104.     for (i=0; i<TAB_ARRAY_SIZE; ++i)
  105.         tabs[i] = 0;
  106. }
  107.