Implement vim-like marks

Commands are 'mark' and 'goto'. Both can be used either directly,
like 'mark a' and 'goto a', or interactively (just 'mark'). For
interactive mode, i3-input must be installed and in your PATH.
This commit is contained in:
Michael Stapelberg
2009-09-20 16:54:29 +02:00
parent 6510b0e14f
commit 3ada8f326c
7 changed files with 200 additions and 32 deletions

View File

@ -24,6 +24,7 @@
#include "queue.h"
#include "layout.h"
#include "client.h"
#include "table.h"
/*
* Removes the given client from the container, either because it will be inserted into another
@ -316,3 +317,30 @@ void client_map(xcb_connection_t *conn, Client *client) {
xcb_map_window(conn, client->frame);
}
/*
* Set the given mark for this client. Used for jumping to the client
* afterwards (like m<mark> and '<mark> in vim).
*
*/
void client_mark(xcb_connection_t *conn, Client *client, const char *mark) {
if (client->mark != NULL)
free(client->mark);
client->mark = sstrdup(mark);
/* Make sure no other client has this mark set */
Client *current;
for (int c = 0; c < 10; c++)
SLIST_FOREACH(current, &(workspaces[c].focus_stack), focus_clients) {
if (current == client ||
current->mark == NULL ||
strcmp(current->mark, mark) != 0)
continue;
free(current->mark);
current->mark = NULL;
/* We can break here since there can only be one other
* client with this mark. */
break;
}
}