87 lines
1.9 KiB
Fortran
87 lines
1.9 KiB
Fortran
|
module vt100
|
||
|
character, parameter :: EFFECT_NORMAL = "0"
|
||
|
character, parameter :: EFFECT_BOLD = "1"
|
||
|
character, parameter :: EFFECT_ITALIC = "3"
|
||
|
character, parameter :: EFFECT_UNDERLINE = "4"
|
||
|
character, parameter :: EFFECT_BLINK = "5"
|
||
|
character, parameter :: EFFECT_REVERSE = "7"
|
||
|
character, parameter :: COLOUR_GREY = "0"
|
||
|
character, parameter :: COLOUR_RED = "1"
|
||
|
character, parameter :: COLOUR_GREEN = "2"
|
||
|
character, parameter :: COLOUR_YELLOW = "3"
|
||
|
character, parameter :: COLOUR_BLUE = "4"
|
||
|
character, parameter :: COLOUR_PINK = "5"
|
||
|
character, parameter :: COLOUR_CYAN = "6"
|
||
|
character, parameter :: COLOUR_WHITE = "7"
|
||
|
end module vt100
|
||
|
|
||
|
program xscii
|
||
|
use vt100
|
||
|
|
||
|
implicit none
|
||
|
|
||
|
interface
|
||
|
subroutine print_colour (colour, effect)
|
||
|
character, intent (in) :: colour
|
||
|
character, intent (in) :: effect
|
||
|
end subroutine print_colour
|
||
|
|
||
|
subroutine print_cancel
|
||
|
end subroutine print_cancel
|
||
|
|
||
|
subroutine print_bar
|
||
|
end subroutine print_bar
|
||
|
end interface
|
||
|
|
||
|
integer :: i
|
||
|
|
||
|
call print_colour (COLOUR_BLUE, EFFECT_BOLD)
|
||
|
write (*, '(a)', advance='no') "Heyo!"
|
||
|
call print_cancel
|
||
|
print *
|
||
|
|
||
|
call print_bar
|
||
|
print *
|
||
|
|
||
|
do i = 1, 10
|
||
|
print *, "> ", i
|
||
|
end do
|
||
|
|
||
|
end program xscii
|
||
|
|
||
|
subroutine print_colour (colour, effect)
|
||
|
use vt100
|
||
|
|
||
|
implicit none
|
||
|
|
||
|
character, intent (in) :: colour
|
||
|
character, intent (in) :: effect
|
||
|
character (7) :: escape
|
||
|
|
||
|
escape = char (27) // "[" // effect // ";3" // colour // "m"
|
||
|
|
||
|
write (*, '(a)', advance='no') escape
|
||
|
end subroutine print_colour
|
||
|
|
||
|
subroutine print_cancel
|
||
|
use vt100
|
||
|
|
||
|
implicit none
|
||
|
|
||
|
character (4) :: escape
|
||
|
|
||
|
escape = char (27) // "[0m"
|
||
|
|
||
|
write (*, '(a)', advance='no') escape
|
||
|
end subroutine print_cancel
|
||
|
|
||
|
subroutine print_bar
|
||
|
use vt100
|
||
|
|
||
|
implicit none
|
||
|
|
||
|
call print_colour (COLOUR_GREY, EFFECT_BOLD)
|
||
|
write (*, '(a)', advance='no') " | "
|
||
|
call print_cancel
|
||
|
end subroutine print_bar
|