added move tab
This commit is contained in:
parent
05febfb897
commit
a4040a91ff
25
surf.c
25
surf.c
|
@ -410,7 +410,27 @@ void switch_tab(Client *c, const Arg *a) {
|
|||
}
|
||||
|
||||
void move_tab(Client *c, const Arg *a) {
|
||||
g_print("move\n");
|
||||
int new_index = c->selected_tab + a->i;
|
||||
int tab_count = g_list_length(c->tabs);
|
||||
|
||||
// Ensure the new index is within valid bounds
|
||||
if (new_index >= 0 && new_index < tab_count) {
|
||||
// Get the nodes for the current and the target positions
|
||||
GList *current_node = g_list_nth(c->tabs, c->selected_tab);
|
||||
GList *target_node = g_list_nth(c->tabs, new_index);
|
||||
|
||||
// Swap the data of the two nodes
|
||||
if (current_node != NULL && target_node != NULL) {
|
||||
gpointer temp_data = current_node->data;
|
||||
current_node->data = target_node->data;
|
||||
target_node->data = temp_data;
|
||||
}
|
||||
|
||||
// Update the selected tab index
|
||||
c->selected_tab = new_index;
|
||||
}
|
||||
|
||||
update_tab_bar(c);
|
||||
}
|
||||
|
||||
void update_tab_uri(Client *c) {
|
||||
|
@ -444,6 +464,9 @@ void new_tab(Client *c, const Arg *a) {
|
|||
add_tab(c, "about:blank");
|
||||
c->selected_tab = g_list_length(c->tabs) - 1;
|
||||
update_tab_bar(c);
|
||||
reload_tab(c);
|
||||
Arg arg = SETPROP("_SURF_URI", "_SURF_GO", "PROMPT_GO");
|
||||
spawn(c, &arg);
|
||||
}
|
||||
|
||||
void fill_tab_bar(Client *c) {
|
||||
|
|
Loading…
Reference in a new issue