-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ANSI color and style-fix issue#15
Add support for ANSI color and style-fix issue#15 This change addresses the need by: Adding new method *colorize*. Side effects: New third party dependency, FACE is now a requirement (all other codes using StringiFor must be updated).
- Loading branch information
Showing
88 changed files
with
612 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/tests/stringifor_string_t/stringifor_string_t-doctest-100.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: acharacter | ||
logical :: test_passed(2) | ||
astring = 'one' | ||
acharacter = 'ONE' | ||
test_passed(1) = ((acharacter<astring).eqv..true.) | ||
astring = 'ONE' | ||
acharacter = 'one' | ||
test_passed(2) = ((acharacter<astring).eqv..false.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
1 change: 1 addition & 0 deletions
1
src/tests/stringifor_string_t/stringifor_string_t-doctest-100.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
T |
14 changes: 7 additions & 7 deletions
14
src/tests/stringifor_string_t/stringifor_string_t-doctest-101.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: acharacter | ||
type(string) :: anotherstring | ||
logical :: test_passed(3) | ||
astring = 'one' | ||
acharacter = 'ONE' | ||
test_passed(1) = ((astring<=acharacter).eqv..false.) | ||
anotherstring = 'ONE' | ||
test_passed(1) = ((astring<=anotherstring).eqv..false.) | ||
astring = 'ONE' | ||
acharacter = 'one' | ||
test_passed(2) = ((astring<=acharacter).eqv..true.) | ||
anotherstring = 'one' | ||
test_passed(2) = ((astring<=anotherstring).eqv..true.) | ||
astring = 'ONE' | ||
acharacter = 'ONE' | ||
test_passed(3) = ((astring<=acharacter).eqv..true.) | ||
anotherstring = 'ONE' | ||
test_passed(3) = ((astring<=anotherstring).eqv..true.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
src/tests/stringifor_string_t/stringifor_string_t-doctest-103.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
type(string) :: anotherstring | ||
character(len=:), allocatable :: acharacter | ||
logical :: test_passed(3) | ||
astring = 'one' | ||
anotherstring = 'ONE' | ||
test_passed(1) = ((astring>=anotherstring).eqv..true.) | ||
acharacter = 'ONE' | ||
test_passed(1) = ((acharacter<=astring).eqv..true.) | ||
astring = 'ONE' | ||
anotherstring = 'one' | ||
test_passed(2) = ((astring>=anotherstring).eqv..false.) | ||
acharacter = 'one' | ||
test_passed(2) = ((acharacter<=astring).eqv..false.) | ||
astring = 'ONE' | ||
anotherstring = 'ONE' | ||
test_passed(3) = ((astring>=anotherstring).eqv..true.) | ||
acharacter = 'ONE' | ||
test_passed(3) = ((acharacter<=astring).eqv..true.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
14 changes: 7 additions & 7 deletions
14
src/tests/stringifor_string_t/stringifor_string_t-doctest-104.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: acharacter | ||
type(string) :: anotherstring | ||
logical :: test_passed(3) | ||
astring = 'one' | ||
acharacter = 'ONE' | ||
test_passed(1) = ((astring>=acharacter).eqv..true.) | ||
anotherstring = 'ONE' | ||
test_passed(1) = ((astring>=anotherstring).eqv..true.) | ||
astring = 'ONE' | ||
acharacter = 'one' | ||
test_passed(2) = ((astring>=acharacter).eqv..false.) | ||
anotherstring = 'one' | ||
test_passed(2) = ((astring>=anotherstring).eqv..false.) | ||
astring = 'ONE' | ||
acharacter = 'ONE' | ||
test_passed(3) = ((astring>=acharacter).eqv..true.) | ||
anotherstring = 'ONE' | ||
test_passed(3) = ((astring>=anotherstring).eqv..true.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
src/tests/stringifor_string_t/stringifor_string_t-doctest-106.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
type(string) :: anotherstring | ||
logical :: test_passed(2) | ||
character(len=:), allocatable :: acharacter | ||
logical :: test_passed(3) | ||
astring = 'one' | ||
anotherstring = 'ONE' | ||
test_passed(1) = ((astring>anotherstring).eqv..true.) | ||
acharacter = 'ONE' | ||
test_passed(1) = ((acharacter>=astring).eqv..false.) | ||
astring = 'ONE' | ||
anotherstring = 'one' | ||
test_passed(2) = ((astring>anotherstring).eqv..false.) | ||
acharacter = 'one' | ||
test_passed(2) = ((acharacter>=astring).eqv..true.) | ||
astring = 'ONE' | ||
acharacter = 'ONE' | ||
test_passed(3) = ((acharacter>=astring).eqv..true.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
10 changes: 5 additions & 5 deletions
10
src/tests/stringifor_string_t/stringifor_string_t-doctest-107.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: acharacter | ||
type(string) :: anotherstring | ||
logical :: test_passed(2) | ||
astring = 'one' | ||
acharacter = 'ONE' | ||
test_passed(1) = ((astring>acharacter).eqv..true.) | ||
anotherstring = 'ONE' | ||
test_passed(1) = ((astring>anotherstring).eqv..true.) | ||
astring = 'ONE' | ||
acharacter = 'one' | ||
test_passed(2) = ((astring>acharacter).eqv..false.) | ||
anotherstring = 'one' | ||
test_passed(2) = ((astring>anotherstring).eqv..false.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/tests/stringifor_string_t/stringifor_string_t-doctest-109.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: acharacter | ||
logical :: test_passed(2) | ||
astring = 'one' | ||
acharacter = 'ONE' | ||
test_passed(1) = ((acharacter>astring).eqv..false.) | ||
astring = 'ONE' | ||
acharacter = 'one' | ||
test_passed(2) = ((acharacter>astring).eqv..true.) | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
1 change: 1 addition & 0 deletions
1
src/tests/stringifor_string_t/stringifor_string_t-doctest-109.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
T |
4 changes: 2 additions & 2 deletions
4
src/tests/stringifor_string_t/stringifor_string_t-doctest-28.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
astring = 'SG93IGFyZSB5b3U/' | ||
print '(L1)', astring%decode(codec='base64')//''=='How are you?' | ||
astring = 'say all Hello WorLD!' | ||
print '(L1)', astring%colorize(color_fg='red')=='[31msay all Hello WorLD![0m' | ||
endprogram volatile_doctest |
4 changes: 2 additions & 2 deletions
4
src/tests/stringifor_string_t/stringifor_string_t-doctest-29.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
astring = 'How are you?' | ||
print '(L1)', astring%encode(codec='base64')//''=='SG93IGFyZSB5b3U/' | ||
astring = 'SG93IGFyZSB5b3U/' | ||
print '(L1)', astring%decode(codec='base64')//''=='How are you?' | ||
endprogram volatile_doctest |
7 changes: 2 additions & 5 deletions
7
src/tests/stringifor_string_t/stringifor_string_t-doctest-30.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
logical :: test_passed(2) | ||
astring = '^\s \d+\s*' | ||
test_passed(1) = astring%escape(to_escape='\')//''=='^\\s \\d+\\s*' | ||
test_passed(2) = astring%escape(to_escape='\', esc='|')//''=='^|\s |\d+|\s*' | ||
print '(L1)', all(test_passed) | ||
astring = 'How are you?' | ||
print '(L1)', astring%encode(codec='base64')//''=='SG93IGFyZSB5b3U/' | ||
endprogram volatile_doctest |
7 changes: 5 additions & 2 deletions
7
src/tests/stringifor_string_t/stringifor_string_t-doctest-31.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
astring = '/bar/foo.tar.bz2' | ||
print '(L1)', astring%extension()//''=='.bz2' | ||
logical :: test_passed(2) | ||
astring = '^\s \d+\s*' | ||
test_passed(1) = astring%escape(to_escape='\')//''=='^\\s \\d+\\s*' | ||
test_passed(2) = astring%escape(to_escape='\', esc='|')//''=='^|\s |\d+|\s*' | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
9 changes: 2 additions & 7 deletions
9
src/tests/stringifor_string_t/stringifor_string_t-doctest-32.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
logical :: test_passed(4) | ||
astring = 'this is string example....wow!!!' | ||
test_passed(1) = astring%fill(width=40)//''=='00000000this is string example....wow!!!' | ||
test_passed(2) = astring%fill(width=50)//''=='000000000000000000this is string example....wow!!!' | ||
test_passed(3) = astring%fill(width=50, right=.true.)//''=='this is string example....wow!!!000000000000000000' | ||
test_passed(4) = astring%fill(width=40, filling_char='*')//''=='********this is string example....wow!!!' | ||
print '(L1)', all(test_passed) | ||
astring = '/bar/foo.tar.bz2' | ||
print '(L1)', astring%extension()//''=='.bz2' | ||
endprogram volatile_doctest |
8 changes: 6 additions & 2 deletions
8
src/tests/stringifor_string_t/stringifor_string_t-doctest-33.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
logical :: test_passed(4) | ||
astring = 'this is string example....wow!!!' | ||
call astring%free | ||
print '(L1)', astring%is_allocated().eqv..false. | ||
test_passed(1) = astring%fill(width=40)//''=='00000000this is string example....wow!!!' | ||
test_passed(2) = astring%fill(width=50)//''=='000000000000000000this is string example....wow!!!' | ||
test_passed(3) = astring%fill(width=50, right=.true.)//''=='this is string example....wow!!!000000000000000000' | ||
test_passed(4) = astring%fill(width=40, filling_char='*')//''=='********this is string example....wow!!!' | ||
print '(L1)', all(test_passed) | ||
endprogram volatile_doctest |
29 changes: 3 additions & 26 deletions
29
src/tests/stringifor_string_t/stringifor_string_t-doctest-34.f90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,7 @@ | ||
program volatile_doctest | ||
use stringifor_string_t | ||
type(string) :: astring | ||
character(len=:), allocatable :: alist_chr(:) | ||
integer, parameter :: Nf=5 | ||
character(14) :: files(1:Nf) | ||
integer :: file_unit | ||
integer :: f | ||
integer :: ff | ||
logical :: test_passed | ||
do f=1, Nf | ||
files(f) = astring%tempname(prefix='foo-') | ||
open(newunit=file_unit, file=files(f)) | ||
write(file_unit, *)f | ||
close(unit=file_unit) | ||
enddo | ||
call astring%glob(pattern='foo-*', list=alist_chr) | ||
do f=1, Nf | ||
open(newunit=file_unit, file=files(f)) | ||
close(unit=file_unit, status='delete') | ||
enddo | ||
test_passed = .false. | ||
outer_chr: do f=1, size(alist_chr, dim=1) | ||
do ff=1, Nf | ||
test_passed = alist_chr(f) == files(ff) | ||
if (test_passed) cycle outer_chr | ||
enddo | ||
enddo outer_chr | ||
print '(L1)', test_passed | ||
astring = 'this is string example....wow!!!' | ||
call astring%free | ||
print '(L1)', astring%is_allocated().eqv..false. | ||
endprogram volatile_doctest |
Oops, something went wrong.