kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=8fcc2be58a56bc33ad4e0cd44ce1a0c196245f32

commit 8fcc2be58a56bc33ad4e0cd44ce1a0c196245f32
Author: Kim Woelders <k...@woelders.dk>
Date:   Tue Feb 6 16:03:03 2018 +0100

    Sort IPC help in columns instead of rows
---
 src/ipc.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/ipc.c b/src/ipc.c
index f164614c..ba345789 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2004-2015 Kim Woelders
+ * Copyright (C) 2004-2018 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -1821,7 +1821,7 @@ ipccmp(const void *p1, const void *p2)
 static void
 IPC_Help(const char *params)
 {
-   int                 i, num;
+   int                 i, j, k, num, nr;
    const IpcItem     **lst, *ipc;
    const char         *nick;
 
@@ -1837,16 +1837,20 @@ IPC_Help(const char *params)
 
        qsort(lst, num, sizeof(IpcItem *), ipccmp);
 
-       for (i = 0; i < num; i++)
+       nr = (num + 2) / 3;
+       for (i = 0; i < nr; i++)
          {
-            ipc = lst[i];
-            nick = (ipc->nick) ? ipc->nick : "";
-            IpcPrintf("  %-16s %-4s ", ipc->name, nick);
-            if ((i % 3) == 2)
-               IpcPrintf("\n");
+            for (j = 0; j < 3; j++)
+              {
+                 k = i + j * nr;
+                 if (k >= num)
+                    break;
+                 ipc = lst[k];
+                 nick = (ipc->nick) ? ipc->nick : "";
+                 IpcPrintf("  %-14s %-10s", ipc->name, nick);
+              }
+            IpcPrintf("\n");
          }
-       if (i % 3)
-          IpcPrintf("\n");
      }
    else if (!strcmp(params, "all"))
      {

-- 


Reply via email to