lines.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. Skins engine.
  3. Work with line draving chars.
  4. Copyright (C) 2009 The Free Software Foundation, Inc.
  5. Written by:
  6. Slava Zanko <slavazanko@gmail.com>, 2009.
  7. This file is part of the Midnight Commander.
  8. The Midnight Commander is free software; you can redistribute it
  9. and/or modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation; either version 2 of the
  11. License, or (at your option) any later version.
  12. The Midnight Commander is distributed in the hope that it will be
  13. useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  14. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. MA 02110-1301, USA.
  20. */
  21. #include <config.h>
  22. #include <stdlib.h>
  23. #include "internal.h"
  24. #include "lib/tty/tty.h"
  25. #include "src/args.h"
  26. /*** global variables ****************************************************************************/
  27. /*** file scope macro definitions ****************************************************************/
  28. /*** file scope type declarations ****************************************************************/
  29. /*** file scope variables ************************************************************************/
  30. /*** file scope functions ************************************************************************/
  31. static int
  32. mc_skin_lines_load_frm (mc_skin_t * mc_skin, const char *name)
  33. {
  34. int ret;
  35. char *frm_val = NULL;
  36. frm_val = mc_config_get_string_raw (mc_skin->config, "Lines", name, " ");
  37. ret = mc_tty_normalize_lines_char (frm_val);
  38. g_free (frm_val);
  39. switch (ret) {
  40. case 0x80:
  41. ret = ACS_HLINE;
  42. break;
  43. case 0x81:
  44. ret = ACS_VLINE;
  45. break;
  46. case 0x82:
  47. ret = ACS_ULCORNER;
  48. break;
  49. case 0x83:
  50. ret = ACS_URCORNER;
  51. break;
  52. case 0x84:
  53. ret = ACS_LLCORNER;
  54. break;
  55. case 0x85:
  56. ret = ACS_LRCORNER;
  57. break;
  58. case 0x86:
  59. ret = ACS_LTEE;
  60. break;
  61. case 0x87:
  62. ret = ACS_RTEE;
  63. break;
  64. case 0x8a:
  65. ret = ACS_PLUS;
  66. break;
  67. default:
  68. break;
  69. }
  70. return ret;
  71. }
  72. /* --------------------------------------------------------------------------------------------- */
  73. /*** public functions ****************************************************************************/
  74. /* --------------------------------------------------------------------------------------------- */
  75. void
  76. mc_skin_lines_parse_ini_file (mc_skin_t * mc_skin)
  77. {
  78. if (mc_args__slow_terminal) {
  79. mc_skin_hardcoded_space_lines (mc_skin);
  80. } else if (mc_args__ugly_line_drawing) {
  81. mc_skin_hardcoded_ugly_lines (mc_skin);
  82. }
  83. mc_tty_ugly_frm[MC_TTY_FRM_horiz] = mc_skin_lines_load_frm (mc_skin, "horiz");
  84. mc_tty_ugly_frm[MC_TTY_FRM_vert] = mc_skin_lines_load_frm (mc_skin, "vert");
  85. mc_tty_ugly_frm[MC_TTY_FRM_lefttop] = mc_skin_lines_load_frm (mc_skin, "lefttop");
  86. mc_tty_ugly_frm[MC_TTY_FRM_righttop] = mc_skin_lines_load_frm (mc_skin, "righttop");
  87. mc_tty_ugly_frm[MC_TTY_FRM_leftbottom] = mc_skin_lines_load_frm (mc_skin, "leftbottom");
  88. mc_tty_ugly_frm[MC_TTY_FRM_rightbottom] = mc_skin_lines_load_frm (mc_skin, "rightbottom");
  89. mc_tty_ugly_frm[MC_TTY_FRM_thinvert] = mc_skin_lines_load_frm (mc_skin, "thinvert");
  90. mc_tty_ugly_frm[MC_TTY_FRM_thinhoriz] = mc_skin_lines_load_frm (mc_skin, "thinhoriz");
  91. mc_tty_ugly_frm[MC_TTY_FRM_rightmiddle] = mc_skin_lines_load_frm (mc_skin, "rightmiddle");
  92. mc_tty_ugly_frm[MC_TTY_FRM_centertop] = mc_skin_lines_load_frm (mc_skin, "centertop");
  93. mc_tty_ugly_frm[MC_TTY_FRM_centerbottom] = mc_skin_lines_load_frm (mc_skin, "centerbottom");
  94. mc_tty_ugly_frm[MC_TTY_FRM_centermiddle] = mc_skin_lines_load_frm (mc_skin, "centermiddle");
  95. mc_tty_ugly_frm[MC_TTY_FRM_leftmiddle] = mc_skin_lines_load_frm (mc_skin, "leftmiddle");
  96. }
  97. /* --------------------------------------------------------------------------------------------- */