aboutsummaryrefslogtreecommitdiffstats
path: root/bwx_tty.c
blob: 08607ab037a479a8bf914182ceb21410cfce0ede (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/***************************************************************
  
        bwx_tty.c       TTY front-end
                        for Bywater BASIC Interpreter
  
                        Copyright (c) 1993, Ted A. Campbell
                        Bywater Software
  
                        email: tcamp@delphi.com
  
        Copyright and Permissions Information:
  
        All U.S. and international rights are claimed by the author,
        Ted A. Campbell.
  
   This software is released under the terms of the GNU General
   Public License (GPL), which is distributed with this software
   in the file "COPYING".  The GPL specifies the terms under
   which users may copy and use the software in this distribution.
  
   A separate license is available for commercial distribution,
   for information on which you should contact the author.
  
***************************************************************/

/*---------------------------------------------------------------*/
/* NOTE: Modifications marked "JBV" were made by Jon B. Volkoff, */
/* 11/1995 (eidetics@cerf.net).                                  */
/*                                                               */
/* Those additionally marked with "DD" were at the suggestion of */
/* Dale DePriest (daled@cadence.com).                            */
/*                                                               */
/* Version 3.00 by Howard Wulf, AF5NE                            */
/*                                                               */
/* Version 3.10 by Howard Wulf, AF5NE                            */
/*                                                               */
/* Version 3.20 by Howard Wulf, AF5NE                            */
/*                                                               */
/*---------------------------------------------------------------*/



#include "bwbasic.h"


extern void
bwx_LOCATE (int Row, int Col)
{
  /* position the cursor to Row and Col */
  /* Row is 1 based, 1..24 */
  /* Col is 1 based, 1..80 */
  assert (My != NULL);
  assert (My->SYSOUT != NULL);
  assert (My->SYSOUT->cfp != NULL);


  if (Row < 1 || Col < 1)
  {
    WARN_ILLEGAL_FUNCTION_CALL;
    return;
  }
  switch (My->OptionTerminalType)
  {
  case C_OPTION_TERMINAL_NONE:
    break;
  case C_OPTION_TERMINAL_ADM:
    fprintf (My->SYSOUT->cfp, "%c=%c%c", 27, Row + 32, Col + 32);
    break;
  case C_OPTION_TERMINAL_ANSI:
    fprintf (My->SYSOUT->cfp, "%c[%d;%dH", 27, Row, Col);
    break;
  default:
    WARN_ADVANCED_FEATURE;
    break;
  }
  fflush (My->SYSOUT->cfp);
  My->SYSOUT->row = Row;
  My->SYSOUT->col = Col;
}

extern void
bwx_CLS (void)
{
  /* clear screen */
  assert (My != NULL);
  assert (My->SYSOUT != NULL);
  assert (My->SYSOUT->cfp != NULL);
  switch (My->OptionTerminalType)
  {
  case C_OPTION_TERMINAL_NONE:
    break;
  case C_OPTION_TERMINAL_ADM:
    fprintf (My->SYSOUT->cfp, "%c", 26);
    break;
  case C_OPTION_TERMINAL_ANSI:
    fprintf (My->SYSOUT->cfp, "%c[2J", 27);
    break;
  default:
    WARN_ADVANCED_FEATURE;
    break;
  }
  bwx_LOCATE (1, 1);
}

extern void
bwx_COLOR (int Fore, int Back)
{
  /* set foreground and background color */
  /* Fore is 0 based, 0..15 */
  /* Back is 0 based, 0..15 */
  assert (My != NULL);
  assert (My->SYSOUT != NULL);
  assert (My->SYSOUT->cfp != NULL);
  if (Fore < 0 || Back < 0)
  {
    WARN_ILLEGAL_FUNCTION_CALL;
    return;
  }
  switch (My->OptionTerminalType)
  {
  case C_OPTION_TERMINAL_NONE:
    break;
  case C_OPTION_TERMINAL_ADM:
    break;
  case C_OPTION_TERMINAL_ANSI:
    fprintf (My->SYSOUT->cfp, "%c[%d;%dm", 27, 30 + Fore, 40 + Back);
    break;
  default:
    WARN_ADVANCED_FEATURE;
    break;
  }
  fflush (My->SYSOUT->cfp);
}



/* EOF */
Un proyecto texto-plano.xyz