unicode: introduce kmscon_utf8_mach_reset()
authorDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 29 May 2012 09:13:49 +0000 (11:13 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Tue, 29 May 2012 09:13:49 +0000 (11:13 +0200)
Sometimes we need to reset the UTF8 state-machine, for instance when
resetting the VTE. This function simply resets the internal state to
KMSCON_UTF8_START so we start all over on the next input character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
src/unicode.c
src/unicode.h

index d9a0952..4a39332 100644 (file)
@@ -421,3 +421,11 @@ uint32_t kmscon_utf8_mach_get(struct kmscon_utf8_mach *mach)
 
        return mach->ch;
 }
+
+void kmscon_utf8_mach_reset(struct kmscon_utf8_mach *mach)
+{
+       if (!mach)
+               return;
+
+       mach->state = KMSCON_UTF8_START;
+}
index f6d0e15..83610af 100644 (file)
@@ -81,5 +81,6 @@ void kmscon_utf8_mach_free(struct kmscon_utf8_mach *mach);
 
 int kmscon_utf8_mach_feed(struct kmscon_utf8_mach *mach, char c);
 uint32_t kmscon_utf8_mach_get(struct kmscon_utf8_mach *mach);
+void kmscon_utf8_mach_reset(struct kmscon_utf8_mach *mach);
 
 #endif /* KMSCON_UNICODE_H */