summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2025-09-13 01:13:25 -0700
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2025-09-13 01:13:25 -0700
commit837b4d765a259bbdcb4b9c28bc6b1c5eb1548292 (patch)
tree4b3eff6f39c4e06417ec8c3032cfd6109ee2860b
parentfeefde22da62a12901ac011d5d34c6567411d6b2 (diff)
Added safe state function
-rw-r--r--escape.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/escape.h b/escape.h
index d7c54a4..a9fe743 100644
--- a/escape.h
+++ b/escape.h
@@ -34,6 +34,27 @@ enum esc_state {
//escape followed by an escape, has to be user generated
DOUBLE_ESC,
};
+
+//returns 1 if the current state is safe to insert characters after, 0 if not
+int safe_state(enum esc_state state) {
+ swtich (state) {
+ case CSI_END:
+ case ST:
+ case nF_END:
+ case C0:
+ case C1:
+ case DECSC:
+ case DECRC:
+ case DOUBLE_ESC:
+ case NORMAL:
+ return 1;
+ break;
+ default:
+ return 0;
+ break;
+ }
+}
+
//global stdin -> pty ESC state
enum esc_state in_state = NORMAL;
//global pty -> stdout ESC state