foo-wm

(Archived) Experimental Zooming IPC-based WM
git clone http://milesalan.com/git/foo-wm
Log | Files | Refs | Mirror | README | LICENSE

commit 6f760eb40e0f090484147a090841dc3cdf7477a9
parent 5923cef8c5add34f3ecd0c0eeb44b19b3b8eefc8
Author: = <miles.sandlar@gmail.com>
Date:   Thu, 11 Oct 2012 11:21:43 -0400

'get marks' returns JSON formmated list of marks
Removal of direction to int conversion
Minor bug/typo fix

Diffstat:
Msrc/client.c | 1+
Msrc/commands.c | 25++++++++++++++++++++++++-
Msrc/util.c | 9---------
3 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/client.c b/src/client.c @@ -28,6 +28,7 @@ int main(int argc, char **argv) { } /* Close and return */ + printf("\n"); close(socketFd); return 0; } diff --git a/src/commands.c b/src/commands.c @@ -126,7 +126,30 @@ char * get(char * property) { else if (!strcmp(property, "view")) return crawlNode(viewNode, 0); else if (!strcmp(property, "focus")) - return crawlNode(focusNode, 0); + return crawlNode(focusedNode, 0); + + + char * marksResponse = malloc(1024); + if (!strcmp(property, "marks")) { + sprintf(marksResponse, "{\"marks\":["); + Mark *n = NULL; + for(n = markTail; n; n = n -> previous) { + fprintf(stderr, "%s%s%s\n", marksResponse, n == markTail ? "," : "", n -> name); + sprintf(marksResponse, + "%s%s\"%s\"", + marksResponse, + n != markTail ? "," : "", + n -> name + ); + fprintf(stderr, "After the Sprintf"); + } + fprintf(stderr, "The Marks Response is %s\n", marksResponse); + + sprintf(marksResponse, "%s]}", marksResponse); + realloc(marksResponse, bytesUntilNull(marksResponse)); + return marksResponse; + } + } diff --git a/src/util.c b/src/util.c @@ -72,15 +72,6 @@ Node * focusOrChildOf(Node * node) { else if (node -> focus) return node -> focus; else return node -> child; } - -int directionStringToInt(char * directionString) { - if (!strcmp(directionString, "left")) return LEFT; - else if (!strcmp(directionString, "up")) return UP; - else if (!strcmp(directionString, "right")) return RIGHT; - else if (!strcmp(directionString, "down")) return DOWN; - else return -1; -} - int bytesUntilNull(char * string) { int counter = 0; while (string[counter] != '\0')