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

Function do_control

outdated/sys/mac/mactty.c:803–846  ·  view source on GitHub ↗

* Do control character */

Source from the content-addressed store, hash-verified

801 * Do control character
802 */
803static void
804do_control(tty_record *record, short character)
805{
806 int recurse = 0;
807
808 /*
809 * Check recursion because nl_add_cr and cr_add_nl may both be set and
810 * invoke each other
811 */
812 do {
813 switch (character) {
814 case CHAR_CR:
815 record->x_curs = 0;
816 if (!recurse
817 && (record->attribute[TTY_ATTRIB_CURSOR] & TA_CR_ADD_NL)) {
818 recurse = 1;
819 } else {
820 recurse = 0;
821 break;
822 } /* FALL-THROUGH: if CR-LF, don't bother with loop */
823 case CHAR_LF:
824 record->y_curs++;
825 if (record->y_curs >= record->y_size) {
826 scroll_tty(record->its_window, 0,
827 1 + record->y_curs - record->y_size);
828 }
829 if (!recurse
830 && (record->attribute[TTY_ATTRIB_CURSOR] & TA_NL_ADD_CR)) {
831 character = CHAR_CR;
832 recurse = 1;
833 } else
834 recurse = 0;
835 break;
836 case CHAR_BELL:
837 tty_nhbell();
838 break;
839 case CHAR_BS:
840 if (record->x_curs > 0)
841 record->x_curs--;
842 default:
843 break;
844 }
845 } while (recurse);
846}
847
848/*
849 * Add a single character. It is drawn directly if the correct flag is set,

Callers 2

add_tty_charFunction · 0.85
add_tty_stringFunction · 0.85

Calls 2

scroll_ttyFunction · 0.85
tty_nhbellFunction · 0.70

Tested by

no test coverage detected