-static void try_interpret_escape_seq(RoteTerm *rt) {
- char firstchar = rt->pd->esbuf[0];
- char lastchar = rt->pd->esbuf[rt->pd->esbuf_len-1];
-
- if (!firstchar) return; /* too early to do anything */
-
- if (rt->pd->handler) {
- /* call custom handler */
- #ifdef DEBUG
- fprintf(stderr, "Calling custom handler for ES <%s>.\n", rt->pd->esbuf);
- #endif
-
- int answer = (*(rt->pd->handler))(rt, rt->pd->esbuf);
- if (answer == ROTE_HANDLERESULT_OK) {
- /* successfully handled */
- #ifdef DEBUG
- fprintf(stderr, "Handler returned OK. Done with escape sequence.\n");
- #endif
-
- cancel_escape_sequence(rt);
- return;
- }
- else if (answer == ROTE_HANDLERESULT_NOTYET) {
- /* handler might handle it when more characters are appended to
- * it. So for now we don't interpret it */
- #ifdef DEBUG
- fprintf(stderr, "Handler returned NOTYET. Waiting for more chars.\n");
- #endif
-
- return;
- }
-
- /* If we got here then answer == ROTE_HANDLERESULT_NOWAY */
- /* handler said it can't handle that escape sequence,
- * but we can still try handling it ourselves, so
- * we proceed normally. */
- #ifdef DEBUG
- fprintf(stderr, "Handler returned NOWAY. Trying our handlers.\n");
- #endif
- }
-
- /* interpret ESC-M as reverse line-feed */
- if (firstchar == 'M') {
- cursor_line_up(rt);
- cancel_escape_sequence(rt);
- return;
- }
-
- if (firstchar != '[' && firstchar != ']') {
- /* unrecognized escape sequence. Let's forget about it. */
- #ifdef DEBUG
- fprintf(stderr, "Unrecognized ES: <%s>\n", rt->pd->esbuf);
- #endif
-
- cancel_escape_sequence(rt);
- return;
- }
-
- if (firstchar == '[' && is_valid_csi_ender(lastchar)) {
- /* we have a csi escape sequence: interpret it */
- rote_es_interpret_csi(rt);
- cancel_escape_sequence(rt);
- }
- else if (firstchar == ']' && lastchar == '\a') {
- /* we have an xterm escape sequence: interpret it */
-
- /* rote_es_interpret_xterm_es(rt); -- TODO!*/
- #ifdef DEBUG
- fprintf(stderr, "Ignored XTerm ES.\n");
- #endif
- cancel_escape_sequence(rt);
- }
-
- /* if the escape sequence took up all available space and could
- * not yet be parsed, abort it */
- if (rt->pd->esbuf_len + 1 >= ESEQ_BUF_SIZE) cancel_escape_sequence(rt);
+static void try_interpret_escape_seq(RoteTerm *rt)
+{
+ char firstchar = rt->pd->esbuf[0];
+ char lastchar = rt->pd->esbuf[rt->pd->esbuf_len-1];
+
+ if (!firstchar) return; /* too early to do anything */
+
+ if (rt->pd->handler) {
+ /* call custom handler */
+#ifdef DEBUG
+ fprintf(stderr, "Calling custom handler for ES <%s>.\n", rt->pd->esbuf);
+#endif
+
+ int answer = (*(rt->pd->handler))(rt, rt->pd->esbuf);
+ if (answer == ROTE_HANDLERESULT_OK) {
+ /* successfully handled */
+#ifdef DEBUG
+ fprintf(stderr, "Handler returned OK. Done with escape sequence.\n");
+#endif
+
+ cancel_escape_sequence(rt);
+ return;
+ }
+ else if (answer == ROTE_HANDLERESULT_NOTYET) {
+ /* handler might handle it when more characters are appended to
+ * it. So for now we don't interpret it */
+#ifdef DEBUG
+ fprintf(stderr, "Handler returned NOTYET. Waiting for more chars.\n");
+#endif
+
+ return;
+ }
+
+ /* If we got here then answer == ROTE_HANDLERESULT_NOWAY */
+ /* handler said it can't handle that escape sequence,
+ * but we can still try handling it ourselves, so
+ * we proceed normally. */
+#ifdef DEBUG
+ fprintf(stderr, "Handler returned NOWAY. Trying our handlers.\n");
+#endif
+ }
+
+ /* interpret ESC-M as reverse line-feed */
+ if (firstchar == 'M') {
+ cursor_line_up(rt);
+ cancel_escape_sequence(rt);
+ return;
+ }
+
+ if (firstchar != '[' && firstchar != ']') {
+ /* unrecognized escape sequence. Let's forget about it. */
+#ifdef DEBUG
+ fprintf(stderr, "Unrecognized ES: <%s>\n", rt->pd->esbuf);
+#endif
+
+ cancel_escape_sequence(rt);
+ return;
+ }
+
+ if (firstchar == '[' && is_valid_csi_ender(lastchar)) {
+ /* we have a csi escape sequence: interpret it */
+ rote_es_interpret_csi(rt);
+ cancel_escape_sequence(rt);
+ }
+ else if (firstchar == ']' && lastchar == '\a') {
+ /* we have an xterm escape sequence: interpret it */
+
+ /* rote_es_interpret_xterm_es(rt); -- TODO!*/
+#ifdef DEBUG
+ fprintf(stderr, "Ignored XTerm ES.\n");
+#endif
+ cancel_escape_sequence(rt);
+ }
+
+ /* if the escape sequence took up all available space and could
+ * not yet be parsed, abort it */
+ if (rt->pd->esbuf_len + 1 >= ESEQ_BUF_SIZE) cancel_escape_sequence(rt);