-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ base ] Add getTermCols and getTermLines to base library and fix pri… (
- Loading branch information
1 parent
6be16a3
commit 8d7791b
Showing
9 changed files
with
68 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module System.Term | ||
|
||
%default total | ||
|
||
libterm : String -> String | ||
libterm s = "C:" ++ s ++ ", libidris2_support, idris_term.h" | ||
|
||
%foreign libterm "idris2_setupTerm" | ||
prim__setupTerm : PrimIO () | ||
|
||
%foreign libterm "idris2_getTermCols" | ||
prim__getTermCols : PrimIO Int | ||
|
||
%foreign libterm "idris2_getTermLines" | ||
prim__getTermLines : PrimIO Int | ||
|
||
export | ||
setupTerm : IO () | ||
setupTerm = primIO prim__setupTerm | ||
|
||
export | ||
getTermCols : IO Int | ||
getTermCols = primIO prim__getTermCols | ||
|
||
export | ||
getTermLines : IO Int | ||
getTermLines = primIO prim__getTermLines |
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
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
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,7 @@ | ||
import System.Term | ||
|
||
main : IO () | ||
main = do | ||
width <- getTermCols | ||
height <- getTermLines | ||
printLn "Success \{show $ width > 0} \{show $ height > 0}" |
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 @@ | ||
"Success False False" |
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 @@ | ||
rm -rf build | ||
|
||
# observe that errors are correctly reported as zero. | ||
$1 --exec main TermSize.idr </dev/null | ||
|
||
# The following should report True True, but the ci scripts don't | ||
# provide a terminal | ||
# $1 --exec main TermSize.idr | ||
|
||
# The following should also report True True if the output is a terminal, | ||
# but the testing framework redirects output. | ||
|
||
# idris2 --exec main tests/allschemes/scheme002/TermSize.idr </dev/null |