Skip to content

Commit

Permalink
fix for substituting Nothing into interpolated text, and other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Sep 16, 2024
1 parent 5f7e3ec commit 53e62ce
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/core/gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ extension [TextType: Textual](text: TextType)
def capitalize: TextType = TextType.concat(text.keep(1).upper, text.after(Prim))
def uncapitalize: TextType = TextType.concat(text.keep(1).lower, text.after(Prim))

inline def head: Char = TextType.unsafeChar(text, Prim)
inline def last: Char = TextType.unsafeChar(text, Ult.of(text))
inline def tail: TextType = text.skip(1, Ltr)
inline def init: TextType = text.skip(1, Rtl)
inline def empty: Boolean = text.length == 0
Expand Down
2 changes: 2 additions & 0 deletions src/core/gossamer.Buffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ abstract class Buffer[TextType](size: Optional[Int] = Unset):

def apply(): TextType = result()
def clear(): this.type = this.also(wipe())
def empty: Boolean = length == 0
def length: Int
1 change: 1 addition & 0 deletions src/core/gossamer.Interpolation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ object Interpolation:
case class Input(txt: Text)

given [ValueType: Showable] => Insertion[Input, ValueType] = value => Input(value.show)
given Insertion[Input, Nothing] = value => Input("".tt)

object T extends Interpolator[Input, Text, Text]:
def initial: Text = anticipation.Text("")
Expand Down
2 changes: 2 additions & 0 deletions src/core/gossamer.TextBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ import vacuous.*
class TextBuffer(size: Optional[Int] = Unset) extends Buffer[Text](size):
private val buffer: StringBuilder = size.lay(StringBuilder())(StringBuilder(_))
protected def put(text: Text): Unit = buffer.append(text)
def put(char: Char): Unit = buffer.append(char)
protected def wipe(): Unit = buffer.clear()
protected def result(): Text = buffer.toString().tt
def length: Int = buffer.length
4 changes: 2 additions & 2 deletions src/core/soundness+gossamer-core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package soundness
export gossamer.{Bidi, Buffer, Cuttable, Decimalizer, Interpolation, Joinable, Numerous,
Presentational, Pue, RangeError, TextBuffer, Textual, append, construct, fill, txt, t, utf8,
utf16, ascii, hex, text, pue, cut, pascal, camel, snake, kebab, length, populated, lower,
upper, plain, skip, keep, capitalize, uncapitalize, head, last, tail, init, empty, chars,
upper, plain, skip, keep, capitalize, uncapitalize, tail, init, empty, chars,
slice, snip, reverse, contains, trim, where, upto, dropWhile, snipWhere,
mapChars, count, metrics, pad, center, fit, uncamel, unkebab, unsnake, starts, ends,
tr, subscript, superscript, rsub, sub, flatMap, urlEncode, urlDecode, punycode, bytes,
sysBytes, lev, join, add}
sysBytes, lev, join, add, words, lines}

package decimalFormatters:
export gossamer.decimalFormatters.java

0 comments on commit 53e62ce

Please sign in to comment.