Repository navigation
Expand file tree
/
Copy pathwrite_record.c
More file actions
45 lines (40 loc) · 1.52 KB
/
Copy pathwrite_record.c
File metadata and controls
45 lines (40 loc) · 1.52 KB
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
/************************************************************************************************
* Filename: Write_Record.c
* Author : Peter van der Woude
* Program : CatView
* Purpose : Prints a given szRecord (assumes is a szRecord i.e lightcyan on blue)
* NOTE: This function supersedes the 'professionally written' function write_string()
* which has a bug that prevents correct printing of Records over 256 characters in length.
* bug: beginning at letter 256, function begins printing at original position - over original text.
*************************************************************************************************/
#include "catview.h"
#include "tyac.h"
#include <conio.h> /* for colours */
#include <string.h> /* for strlen() */
void Write_Record(char *szRecord, int nRow) {
int nCol = 0;
int nLetterNum;
int nRecordLength = strlen(szRecord);
/* set maximum to 400 letters (5 lines) - any more would suggest a non-catalogue file */
/* and is therefore the maximum length for any szRecord in CatView */
nRecordLength = (nRecordLength <= MAX_REC_LENGTH) ? nRecordLength : MAX_REC_LENGTH;
for (nLetterNum = 0; nLetterNum < nRecordLength; nLetterNum++) {
switch (*(szRecord + nLetterNum)) {
case '\n':
nRow++;
nCol = 0;
break;
case '\t':
nCol += 4;
break;
default: /* just print the character. */
if (nCol >= 80) {
nCol = 0;
nRow++;
}
cursor(nRow, nCol);
write_char(*(szRecord + nLetterNum), LIGHTCYAN, BLUE);
nCol++;
}
}
}