Write correct length to terminal for unflash sequences

Introduce a wrapper for fwrite() of a full string to the current_ftarget.
This commit is contained in:
Kevin Easton
2017-06-09 00:42:57 +10:00
parent 917a04ce66
commit 4ae2c5ebdd
2 changed files with 15 additions and 7 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2.2] [Changes 1.2.2]
* Write correct length to terminal for unflash sequences. (caf)
* Update source file dependencies in Makefile.in. (caf) * Update source file dependencies in Makefile.in. (caf)
* Remove unused opendir.c. (caf) * Remove unused opendir.c. (caf)

View File

@@ -44,6 +44,12 @@ extern LastMsg last_servermsg[];
char three_stars[4] = "***"; char three_stars[4] = "***";
/* Write a string to the current target */
static size_t writestr(const char *s)
{
return fwrite(s, strlen(s), 1, current_ftarget);
}
/* unflash: sends a ^[c to the screen */ /* unflash: sends a ^[c to the screen */
/* Must be defined to be useful, cause some vt100s really *do* reset when /* Must be defined to be useful, cause some vt100s really *do* reset when
sent this command. >;-) */ sent this command. >;-) */
@@ -51,19 +57,19 @@ char three_stars[4] = "***";
/* functions which switch the character set on the console */ /* functions which switch the character set on the console */
/* ibmpc is not available on the xterm */ /* ibmpc is not available on the xterm */
void charset_ibmpc (void) void charset_ibmpc(void)
{ {
fwrite("\033(U", 3, 1, current_ftarget); /* switch to IBM code page 437 */ writestr("\033(U"); /* switch to IBM code page 437 */
} }
void charset_lat1 (void) void charset_lat1(void)
{ {
fwrite("\033(B", 3, 1, current_ftarget); /* switch to Latin-1 (ISO 8859-1) */ writestr("\033(B"); /* switch to Latin-1 (ISO 8859-1) */
} }
void charset_cst(void) void charset_cst(void)
{ {
fwrite("\033(K", 3, 1, current_ftarget); /* switch too user-defined */ writestr("\033(K"); /* switch to user-defined */
} }
/* currently not used. */ /* currently not used. */
@@ -75,9 +81,9 @@ void unflash (void)
#if !defined(WINNT) && !defined(__EMX__) #if !defined(WINNT) && !defined(__EMX__)
#if defined(HARD_UNFLASH) && !defined(CHARSET_CUSTOM) #if defined(HARD_UNFLASH) && !defined(CHARSET_CUSTOM)
fwrite("\033c", 5, 1, current_ftarget); /* hard reset */ writestr("\033c"); /* hard reset */
#else #else
fwrite("\033)0", 6, 1, current_ftarget); /* soft reset */ writestr("\033)0"); /* soft reset */
#endif #endif
#if defined(LATIN1) #if defined(LATIN1)