GETWBUF(3R)

NAME
getwbuf, putwbuf, Wbufsize - access the 630 MTG default terminal emulator buffer

SYNOPSIS
int getwbuf (buf, size)

int putwbuf (buf, size)

char *buf;
int size;

int Wbufsize;

DESCRIPTION
These functions give access to the global text buffer used by the 630 MTG default terminal emulator to hold the last cut, sent or saved text. They offer the ability for cut-and-paste communication between the default terminal emulator and user's applications.

The getwbuf function reads from the global text buffer. Up to size bytes are copied into the buffer pointed to by buf. The actual number of bytes copied is returned.

The putwbuf function writes from the character buffer pointed to by buf into the global text buffer. The number of bytes copied is returned. The previous content of the global text buffer is thrown away.

The global variable Wbufsize is the current number of characters in the global buffer used by getwbuf and putwbuf.

EXAMPLE
The following example is a function that takes the global text buffer and converts every 8 continuous spaces into a tab.

    tabexpand()
    {
       char buf1[120];
       char buf2[120];
       int i,j,k,space;
       k = 0;
       space = 0;
       i = getwbuf(buf1, 120);
       for(j=0; j<i; ++j)
       {
          buf2[k] = buf1[j];
          if(buf2[k] == ' ')
             space++;
          else
             space = 0;
          if(space == 8)
          {
             k -= 7;
             buf2[k] = '\t';
             space = 0;
          }
          ++k;
       }
       putwbuf(buf2, k);
    }