format

package
v0.7.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package format implements our own content print methods.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageBox

type MessageBox struct {
	// contains filtered or unexported fields
}

MessageBox defines message box structure used to draw pretty message box.

Example
msgBox := NewMessageBox(80)
msgBox.Add("Merge request #123 is created or updated.\n")
msgBox.Add("Access MR#123 at: %s", "http://localhost/...")
msgBox.Add("Download using command: %s", "git repo download 123")
msgBox.Draw(os.Stdout)
Output:

+----------------------------------------------------+
| Merge request #123 is created or updated.          |
|                                                    |
| Access MR#123 at: http://localhost/...             |
| Download using command: git repo download 123      |
+----------------------------------------------------+

func NewMessageBox

func NewMessageBox(maxWidth int) *MessageBox

NewMessageBox creates new message box instance.

func (*MessageBox) Add

func (v *MessageBox) Add(a ...interface{})

Add messages to message box.

func (*MessageBox) Draw

func (v *MessageBox) Draw(w io.Writer)

Draw starts to draw message box.

func (*MessageBox) SetStyle

func (v *MessageBox) SetStyle(pos ...byte)

SetStyle changes style of message box. Arguments provide position code for style.

One position code: draw message box border using the given character.

Four position codes: draw message box border using the given characters. The 1st code defines the left border, the 2nd code defines the top border, The 3rd code defines the right border, and the last code defines the bottom border.

Eight position codes: draw message box border using the given characters. Chacters given by the position codes defiens the left, top-left, top, top-right, right, bottom-right, bottom, bottom-left charcter of the border.

Example
msgBox := NewMessageBox(80)
msgBox.Add("Merge request #123 is created or updated.\n")
msgBox.Add("Access MR#123 at: %s", "http://localhost/...")
msgBox.Add("Download using command: %s", "git repo download 123")
msgBox.SetStyle('#')
msgBox.Draw(os.Stdout)
fmt.Println("")
msgBox.SetStyle('|', '+', '-', '+', '|', '+', '-', '+')
msgBox.Draw(os.Stdout)
Output:

######################################################
# Merge request #123 is created or updated.          #
#                                                    #
# Access MR#123 at: http://localhost/...             #
# Download using command: git repo download 123      #
######################################################

+----------------------------------------------------+
| Merge request #123 is created or updated.          |
|                                                    |
| Access MR#123 at: http://localhost/...             |
| Download using command: git repo download 123      |
+----------------------------------------------------+

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL