From 5bc259e388ae957ae16cecb6ca3e895ec681d85b Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 7 Jun 2015 05:23:31 +0200
Subject: degesch: sort modes on change
---
degesch.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/degesch.c b/degesch.c
index 790ee7b..e01da85 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4000,6 +4000,12 @@ mode_processor_run (struct mode_processor *self,
}
}
+static int
+mode_char_cmp (const void *a, const void *b)
+{
+ return *(const char *) a - *(const char *) b;
+}
+
static void
mode_processor_toggle (struct mode_processor *self, struct str *modes)
{
@@ -4010,7 +4016,7 @@ mode_processor_toggle (struct mode_processor *self, struct str *modes)
if (self->adding)
{
str_append_c (modes, self->mode_char);
- // TODO: sort the modes
+ qsort (modes->str, modes->len, 1, mode_char_cmp);
}
else
str_remove_slice (modes, pos - modes->str, 1);
--
cgit v1.2.3-70-g09d2