about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-09-19 23:31:04 +0100
committerJames Booth <boothj5@gmail.com>2015-09-19 23:31:04 +0100
commitd7bba740919b2be154d141c1683ea43e771c4b33 (patch)
tree38d9ba5c65c5d0789b6e55c74d6610a78d224736
parenta3dccce2fa859b3030d740b609fa9e9466601cc7 (diff)
downloadprofani-tty-d7bba740919b2be154d141c1683ea43e771c4b33.tar.gz
Moved /winstidy command to /wins autotidy
-rw-r--r--src/command/command.c44
-rw-r--r--src/command/commands.c23
-rw-r--r--src/command/commands.h1
-rw-r--r--src/ui/console.c4
4 files changed, 40 insertions, 32 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 7849dde9..27c8e078 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -105,6 +105,7 @@ static char * _inpblock_autocomplete(ProfWin *window, const char * const input);
 static char * _time_autocomplete(ProfWin *window, const char * const input);
 static char * _receipts_autocomplete(ProfWin *window, const char * const input);
 static char * _help_autocomplete(ProfWin *window, const char * const input);
+static char * _wins_autocomplete(ProfWin *window, const char * const input);
 
 GHashTable *commands = NULL;
 
@@ -697,14 +698,16 @@ static struct cmd_t command_defs[] =
             CMD_TAG_UI)
         CMD_SYN(
             "/wins tidy",
+            "/wins autotidy on|off",
             "/wins prune",
             "/wins swap <source> <target>")
         CMD_DESC(
             "Manage windows. "
             "Passing no argument will list all currently active windows and information about their usage.")
         CMD_ARGS(
-            { "tidy", "Move windows so there are no gaps." },
-            { "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." },
+            { "tidy",                   "Move windows so there are no gaps." },
+            { "autotidy on|off",        "Automatically remove gaps when closing windows." },
+            { "prune",                  "Close all windows with no unread messages, and then tidy so there are no gaps." },
             { "swap <source> <target>", "Swap windows, target may be an empty position." })
         CMD_NOEXAMPLES
     },
@@ -893,19 +896,6 @@ static struct cmd_t command_defs[] =
         CMD_NOEXAMPLES
     },
 
-    { "/winstidy",
-        cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting,
-        CMD_TAGS(
-            CMD_TAG_UI)
-        CMD_SYN(
-            "/winstidy on|off")
-        CMD_DESC(
-            "Auto tidy windows, when a window is closed, windows will be moved to fill the gap.")
-        CMD_ARGS(
-            { "on|off", "Enable or disable auto window tidy." })
-        CMD_NOEXAMPLES
-    },
-
     { "/time",
         cmd_time, parse_args, 1, 3, &cons_time_setting,
         CMD_TAGS(
@@ -1872,6 +1862,7 @@ cmd_init(void)
     wins_ac = autocomplete_new();
     autocomplete_add(wins_ac, "prune");
     autocomplete_add(wins_ac, "tidy");
+    autocomplete_add(wins_ac, "autotidy");
     autocomplete_add(wins_ac, "swap");
 
     roster_ac = autocomplete_new();
@@ -2534,8 +2525,8 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
         }
     }
 
-    gchar *cmds[] = { "/prefs", "/disco", "/close", "/wins", "/subject", "/room" };
-    Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, wins_ac, subject_ac, room_ac };
+    gchar *cmds[] = { "/prefs", "/disco", "/close", "/subject", "/room" };
+    Autocomplete completers[] = { prefs_ac, disco_ac, close_ac, subject_ac, room_ac };
 
     for (i = 0; i < ARRAY_SIZE(cmds); i++) {
         result = autocomplete_param_with_ac(input, cmds[i], completers[i], TRUE);
@@ -2574,6 +2565,7 @@ _cmd_complete_parameters(ProfWin *window, const char * const input)
     g_hash_table_insert(ac_funcs, "/inpblock",      _inpblock_autocomplete);
     g_hash_table_insert(ac_funcs, "/time",          _time_autocomplete);
     g_hash_table_insert(ac_funcs, "/receipts",      _receipts_autocomplete);
+    g_hash_table_insert(ac_funcs, "/wins",          _wins_autocomplete);
 
     int len = strlen(input);
     char parsed[len+1];
@@ -3463,6 +3455,24 @@ _statuses_autocomplete(ProfWin *window, const char * const input)
 }
 
 static char *
+_wins_autocomplete(ProfWin *window, const char * const input)
+{
+    char *result = NULL;
+
+    result = autocomplete_param_with_func(input, "/wins autotidy", prefs_autocomplete_boolean_choice);
+    if (result) {
+        return result;
+    }
+
+    result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE);
+    if (result) {
+        return result;
+    }
+
+    return NULL;
+}
+
+static char *
 _receipts_autocomplete(ProfWin *window, const char * const input)
 {
     char *result = NULL;
diff --git a/src/command/commands.c b/src/command/commands.c
index e3374ddd..61c0373b 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -747,6 +747,17 @@ cmd_wins(ProfWin *window, const char * const command, gchar **args)
                 cons_show("Same source and target window supplied.");
             }
         }
+    } else if (strcmp(args[0], "autotidy") == 0) {
+        if (g_strcmp0(args[1], "on") == 0) {
+            cons_show("Window autotidy enabled");
+            prefs_set_boolean(PREF_WINS_AUTO_TIDY, TRUE);
+            ui_tidy_wins();
+        } else if (g_strcmp0(args[1], "off") == 0) {
+            cons_show("Window autotidy disabled");
+            prefs_set_boolean(PREF_WINS_AUTO_TIDY, FALSE);
+        } else {
+            cons_bad_cmd_usage(command);
+        }
     } else {
         cons_bad_cmd_usage(command);
     }
@@ -755,18 +766,6 @@ cmd_wins(ProfWin *window, const char * const command, gchar **args)
 }
 
 gboolean
-cmd_winstidy(ProfWin *window, const char * const command, gchar **args)
-{
-    gboolean result = _cmd_set_boolean_preference(args[0], command, "Wins Auto Tidy", PREF_WINS_AUTO_TIDY);
-
-    if (result && g_strcmp0(args[0], "on") == 0) {
-        ui_tidy_wins();
-    }
-
-    return result;
-}
-
-gboolean
 cmd_win(ProfWin *window, const char * const command, gchar **args)
 {
     int num = atoi(args[0]);
diff --git a/src/command/commands.h b/src/command/commands.h
index c158f606..89f923ff 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -129,7 +129,6 @@ gboolean cmd_vercheck(ProfWin *window, const char * const command, gchar **args)
 gboolean cmd_who(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_win(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_wins(ProfWin *window, const char * const command, gchar **args);
-gboolean cmd_winstidy(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_xa(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_alias(ProfWin *window, const char * const command, gchar **args);
 gboolean cmd_xmlconsole(ProfWin *window, const char * const command, gchar **args);
diff --git a/src/ui/console.c b/src/ui/console.c
index 2b05448b..80bfe9f5 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -923,9 +923,9 @@ void
 cons_winstidy_setting(void)
 {
     if (prefs_get_boolean(PREF_WINS_AUTO_TIDY))
-        cons_show("Window Auto Tidy (/winstidy)  : ON");
+        cons_show("Window Auto Tidy (/wins)      : ON");
     else
-        cons_show("Window Auto Tidy (/winstidy)  : OFF");
+        cons_show("Window Auto Tidy (/wins)      : OFF");
 }
 
 void
#n471'>471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734