diff --git a/CHANGELOG.md b/CHANGELOG.md index 821495a5..e8a11b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### 12.50.0 + +* `[fmtc]` Added methods `TPrint`, `LPrint` and `TLPrint` + ### 12.49.0 * `[options]` Added method `Is` for checking argument value diff --git a/ek.go b/ek.go index 627e09b5..4236f460 100644 --- a/ek.go +++ b/ek.go @@ -20,7 +20,7 @@ import ( // ////////////////////////////////////////////////////////////////////////////////// // // VERSION is current ek package version -const VERSION = "12.49.0" +const VERSION = "12.50.0" // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/fmtc/fmtc.go b/fmtc/fmtc.go index 3f7ae237..5609cd07 100644 --- a/fmtc/fmtc.go +++ b/fmtc/fmtc.go @@ -193,6 +193,12 @@ func Errorf(f string, a ...interface{}) error { return errors.New(Sprintf(f, a...)) } +// TPrint removes all content on the current line and prints the new message +func TPrint(a ...interface{}) (int, error) { + fmt.Print(_CODE_CLEAN_LINE) + return Print(a...) +} + // TPrintf removes all content on the current line and prints the new message func TPrintf(f string, a ...interface{}) (int, error) { fmt.Print(_CODE_CLEAN_LINE) @@ -206,6 +212,13 @@ func TPrintln(a ...interface{}) (int, error) { return Println(a...) } +// LPrint formats using the default formats for its operands and writes to standard +// output limited by the text size +func LPrint(maxSize int, a ...interface{}) (int, error) { + s := fmt.Sprint(a...) + return fmt.Print(searchColors(s, maxSize, DisableColors)) +} + // LPrintf formats according to a format specifier and writes to standard output // limited by the text size func LPrintf(maxSize int, f string, a ...interface{}) (int, error) { @@ -220,6 +233,13 @@ func LPrintln(maxSize int, a ...interface{}) (int, error) { return fmt.Println(a...) } +// TLPrint removes all content on the current line and prints the new message +// limited by the text size +func TLPrint(maxSize int, a ...interface{}) (int, error) { + fmt.Print(_CODE_CLEAN_LINE) + return LPrint(maxSize, a...) +} + // TLPrintf removes all content on the current line and prints the new message // limited by the text size func TLPrintf(maxSize int, f string, a ...interface{}) (int, error) { diff --git a/fmtc/fmtc_test.go b/fmtc/fmtc_test.go index 557cf7f2..db981f70 100644 --- a/fmtc/fmtc_test.go +++ b/fmtc/fmtc_test.go @@ -217,18 +217,22 @@ func (s *FormatSuite) TestMethods(c *C) { Printf("Printf: %s\n", "OK") Print("Print: OK\n") + LPrint(11, "LPrintf: OK NOTOK") + NewLine() LPrintf(11, "LPrintf: %s NOTOK", "OK") NewLine() LPrintln(12, "LPrintln: OK NOTOK") } func (s *FormatSuite) TestAux(c *C) { + TPrint("TPrint: OK\n") TPrintf("TPrint: %s", "OK") TPrintf("") TPrintf("TPrint: %s", "OK") TPrintln("TPrint: OK") + TLPrint(11, "TLPrint: OK NOTOK") TLPrintf(11, "TLPrint: %s NOTOK", "OK") TLPrintf(11, "") TLPrintf(11, "TLPrint: %s NOTOK", "OK")