diff --git a/README.md b/README.md index 7b32b1f..39e2a96 100755 --- a/README.md +++ b/README.md @@ -40,9 +40,10 @@ Several variations are available but the following is recommended: ## Installation - wget "https://github.com/simonlaszcz/vidtex/blob/master/releases/vidtex-1.3.0.tar.gz?raw=true" -O "vidtex-1.3.0.tar.gz" - tar xvf vidtex-1.3.0.tar.gz - cd vidtex-1.3.0 + # Substitute n.n.n with the release number + wget "https://github.com/simonlaszcz/vidtex/blob/master/releases/vidtex-n.n.n.tar.gz?raw=true" -O "vidtex-n.n.n.tar.gz" + tar xvf vidtex-n.n.n.tar.gz + cd vidtex-n.n.n ./configure sudo make install diff --git a/configure.ac b/configure.ac index fad9c2c..d151555 100755 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([vidtex], [1.3.0]) +AC_INIT([vidtex], [1.4.0]) AX_WITH_CURSES AC_ARG_WITH([ncursesw], AC_MSG_ERROR([ncursesw not installed])) AC_CONFIG_SRCDIR([src/main.c]) diff --git a/releases/vidtex-1.4.0.tar.gz b/releases/vidtex-1.4.0.tar.gz new file mode 100644 index 0000000..18e5e8c Binary files /dev/null and b/releases/vidtex-1.4.0.tar.gz differ diff --git a/src/decoder.c b/src/decoder.c index 82e8b3c..5b76ca0 100755 --- a/src/decoder.c +++ b/src/decoder.c @@ -20,8 +20,8 @@ static void vt_put_char(struct vt_decoder_state *state, int row, int col, wchar_t ch, struct vt_decoder_attr *attr); static void vt_init_colors(void); static void vt_trace(struct vt_decoder_state *state, char *format, ...); -static void vt_cursor(struct vt_decoder_state *state); static void vt_dump(struct vt_decoder_state *state, uint8_t *buffer, int count); +void vt_move_cursor(struct vt_decoder_state *state); void vt_decoder_init(struct vt_decoder_state *state) @@ -34,10 +34,11 @@ vt_decoder_init(struct vt_decoder_state *state) } } + curs_set(0); state->flags.is_cursor_on = false; - curs_set(state->force_cursor); vt_new_frame(state); vt_get_char_code(state, true, false, 0, 2, &state->space); + wrefresh(state->win); } void @@ -87,8 +88,8 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count) } } + vt_move_cursor(state); vt_trace(state, "BS"); - vt_cursor(state); continue; case 9: // h-tab ++state->col; @@ -102,13 +103,20 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count) } } + vt_move_cursor(state); vt_trace(state, "H-TAB"); - vt_cursor(state); continue; - case 10: // LF (end of row) - vt_next_row(state); + case 10: // LF + ++state->row; + + if (state->row >= MAX_ROWS) { + state->row = 0; + } + + vt_reset_flags(state); + vt_reset_after_flags(state); + vt_move_cursor(state); vt_trace(state, "LF (new row)"); - vt_cursor(state); continue; case 11: // v-tab --state->row; @@ -117,36 +125,39 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count) state->row = MAX_ROWS - 1; } + vt_move_cursor(state); vt_trace(state, "V-TAB"); - vt_cursor(state); continue; case 12: // FF (new frame/clear screen) vt_new_frame(state); + vt_move_cursor(state); vt_trace(state, "FF (new frame)"); - vt_cursor(state); continue; case 13: // CR vt_fill_end(state); state->col = 0; + vt_move_cursor(state); vt_trace(state, "CR (fill to end)"); - vt_cursor(state); continue; case 17: // DC1 - cursor on + curs_set(1); state->flags.is_cursor_on = true; + vt_move_cursor(state); vt_trace(state, "DC1 (cursor on)"); continue; case 20: // DC4 - cursor off + curs_set(0); state->flags.is_cursor_on = false; - curs_set(state->force_cursor); + vt_move_cursor(state); vt_trace(state, "DC4 (cursor off)"); continue; case 30: // RS - back to origin vt_fill_end(state); state->col = 0; state->row = 0; + vt_move_cursor(state); vt_trace(state, "RS (fill to end, back to origin)"); - vt_cursor(state); continue; } @@ -314,47 +325,78 @@ vt_decoder_decode(struct vt_decoder_state *state, uint8_t *buffer, int count) wmove(state->win, state->row, state->col); wrefresh(state->win); } +} - // Move the cursor to the last character displayed - curs_set(state->force_cursor || state->flags.is_cursor_on); +void +vt_move_cursor(struct vt_decoder_state *state) +{ wmove(state->win, state->row, state->col); - wrefresh(state->win); + + if (state->flags.is_cursor_on) { + wrefresh(state->win); + } } void vt_decoder_toggle_flash(struct vt_decoder_state *state) { + bool needs_refresh = false; + int curs = curs_set(0); state->screen_flash_state = !state->screen_flash_state; + if (curs) { + wrefresh(state->win); + } + for (int r = 0; r < MAX_ROWS; ++r) { for (int c = 0; c < MAX_COLS; ++c) { struct vt_decoder_cell *cell = &state->cells[r][c]; if (cell->attr.has_flash) { vt_put_char(state, r, c, cell->character, &cell->attr); + needs_refresh = true; } } } - wrefresh(state->win); + curs_set(curs); + + if (needs_refresh || curs) { + // restore cursor position + wmove(state->win, state->row, state->col); + wrefresh(state->win); + } } void vt_decoder_toggle_reveal(struct vt_decoder_state *state) { + bool needs_refresh = false; + int curs = curs_set(0); state->screen_revealed_state = !state->screen_revealed_state; + if (curs) { + wrefresh(state->win); + } + for (int r = 0; r < MAX_ROWS; ++r) { for (int c = 0; c < MAX_COLS; ++c) { struct vt_decoder_cell *cell = &state->cells[r][c]; if (cell->attr.has_concealed) { vt_put_char(state, r, c, cell->character, &cell->attr); + needs_refresh = true; } } } - wrefresh(state->win); + curs_set(curs); + + if (needs_refresh || curs) { + // restore cursor position + wmove(state->win, state->row, state->col); + wrefresh(state->win); + } } static void @@ -472,7 +514,7 @@ vt_reset_flags(struct vt_decoder_state *state) state->flags.is_mosaic_held = false; state->flags.held_mosaic = state->space; state->flags.is_double_height = false; - // Leave cursor ON + // leave cursor as is } static void @@ -567,8 +609,12 @@ vt_init_colors(void) static void vt_trace(struct vt_decoder_state *state, char *format, ...) { + int cy = 0; + int cx = 0; + if (state->trace_file != NULL) { - fprintf(state->trace_file, "%02d,%02d\t", state->row, state->col); + getyx(state->win, cy, cx); + fprintf(state->trace_file, "%02d,%02d (%02d,%02d)\t", state->row, state->col, cy, cx); va_list args; va_start(args, format); vfprintf(state->trace_file, format, args); @@ -577,15 +623,6 @@ vt_trace(struct vt_decoder_state *state, char *format, ...) } } -static void -vt_cursor(struct vt_decoder_state *state) -{ - if (state->force_cursor) { - wmove(state->win, state->row, state->col); - wrefresh(state->win); - } -} - static void vt_dump(struct vt_decoder_state *state, uint8_t *buffer, int count) { diff --git a/src/decoder.h b/src/decoder.h index 9db4b20..1aba993 100755 --- a/src/decoder.h +++ b/src/decoder.h @@ -87,7 +87,6 @@ struct vt_decoder_flags bool is_mosaic_held; struct vt_decoder_char held_mosaic; bool is_double_height; - // DC1 = on, DC4 = off. Set-At bool is_cursor_on; }; diff --git a/src/main.c b/src/main.c index bd05e82..62a5b0b 100755 --- a/src/main.c +++ b/src/main.c @@ -377,7 +377,6 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session) {"port", required_argument, 0, 0}, {"dump", required_argument, 0, 0}, {"menu", no_argument, 0, 0}, - {"cursor", no_argument, 0, 0}, {"mono", no_argument, 0, 0}, {"trace", required_argument, 0, 0}, {"bold", no_argument, 0, 0}, @@ -414,12 +413,9 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session) session->show_menu = true; break; case 4: - session->decoder_state.force_cursor = true; - break; - case 5: session->decoder_state.mono_mode = true; break; - case 6: + case 5: if (session->decoder_state.trace_file != NULL) { vt_usage(); goto abend; @@ -431,23 +427,23 @@ vt_parse_options(int argc, char *argv[], struct vt_session_state *session) } setbuf(session->decoder_state.trace_file, NULL); break; - case 7: + case 6: session->decoder_state.bold_mode = true; break; - case 8: + case 7: session->decoder_state.map_char = &gal_map_char; break; - case 9: + case 8: session->load_file = fopen(optarg, "rb"); if (session->load_file == NULL) { log_err(); goto abend; } break; - case 10: + case 9: session->show_help = true; break; - case 11: + case 10: session->show_version = true; break; } @@ -645,7 +641,6 @@ vt_usage(void) printf("Version: %s\n", version); printf("Usage: vidtex [options]\nOptions:\n"); printf("%-16s\tOutput bold brighter colours\n", "--bold"); - printf("%-16s\tAlways show cursor\n", "--cursor"); printf("%-16s\tDump all bytes read from host to file\n", "--dump filename"); printf("%-16s\tLoad and display a saved frame\n", "--file filename"); printf("%-16s\tOutput char codes for Mode7 font\n", "--galax"); diff --git a/src/vidtex.1 b/src/vidtex.1 index 70de7bf..56b1a6a 100755 --- a/src/vidtex.1 +++ b/src/vidtex.1 @@ -32,9 +32,6 @@ Several variations are available but the following is recommended: \-\-\fBbold Output bold text and brighter colours .TP -\-\-\fBcursor -Always display the cursor -.TP \-\-\fBdump \fIfile Dump all bytes received from the host to \fIfile\fR .TP diff --git a/src/vidtexrc b/src/vidtexrc index e097588..d57b92c 100755 --- a/src/vidtexrc +++ b/src/vidtexrc @@ -1,12 +1,9 @@ #name,host,port,preamble,postamble ccl4,fish.ccl4.org,23, ,42 81 81 +night-owl,nightowlbbs.ddns.net,6400, ,42 57 48 95 95 nxtel,nx.nxtel.org,23280 teefax,teletext.matrixnetwork.co.uk,6502, ,70 70 70 telstar-fast-1,glasstty.com,6502,255 253 3,42 57 48 95 95 telstar-fast-2,glasstty.com,6503,255 253 3,42 57 48 95 95 telstar-slow-1,glasstty.com,6502, ,42 57 48 95 95 telstar-slow-2,glasstty.com,6503, ,42 57 48 95 95 -prestel demo,viewdata.org.uk,6522 -linkline demo,viewdata.org.uk,6854 -#offline for a long time -ringworld,rw1.m63.co.uk,23