MCPcopy Create free account
hub / github.com/NetHack/NetHack / add_tty_string

Function add_tty_string

outdated/sys/mac/mactty.c:881–924  ·  view source on GitHub ↗

* Add a null-terminated string of characters */

Source from the content-addressed store, hash-verified

879 * Add a null-terminated string of characters
880 */
881short
882add_tty_string(WindowPtr window, const char *string)
883{
884 register const unsigned char *start_c;
885 register const unsigned char *the_c;
886 register unsigned char ch, is_control = 0, tty_wrap;
887 register short max_x, pos_x;
888 RECORD_EXISTS(record);
889
890 if (record->curs_state != 0)
891 curs_pos(record, record->x_curs, record->y_curs, 0);
892
893 the_c = (const unsigned char *) string;
894 max_x = record->x_size;
895 tty_wrap = (record->attribute[TTY_ATTRIB_FLAGS] & TA_WRAP_AROUND);
896 for (;;) {
897 pos_x = record->x_curs;
898 if (!tty_wrap && pos_x >= max_x)
899 break; /* Optimize away drawing across border without wrap */
900
901 start_c = the_c;
902 ch = *the_c;
903 while (pos_x < max_x) {
904 is_control =
905 (ch < sizeof(long) * 8) && ((s_control & (1 << ch)) != 0L);
906 if (is_control)
907 break;
908 the_c++;
909 ch = *the_c;
910 pos_x++;
911 }
912 do_add_string(record, (char *) start_c, the_c - start_c);
913 do_add_cursor(record, pos_x);
914 if (!ch)
915 break;
916
917 if (is_control) {
918 do_control(record, ch);
919 the_c++;
920 }
921 }
922
923 return noErr;
924}
925
926/*
927 * Read or change attributes for the tty. Note that some attribs may

Callers 2

backspFunction · 0.85
xputsFunction · 0.85

Calls 4

curs_posFunction · 0.85
do_add_stringFunction · 0.85
do_add_cursorFunction · 0.85
do_controlFunction · 0.85

Tested by

no test coverage detected