
(********************************************************************)
(*                                                                  *)
(*  keydescr.s7i  Descriptive text for function keys                *)
(*  Copyright (C) 2013  Thomas Mertes                               *)
(*                                                                  *)
(*  This file is part of the Seed7 Runtime Library.                 *)
(*                                                                  *)
(*  The Seed7 Runtime Library is free software; you can             *)
(*  redistribute it and/or modify it under the terms of the GNU     *)
(*  Lesser General Public License as published by the Free Software *)
(*  Foundation; either version 2.1 of the License, or (at your      *)
(*  option) any later version.                                      *)
(*                                                                  *)
(*  The Seed7 Runtime Library 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 Lesser General Public License for more    *)
(*  details.                                                        *)
(*                                                                  *)
(*  You should have received a copy of the GNU Lesser General       *)
(*  Public License along with this program; if not, write to the    *)
(*  Free Software Foundation, Inc., 51 Franklin Street,             *)
(*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
(*                                                                  *)
(********************************************************************)


include "keybd.s7i";


const type: keyDescriptionType is hash [char] string;


const func keyDescriptionType: genKeyDescription is func
  result
    var keyDescriptionType: keyDescription is keyDescriptionType.value;
  local
    var string: description is "";
    var integer: index is 0;
  begin
    for description key index range [](
        "KEY_CTL_A", "KEY_CTL_B", "KEY_CTL_C", "KEY_CTL_D", "KEY_CTL_E",
        "KEY_CTL_F", "KEY_CTL_G", "KEY_CTL_H", "KEY_CTL_I", "KEY_CTL_J",
        "KEY_CTL_K", "KEY_CTL_L", "KEY_CTL_M", "KEY_CTL_N", "KEY_CTL_O",
        "KEY_CTL_P", "KEY_CTL_Q", "KEY_CTL_R", "KEY_CTL_S", "KEY_CTL_T",
        "KEY_CTL_U", "KEY_CTL_V", "KEY_CTL_W", "KEY_CTL_X", "KEY_CTL_Y",
        "KEY_CTL_Z", "KEY_ESC") do
      keyDescription @:= [chr(index)] description;
    end for;
    for description key index range [](
        "KEY_ALT_A", "KEY_ALT_B", "KEY_ALT_C", "KEY_ALT_D", "KEY_ALT_E",
        "KEY_ALT_F", "KEY_ALT_G", "KEY_ALT_H", "KEY_ALT_I", "KEY_ALT_J",
        "KEY_ALT_K", "KEY_ALT_L", "KEY_ALT_M", "KEY_ALT_N", "KEY_ALT_O",
        "KEY_ALT_P", "KEY_ALT_Q", "KEY_ALT_R", "KEY_ALT_S", "KEY_ALT_T",
        "KEY_ALT_U", "KEY_ALT_V", "KEY_ALT_W", "KEY_ALT_X", "KEY_ALT_Y",
        "KEY_ALT_Z") do
      keyDescription @:= [chr(pred(ord(KEY_ALT_A)) + index)] description;
    end for;
    for description key index range [](
        "KEY_ALT_0", "KEY_ALT_1", "KEY_ALT_2", "KEY_ALT_3", "KEY_ALT_4",
        "KEY_ALT_5", "KEY_ALT_6", "KEY_ALT_7", "KEY_ALT_8", "KEY_ALT_9") do
      keyDescription @:= [chr(pred(ord(KEY_ALT_0)) + index)] description;
    end for;
    for description key index range [](
        "KEY_F1", "KEY_F2", "KEY_F3", "KEY_F4", "KEY_F5",
        "KEY_F6", "KEY_F7", "KEY_F8", "KEY_F9", "KEY_F10",
        "KEY_F11", "KEY_F12") do
      keyDescription @:= [chr(pred(ord(KEY_F1)) + index)] description;
    end for;
    for description key index range [](
        "KEY_SFT_F1", "KEY_SFT_F2", "KEY_SFT_F3", "KEY_SFT_F4", "KEY_SFT_F5",
        "KEY_SFT_F6", "KEY_SFT_F7", "KEY_SFT_F8", "KEY_SFT_F9", "KEY_SFT_F10",
        "KEY_SFT_F11", "KEY_SFT_F12") do
      keyDescription @:= [chr(pred(ord(KEY_SFT_F1)) + index)] description;
    end for;
    for description key index range [](
        "KEY_CTL_F1", "KEY_CTL_F2", "KEY_CTL_F3", "KEY_CTL_F4", "KEY_CTL_F5",
        "KEY_CTL_F6", "KEY_CTL_F7", "KEY_CTL_F8", "KEY_CTL_F9", "KEY_CTL_F10",
        "KEY_CTL_F11", "KEY_CTL_F12") do
      keyDescription @:= [chr(pred(ord(KEY_CTL_F1)) + index)] description;
    end for;
    for description key index range [](
        "KEY_ALT_F1", "KEY_ALT_F2", "KEY_ALT_F3", "KEY_ALT_F4", "KEY_ALT_F5",
        "KEY_ALT_F6", "KEY_ALT_F7", "KEY_ALT_F8", "KEY_ALT_F9", "KEY_ALT_F10",
        "KEY_ALT_F11", "KEY_ALT_F12") do
      keyDescription @:= [chr(pred(ord(KEY_ALT_F1)) + index)] description;
    end for;
    for description key index range [](
        "KEY_NULCHAR", "KEY_BACKTAB") do
      keyDescription @:= [chr(pred(ord(KEY_NULCHAR)) + index)] description;
    end for;
    for description key index range [](
        "KEY_LEFT", "KEY_RIGHT", "KEY_UP", "KEY_DOWN",
        "KEY_HOME", "KEY_END", "KEY_PGUP", "KEY_PGDN",
        "KEY_INS", "KEY_DEL", "KEY_PAD_CENTER") do
      keyDescription @:= [chr(pred(ord(KEY_LEFT)) + index)] description;
    end for;
    for description key index range [](
        "KEY_CTL_LEFT", "KEY_CTL_RIGHT", "KEY_CTL_UP", "KEY_CTL_DOWN",
        "KEY_CTL_HOME", "KEY_CTL_END", "KEY_CTL_PGUP", "KEY_CTL_PGDN",
        "KEY_CTL_INS", "KEY_CTL_DEL", "KEY_SCRLUP", "KEY_SCRLDN",
        "KEY_INSLN", "KEY_DELLN", "KEY_ERASE", "KEY_CTL_NL") do
      keyDescription @:= [chr(pred(ord(KEY_CTL_LEFT)) + index)] description;
    end for;
    for description key index range [](
        "KEY_NULLCMD", "KEY_REDRAW", "KEY_NEWWINDOW",
        "KEY_MOUSE1", "KEY_MOUSE2", "KEY_MOUSE3", "KEY_MOUSE4", "KEY_MOUSE5") do
      keyDescription @:= [chr(pred(ord(KEY_NULLCMD)) + index)] description;
    end for;
    for description key index range [](
        "KEY_UNDEF", "KEY_NONE") do
      keyDescription @:= [chr(pred(ord(KEY_UNDEF)) + index)] description;
    end for;
  end func;


const keyDescriptionType: keyDescription is genKeyDescription;
