lines.c 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Skins engine.
  3. Work with line draving chars.
  4. Copyright (C) 2009-2024
  5. Free Software Foundation, Inc.
  6. Written by:
  7. Slava Zanko <slavazanko@gmail.com>, 2009.
  8. This file is part of the Midnight Commander.
  9. The Midnight Commander is free software: you can redistribute it
  10. and/or modify it under the terms of the GNU General Public License as
  11. published by the Free Software Foundation, either version 3 of the License,
  12. or (at your option) any later version.
  13. The Midnight Commander is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. GNU General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <config.h>
  21. #include <stdlib.h>
  22. #include "internal.h"
  23. #include "lib/tty/tty.h"
  24. /*** global variables ****************************************************************************/
  25. /*** file scope macro definitions ****************************************************************/
  26. /*** file scope type declarations ****************************************************************/
  27. /*** forward declarations (file scope functions) *************************************************/
  28. /*** file scope variables ************************************************************************/
  29. /* --------------------------------------------------------------------------------------------- */
  30. /*** file scope functions ************************************************************************/
  31. /* --------------------------------------------------------------------------------------------- */
  32. static int
  33. mc_skin_lines_load_frm (mc_skin_t *mc_skin, const char *name)
  34. {
  35. int ret;
  36. char *frm_val;
  37. frm_val = mc_config_get_string_raw (mc_skin->config, "Lines", name, " ");
  38. ret = mc_tty_normalize_lines_char (frm_val);
  39. g_free (frm_val);
  40. return ret;
  41. }
  42. /* --------------------------------------------------------------------------------------------- */
  43. /*** public functions ****************************************************************************/
  44. /* --------------------------------------------------------------------------------------------- */
  45. void
  46. mc_skin_lines_parse_ini_file (mc_skin_t *mc_skin)
  47. {
  48. if (mc_global.tty.slow_terminal)
  49. mc_skin_hardcoded_space_lines (mc_skin);
  50. else if (mc_global.tty.ugly_line_drawing)
  51. mc_skin_hardcoded_ugly_lines (mc_skin);
  52. /* single lines */
  53. mc_tty_frm[MC_TTY_FRM_VERT] = mc_skin_lines_load_frm (mc_skin, "vert");
  54. mc_tty_frm[MC_TTY_FRM_HORIZ] = mc_skin_lines_load_frm (mc_skin, "horiz");
  55. mc_tty_frm[MC_TTY_FRM_LEFTTOP] = mc_skin_lines_load_frm (mc_skin, "lefttop");
  56. mc_tty_frm[MC_TTY_FRM_RIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "righttop");
  57. mc_tty_frm[MC_TTY_FRM_LEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "leftbottom");
  58. mc_tty_frm[MC_TTY_FRM_RIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "rightbottom");
  59. mc_tty_frm[MC_TTY_FRM_TOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "topmiddle");
  60. mc_tty_frm[MC_TTY_FRM_BOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "bottommiddle");
  61. mc_tty_frm[MC_TTY_FRM_LEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "leftmiddle");
  62. mc_tty_frm[MC_TTY_FRM_RIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "rightmiddle");
  63. mc_tty_frm[MC_TTY_FRM_CROSS] = mc_skin_lines_load_frm (mc_skin, "cross");
  64. /* double lines */
  65. mc_tty_frm[MC_TTY_FRM_DVERT] = mc_skin_lines_load_frm (mc_skin, "dvert");
  66. mc_tty_frm[MC_TTY_FRM_DHORIZ] = mc_skin_lines_load_frm (mc_skin, "dhoriz");
  67. mc_tty_frm[MC_TTY_FRM_DLEFTTOP] = mc_skin_lines_load_frm (mc_skin, "dlefttop");
  68. mc_tty_frm[MC_TTY_FRM_DRIGHTTOP] = mc_skin_lines_load_frm (mc_skin, "drighttop");
  69. mc_tty_frm[MC_TTY_FRM_DLEFTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "dleftbottom");
  70. mc_tty_frm[MC_TTY_FRM_DRIGHTBOTTOM] = mc_skin_lines_load_frm (mc_skin, "drightbottom");
  71. mc_tty_frm[MC_TTY_FRM_DTOPMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dtopmiddle");
  72. mc_tty_frm[MC_TTY_FRM_DBOTTOMMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dbottommiddle");
  73. mc_tty_frm[MC_TTY_FRM_DLEFTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "dleftmiddle");
  74. mc_tty_frm[MC_TTY_FRM_DRIGHTMIDDLE] = mc_skin_lines_load_frm (mc_skin, "drightmiddle");
  75. }
  76. /* --------------------------------------------------------------------------------------------- */