home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
word
/
text
/
024
/
hwind.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-04
|
15KB
|
521 lines
/******************* start of original comments ********************/
/*
* Written by Douglas Thomson (1989/1990)
*
* This source code is released into the public domain.
*/
/*
* Name: hardware independent screen IO module
* Purpose: This file contains the code to interface the rest of the
* editor to the display and input hardware.
* File: hwind.c
* Author: Douglas Thomson
* System: this file is intended to be system-independent
* Date: October 2, 1989
* Notes: This is the only module that is allowed to call the hardware
* dependent display IO library.
* Typically, functions here check whether any action is
* necessary (for example, the cursor may already happen to be
* in the required position), call hardware dependent functions
* to achieve the required effect, and finally update status
* information about the current state of the terminal display.
* The idea behind this approach is to keep the hardware
* dependent code as small and simple as possible, thus making
* porting the code easier.
*/
/********************* end of original comments ********************/
/*
* Some routines were added to display current editor modes in the lite bar
* at the bottom of the screen. Other routines were rewritten in assembly.
* I feel the need for speed.
*
* New editor name: TDE, the Thomson-Davis Editor.
* Author: Frank Davis
* Date: June 5, 1991, version 1.0
* Date: July 29, 1991, version 1.1
* Date: October 5, 1991, version 1.2
* Date: January 20, 1992, version 1.3
* Date: February 17, 1992, version 1.4
* Date: April 1, 1992, version 1.5
* Date: June 5, 1992, version 2.0
* Date: October 31, 1992, version 2.1
* Date: April 1, 1993, version 2.2
* Date: June 5, 1993, version 3.0
*
* This modification of Douglas Thomson's code is released into the
* public domain, Frank Davis. You may distribute it freely.
*/
#include <bios.h> /* for REGS */
#include <dos.h> /* for intdos */
#include "tdestr.h"
#include "common.h"
#include "tdefunc.h"
#include "define.h"
/*
* Name: get_date
* Purpose: get system date from DOS
* Date: June 5, 1992
* Passed: year: pointer to integer to store year
* month: pointer to integer to store month
* day: pointer to integer to store day
* day_of_week: pointer to integer to store dow
* Notes: call standard DOS interrupt 0x21, function 0x2a to get the date.
*/
void get_date( int *year, int *month, int *day, int *day_of_week )
{
union REGS inregs, outregs;
inregs.h.ah = 0x2a;
intdos( &inregs, &outregs );
*year = (int)outregs.x.cx;
*month = (int)outregs.h.dh;
*day = (int)outregs.h.dl;
*day_of_week = (int)outregs.h.al;
}
/*
* Name: get_time
* Purpose: get system time from DOS
* Date: June 5, 1992
* Passed: hour: pointer to integer to store hour - system returns 24 hour
* minutes: pointer to integer to store minutes
* seconds: pointer to integer to store seconds
* hundredths: pointer to integer to store hundredths of second
* Notes: call standard DOS interrupt 0x21, function 0x2c to get the time.
*/
void get_time( int *hour, int *minutes, int *seconds, int *hundredths )
{
union REGS inregs, outregs;
inregs.h.ah = 0x2c;
intdos( &inregs, &outregs );
*hour = (int)outregs.h.ch;
*minutes = (int)outregs.h.cl;
*seconds = (int)outregs.h.dh;
*hundredths = (int)outregs.h.dl;
}
/*
* Name: show_modes
* Purpose: show current editor modes in lite bar at bottom of screen
* Date: June 5, 1991
*/
void show_modes( void )
{
char status_line[MAX_COLS+2];
memset( status_line, ' ', MAX_COLS );
status_line[MAX_COLS] = '\0';
s_output( status_line, g_display.mode_line, 0, g_display.mode_color );
s_output( "F= W=", g_display.mode_line, 1, g_display.mode_color );
s_output( "m=", g_display.mode_line, 12, g_display.mode_color );
show_window_count( g_status.window_count );
show_file_count( g_status.file_count );
show_avail_mem( );
show_tab_modes( );
show_indent_mode( );
show_sync_mode( );
show_control_z( );
show_insert_mode( );
show_search_case( );
show_wordwrap_mode( );
show_trailing( );
}
/*
* Name: show_file_count
* Purpose: show number of open files in lite bar at bottom of screen
* Passed: fc: file count - number of open files
* Date: June 5, 1991
*/
void show_file_count( int fc )
{
char status_line[MAX_COLS+2];
s_output( " ", g_display.mode_line, 3, g_display.mode_color );
s_output( itoa( fc, status_line, 10 ), g_display.mode_line, 3,
g_display.mode_color );
}
/*
* Name: show_window_count
* Purpose: show total number of windows in lite bar at bottom of screen
* Passed: wc: window count - visible and hidden.
* Date: September 13, 1991
*/
void show_window_count( int wc )
{
char status_line[MAX_COLS+2];
s_output( " ", g_display.mode_line, 8, g_display.mode_color );
s_output( itoa( wc, status_line, 10 ), g_display.mode_line, 8,
g_display.mode_color );
}
/*
* Name: show_avail_mem
* Purpose: show available free memory in lite bar at bottom of screen
* Date: June 5, 1991
*/
void show_avail_mem( void )
{
char line[MAX_COLS+2];
unsigned long avail_mem;
#if defined( __MSC__ )
unsigned paragraphs;
_dos_allocmem( 0xffff, ¶graphs );
/*
* A paragraph is 16 bytes. Convert paragraphs to bytes by shifting left
* 4 bits.
*/
avail_mem = (long)paragraphs << 4;
#else
avail_mem = farcoreleft( );
#endif
s_output( " ", g_display.mode_line, 14, g_display.mode_color );
ultoa( avail_mem, line, 10 );
s_output( line, g_display.mode_line, 14,
g_display.mode_color );
}
/*
* Name: show_tab_modes
* Purpose: show smart tab mode in lite bar at bottom of screen
* Date: October 31, 1992
*/
void show_tab_modes( void )
{
char *blank_tab = " ";
char ascii_tab[10];
s_output( tabs, g_display.mode_line, 22, g_display.mode_color );
s_output( mode.smart_tab ? smart : fixed, g_display.mode_line, 27,
g_display.mode_color );
s_output( mode.inflate_tabs ? intab : outtab, g_display.mode_line, 28,
g_display.mode_color );
s_output( blank_tab, g_display.mode_line, 29, g_display.mode_color );
s_output( itoa( mode.ptab_size, ascii_tab, 10), g_display.mode_line, 29,
g_display.mode_color );
}
/*
* Name: show_indent_mode
* Purpose: show indent mode in lite bar at bottom of screen
* Date: June 5, 1991
*/
void show_indent_mode( void )
{
s_output( mode.indent ? indent : blank, g_display.mode_line, 32,
g_display.mode_color );
}
/*
* Name: show_search_case
* Purpose: show search mode in lite bar
* Date: June 5, 1991
*/
void show_search_case( void )
{
s_output( mode.search_case == IGNORE ? ignore : match, g_display.mode_line,
40, g_display.mode_color );
}
/*
* Name: show_sync_mode
* Purpose: show sync mode in lite bar
* Date: January 15, 1992
*/
void show_sync_mode( void )
{
s_output( mode.sync ? sync_on : sync_off, g_display.mode_line, 48,
g_display.mode_color );
}
/*
* Name: show_wordwrap_mode
* Purpose: display state of word wrap mode
* Date: June 5, 1991
*/
void show_wordwrap_mode( void )
{
s_output( ww_mode[mode.word_wrap], g_display.mode_line, 54,
g_display.mode_color );
}
/*
* Name: show_trailing
* Purpose: show state of trailing flag
* Date: June 5, 1991
*/
void show_trailing( void )
{
c_output( mode.trailing ? 'T' : ' ', 66, g_display.mode_line,
g_display.mode_