File: modules_62_terminal.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (35 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module modules_62_terminal
  implicit none
  private

  public :: toml_terminal, ansi_code

  ! Nested type
  type :: ansi_code
    integer :: style = -1
    integer :: bg = -1
    integer :: fg = -1
  end type ansi_code

  ! Main type with multiple ansi_code components and default init
  type :: toml_terminal
    type(ansi_code) :: reset = ansi_code()
    type(ansi_code) :: bold = ansi_code()
  end type toml_terminal

  interface toml_terminal
    module procedure :: new_terminal
  end interface toml_terminal

contains

  pure function new_terminal(use_color) result(new)
    logical, intent(in) :: use_color
    type(toml_terminal) :: new
    if (use_color) then
      new%reset = ansi_code(0, -1, -1)
      new%bold = ansi_code(1, -1, -1)
    end if
  end function new_terminal

end module modules_62_terminal