Skip to content

Commit 1fe93b7

Browse files
committed
Fixed cursor positioning. Cursor was not moved correctly after some spacing characters and was left in the
wrong position after flash and concealed attr processing.
1 parent 4dd850b commit 1fe93b7

File tree

8 files changed

+77
-51
lines changed

8 files changed

+77
-51
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ Several variations are available but the following is recommended:
4040
4141

4242
## Installation
43-
wget "https://github.com/simonlaszcz/vidtex/blob/master/releases/vidtex-1.3.0.tar.gz?raw=true" -O "vidtex-1.3.0.tar.gz"
44-
tar xvf vidtex-1.3.0.tar.gz
45-
cd vidtex-1.3.0
43+
# Substitute n.n.n with the release number
44+
wget "https://github.com/simonlaszcz/vidtex/blob/master/releases/vidtex-n.n.n.tar.gz?raw=true" -O "vidtex-n.n.n.tar.gz"
45+
tar xvf vidtex-n.n.n.tar.gz
46+
cd vidtex-n.n.n
4647
./configure
4748
sudo make install
4849

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([vidtex], [1.3.0])
1+
AC_INIT([vidtex], [1.4.0])
22
AX_WITH_CURSES
33
AC_ARG_WITH([ncursesw], AC_MSG_ERROR([ncursesw not installed]))
44
AC_CONFIG_SRCDIR([src/main.c])

releases/vidtex-1.4.0.tar.gz

123 KB
Binary file not shown.

src/decoder.c

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ static void vt_put_char(struct vt_decoder_state *state,
2020
int row, int col, wchar_t ch, struct vt_decoder_attr *attr);
2121
static void vt_init_colors(void);
2222
static void vt_trace(struct vt_decoder_state *state, char *format, ...);
23-
static void vt_cursor(struct vt_decoder_state *state);
2423
static void vt_dump(struct vt_decoder_state *state, uint8_t *buffer, int count);
24+
void vt_move_cursor(struct vt_decoder_state *state);
2525

2626
void
2727
vt_decoder_init(struct vt_decoder_state *state)
@@ -34,10 +34,11 @@ vt_decoder_init(struct vt_decoder_state *state)
3434
}
3535
}
3636

37+
curs_set(0);
3738
state->flags.is_cursor_on = false;
38-
curs_set(state->force_cursor);
3939
vt_new_frame(state);
4040
vt_get_char_code(state, true, false, 0, 2, &state->space);
41+
wrefresh(state->win);
4142
}
4243

4344
void
@@ -87,8 +88,8 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count)
8788
}
8889
}
8990

91+
vt_move_cursor(state);
9092
vt_trace(state, "BS");
91-
vt_cursor(state);
9293
continue;
9394
case 9: // h-tab
9495
++state->col;
@@ -102,13 +103,20 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count)
102103
}
103104
}
104105

106+
vt_move_cursor(state);
105107
vt_trace(state, "H-TAB");
106-
vt_cursor(state);
107108
continue;
108-
case 10: // LF (end of row)
109-
vt_next_row(state);
109+
case 10: // LF
110+
++state->row;
111+
112+
if (state->row >= MAX_ROWS) {
113+
state->row = 0;
114+
}
115+
116+
vt_reset_flags(state);
117+
vt_reset_after_flags(state);
118+
vt_move_cursor(state);
110119
vt_trace(state, "LF (new row)");
111-
vt_cursor(state);
112120
continue;
113121
case 11: // v-tab
114122
--state->row;
@@ -117,36 +125,39 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count)
117125
state->row = MAX_ROWS - 1;
118126
}
119127

128+
vt_move_cursor(state);
120129
vt_trace(state, "V-TAB");
121-
vt_cursor(state);
122130
continue;
123131
case 12:
124132
// FF (new frame/clear screen)
125133
vt_new_frame(state);
134+
vt_move_cursor(state);
126135
vt_trace(state, "FF (new frame)");
127-
vt_cursor(state);
128136
continue;
129137
case 13: // CR
130138
vt_fill_end(state);
131139
state->col = 0;
140+
vt_move_cursor(state);
132141
vt_trace(state, "CR (fill to end)");
133-
vt_cursor(state);
134142
continue;
135143
case 17: // DC1 - cursor on
144+
curs_set(1);
136145
state->flags.is_cursor_on = true;
146+
vt_move_cursor(state);
137147
vt_trace(state, "DC1 (cursor on)");
138148
continue;
139149
case 20: // DC4 - cursor off
150+
curs_set(0);
140151
state->flags.is_cursor_on = false;
141-
curs_set(state->force_cursor);
152+
vt_move_cursor(state);
142153
vt_trace(state, "DC4 (cursor off)");
143154
continue;
144155
case 30: // RS - back to origin
145156
vt_fill_end(state);
146157
state->col = 0;
147158
state->row = 0;
159+
vt_move_cursor(state);
148160
vt_trace(state, "RS (fill to end, back to origin)");
149-
vt_cursor(state);
150161
continue;
151162
}
152163

@@ -314,47 +325,78 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count)
314325
wmove(state->win, state->row, state->col);
315326
wrefresh(state->win);
316327
}
328+
}
317329

318-
// Move the cursor to the last character displayed
319-
curs_set(state->force_cursor || state->flags.is_cursor_on);
330+
void
331+
vt_move_cursor(struct vt_decoder_state *state)
332+
{
320333
wmove(state->win, state->row, state->col);
321-
wrefresh(state->win);
334+
335+
if (state->flags.is_cursor_on) {
336+
wrefresh(state->win);
337+
}
322338
}
323339

324340
void
325341
vt_decoder_toggle_flash(struct vt_decoder_state *state)
326342
{
343+
bool needs_refresh = false;
344+
int curs = curs_set(0);
327345
state->screen_flash_state = !state->screen_flash_state;
328346

347+
if (curs) {
348+
wrefresh(state->win);
349+
}
350+
329351
for (int r = 0; r < MAX_ROWS; ++r) {
330352
for (int c = 0; c < MAX_COLS; ++c) {
331353
struct vt_decoder_cell *cell = &state->cells[r][c];
332354

333355
if (cell->attr.has_flash) {
334356
vt_put_char(state, r, c, cell->character, &cell->attr);
357+
needs_refresh = true;
335358
}
336359
}
337360
}
338361

339-
wrefresh(state->win);
362+
curs_set(curs);
363+
364+
if (needs_refresh || curs) {
365+
// restore cursor position
366+
wmove(state->win, state->row, state->col);
367+
wrefresh(state->win);
368+
}
340369
}
341370

342371
void
343372
vt_decoder_toggle_reveal(struct vt_decoder_state *state)
344373
{
374+
bool needs_refresh = false;
375+
int curs = curs_set(0);
345376
state->screen_revealed_state = !state->screen_revealed_state;
346377

378+
if (curs) {
379+
wrefresh(state->win);
380+
}
381+
347382
for (int r = 0; r < MAX_ROWS; ++r) {
348383
for (int c = 0; c < MAX_COLS; ++c) {
349384
struct vt_decoder_cell *cell = &state->cells[r][c];
350385

351386
if (cell->attr.has_concealed) {
352387
vt_put_char(state, r, c, cell->character, &cell->attr);
388+
needs_refresh = true;
353389
}
354390
}
355391
}
356392

357-
wrefresh(state->win);
393+
curs_set(curs);
394+
395+
if (needs_refresh || curs) {
396+
// restore cursor position
397+
wmove(state->win, state->row, state->col);
398+
wrefresh(state->win);
399+
}
358400
}
359401

360402
static void
@@ -472,7 +514,7 @@ vt_reset_flags(struct vt_decoder_state *state)
472514
state->flags.is_mosaic_held = false;
473515
state->flags.held_mosaic = state->space;
474516
state->flags.is_double_height = false;
475-
// Leave cursor ON
517+
// leave cursor as is
476518
}
477519

478520
static void
@@ -567,8 +609,12 @@ vt_init_colors(void)
567609
static void
568610
vt_trace(struct vt_decoder_state *state, char *format, ...)
569611
{
612+
int cy = 0;
613+
int cx = 0;
614+
570615
if (state->trace_file != NULL) {
571-
fprintf(state->trace_file, "%02d,%02d\t", state->row, state->col);
616+
getyx(state->win, cy, cx);
617+
fprintf(state->trace_file, "%02d,%02d (%02d,%02d)\t", state->row, state->col, cy, cx);
572618
va_list args;
573619
va_start(args, format);
574620
vfprintf(state->trace_file, format, args);
@@ -577,15 +623,6 @@ vt_trace(struct vt_decoder_state *state, char *format, ...)
577623
}
578624
}
579625

580-
static void
581-
vt_cursor(struct vt_decoder_state *state)
582-
{
583-
if (state->force_cursor) {
584-
wmove(state->win, state->row, state->col);
585-
wrefresh(state->win);
586-
}
587-
}
588-
589626
static void
590627
vt_dump(struct vt_decoder_state *state, uint8_t *buffer, int count)
591628
{

src/decoder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ struct vt_decoder_flags
8787
bool is_mosaic_held;
8888
struct vt_decoder_char held_mosaic;
8989
bool is_double_height;
90-
// DC1 = on, DC4 = off. Set-At
9190
bool is_cursor_on;
9291
};
9392

src/main.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session)
377377
{"port", required_argument, 0, 0},
378378
{"dump", required_argument, 0, 0},
379379
{"menu", no_argument, 0, 0},
380-
{"cursor", no_argument, 0, 0},
381380
{"mono", no_argument, 0, 0},
382381
{"trace", required_argument, 0, 0},
383382
{"bold", no_argument, 0, 0},
@@ -414,12 +413,9 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session)
414413
session->show_menu = true;
415414
break;
416415
case 4:
417-
session->decoder_state.force_cursor = true;
418-
break;
419-
case 5:
420416
session->decoder_state.mono_mode = true;
421417
break;
422-
case 6:
418+
case 5:
423419
if (session->decoder_state.trace_file != NULL) {
424420
vt_usage();
425421
goto abend;
@@ -431,23 +427,23 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session)
431427
}
432428
setbuf(session->decoder_state.trace_file, NULL);
433429
break;
434-
case 7:
430+
case 6:
435431
session->decoder_state.bold_mode = true;
436432
break;
437-
case 8:
433+
case 7:
438434
session->decoder_state.map_char = &gal_map_char;
439435
break;
440-
case 9:
436+
case 8:
441437
session->load_file = fopen(optarg, "rb");
442438
if (session->load_file == NULL) {
443439
log_err();
444440
goto abend;
445441
}
446442
break;
447-
case 10:
443+
case 9:
448444
session->show_help = true;
449445
break;
450-
case 11:
446+
case 10:
451447
session->show_version = true;
452448
break;
453449
}
@@ -645,7 +641,6 @@ vt_usage(void)
645641
printf("Version: %s\n", version);
646642
printf("Usage: vidtex [options]\nOptions:\n");
647643
printf("%-16s\tOutput bold brighter colours\n", "--bold");
648-
printf("%-16s\tAlways show cursor\n", "--cursor");
649644
printf("%-16s\tDump all bytes read from host to file\n", "--dump filename");
650645
printf("%-16s\tLoad and display a saved frame\n", "--file filename");
651646
printf("%-16s\tOutput char codes for Mode7 font\n", "--galax");

src/vidtex.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ Several variations are available but the following is recommended:
3232
\-\-\fBbold
3333
Output bold text and brighter colours
3434
.TP
35-
\-\-\fBcursor
36-
Always display the cursor
37-
.TP
3835
\-\-\fBdump \fIfile
3936
Dump all bytes received from the host to \fIfile\fR
4037
.TP

src/vidtexrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#name,host,port,preamble,postamble
22
ccl4,fish.ccl4.org,23, ,42 81 81
3+
night-owl,nightowlbbs.ddns.net,6400, ,42 57 48 95 95
34
nxtel,nx.nxtel.org,23280
45
teefax,teletext.matrixnetwork.co.uk,6502, ,70 70 70
56
telstar-fast-1,glasstty.com,6502,255 253 3,42 57 48 95 95
67
telstar-fast-2,glasstty.com,6503,255 253 3,42 57 48 95 95
78
telstar-slow-1,glasstty.com,6502, ,42 57 48 95 95
89
telstar-slow-2,glasstty.com,6503, ,42 57 48 95 95
9-
prestel demo,viewdata.org.uk,6522
10-
linkline demo,viewdata.org.uk,6854
11-
#offline for a long time
12-
ringworld,rw1.m63.co.uk,23

0 commit comments

Comments
 (0)