home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
disks
/
disk427.lzh
/
STV
/
source
/
text.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-09
|
2KB
|
98 lines
/*********************************
* TEXT 01/02/91
* Source file for STV
* © Copyright 1990 Timm Martin
* All Rights Reserved Worldwide
**********************************/
#include <exec/types.h>
#include <functions.h>
#include <intuition/intuition.h>
#include <string.h>
#include "func.h"
#include "main.h"
/****************
* TEXT DISPLAY
*****************/
/*
This procedure displays all text lines in the window.
*/
void text_display( void )
{
int bottom;
int line;
long top;
if (stats.Top + current_file.Lines < stats.Rows)
bottom = current_file.Lines - stats.Top;
else
bottom = stats.Rows;
for (line = 0, top = stats.TopEdge; line < bottom;
line++, top += stats.TextHeight)
{
SetAPen( rp, BLUE );
RectFill( rp, (long)stats.LeftEdge, top,
(long)stats.RightEdge, top + stats.TextHeight - 1 );
text_line( line );
}
}
/*************
* TEXT LINE
**************/
/*
This procedure displays the specified line in the window (the 'line' is
relative position in the window, not the file). This procedure assumes the
text line has already been cleared, either by ScrollRaster() or by RectFill().
*/
void text_line( int line )
{
int length; /* length of string to be printed */
REG char *s; /* for stepping thru line */
s = current_file.Table[stats.Top + line];
if ((length = strlen( s )) > stats.Cols)
length = stats.Cols;
SetAPen( rp, (long)arguments.TextColor );
Move( rp, (long)stats.LeftEdge,
(long)(stats.TopEdge + stats.Baseline + line * stats.TextHeight) );
Text( rp, s, (long)length );
}
/***************
* TEXT STRING
****************/
/*
This procedure displays a specified text string in the window. The 'line' is
the relative position in the window, not the file).
*/
void text_string( int line, int start, int length )
/*
line ..... relative position in window
start .... starting char position in line
length ... number of chars to display
*/
{
int diff; /* how far string goes past end */
/* only do this if not off the end */
if (start < stats.Cols)
{
if ((diff = start + length - stats.Cols) > 0)
length -= diff;
SetAPen( rp, RED );
Move( rp, (long)(stats.LeftEdge + start * stats.TextWidth),
(long)(stats.TopEdge + stats.Baseline + line * stats.TextHeight) );
Text( rp, current_file.Table[stats.Top + line] + start, (long)length );
}
}