From 8215c3767efd8e1ba3e5e425b6bcbdc4654d610c Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 11 Dec 2023 16:53:53 -0500 Subject: [PATCH] Working on Fortran version... L: --- xscii.f90 | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 xscii.f90 diff --git a/xscii.f90 b/xscii.f90 new file mode 100644 index 0000000..34fb90c --- /dev/null +++ b/xscii.f90 @@ -0,0 +1,86 @@ +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