/* * confwin.c * * Copyright (C) 2012 - 2019 James Booth * * This file is part of Profanity. * * Profanity is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Profanity is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Profanity. If not, see . * * In addition, as a special exception, the copyright holders give permission to * link the code of portions of this program with the OpenSSL library under * certain conditions as described in each individual source file, and * distribute linked combinations including the two. * * You must obey the GNU General Public License in all respects for all of the * code used other than OpenSSL. If you modify file(s) with this exception, you * may extend this exception to your version of the file(s), but you are not * obligated to do so. If you do not wish to do so, delete this exception * statement from your version. If you delete this exception statement from all * source files in the program, then also delete it here. * */ #include #include #include "ui/ui.h" #include "ui/window.h" #include "ui/win_types.h" #include "ui/window_list.h" static void _confwin_form_field(ProfWin *window, char *tag, FormField *field); void confwin_show_form(ProfConfWin *confwin) { ProfWin *window = (ProfWin*) confwin; if (confwin->form->title) { win_print(window, THEME_DEFAULT, '-', "Form title: "); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); } else { win_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid); } win_println(window, THEME_DEFAULT, '-', ""); confwin_form_help(confwin); GSList *fields = confwin->form->fields; GSList *curr_field = fields; while (curr_field) { FormField *field = curr_field->data; if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { char *value = field->values->data; win_println(window, THEME_DEFAULT, '-', "%s", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); _confwin_form_field(window, tag, field); } curr_field = g_slist_next(curr_field); } } void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) { assert(confwin != NULL); FormField *field = form_get_field_by_tag(form, tag); ProfWin *window = (ProfWin*)confwin; _confwin_form_field(window, tag, field); win_println(window, THEME_DEFAULT, '-', ""); } void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) { assert(confwin != NULL); ProfWin *window = (ProfWin*)confwin; ui_focus_win(window); confwin_show_form(confwin); win_println(window, THEME_DEFAULT, '-', ""); if (confwin->submit != NULL) { win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes."); } win_println(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes."); win_println(window, THEME_DEFAULT, '-', "See '/form help' for more information."); win_println(window, THEME_DEFAULT, '-', ""); } void confwin_field_help(ProfConfWin *confwin, char *tag) { assert(confwin != NULL); ProfWin *window = (ProfWin*) confwin; FormField *field = form_get_field_by_tag(confwin->form, tag); if (f
# To check our support for consoles in scenarios, rewrite tests from
# scenario_console.mu
# Tests for console interface.

scenario read-key-in-mu [
  assume-console [
    type [abc]
  ]
  run [
    1:char, 2:bool <- read-key console
    3:char, 4:bool <- read-key console
    5:char, 6:bool <- read-key console
    7:char, 8:bool <-