Add text wrapping for string functions
This commit is contained in:
parent
6ac86565c1
commit
4ad0d8df34
1 changed files with 6 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
module Cowsay
|
module Cowsay
|
||||||
|
|
||||||
|
using TextWrap
|
||||||
|
|
||||||
export cowsay
|
export cowsay
|
||||||
export cowthink
|
export cowthink
|
||||||
export cowsaid
|
export cowsaid
|
||||||
|
@ -120,8 +122,8 @@ julia> cowthunk("Have I mooed today?")
|
||||||
" _____________________\\n( Have I mooed today? )\\n ---------------------\\n o ^__^\\n o (oo)\\\\_______\\n (__)\\\\ )\\\\/\\\\\\n ||----w |\\n || ||\\n"
|
" _____________________\\n( Have I mooed today? )\\n ---------------------\\n o ^__^\\n o (oo)\\\\_______\\n (__)\\\\ )\\\\/\\\\\\n ||----w |\\n || ||\\n"
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function cowsaid(message::AbstractString; cow=default, eyes="oo", tongue=" ")
|
function cowsaid(message::AbstractString; cow=default, eyes="oo", tongue=" ", wrap=40)
|
||||||
balloon = sayballoon(message)
|
balloon = sayballoon(TextWrap.wrap(message, width=wrap))
|
||||||
return string(balloon, cow(eyes=eyes, tongue=tongue))
|
return string(balloon, cow(eyes=eyes, tongue=tongue))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,8 +134,8 @@ Construct art of a cow thinking `message`.
|
||||||
|
|
||||||
See [`cowsaid`](@ref) and [`cowsay`](@ref)
|
See [`cowsaid`](@ref) and [`cowsay`](@ref)
|
||||||
"""
|
"""
|
||||||
function cowthunk(message::AbstractString; cow=default, eyes="oo", tongue=" ")
|
function cowthunk(message::AbstractString; cow=default, eyes="oo", tongue=" ", wrap=40)
|
||||||
balloon = thinkballoon(message)
|
balloon = thinkballoon(TextWrap.wrap(message, width=wrap))
|
||||||
return string(balloon, cow(eyes=eyes, tongue=tongue, thoughts="o"))
|
return string(balloon, cow(eyes=eyes, tongue=tongue, thoughts="o"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue