Modif format
This commit is contained in:
		
							parent
							
								
									67532c3acc
								
							
						
					
					
						commit
						57f6071552
					
				
					 3 changed files with 19 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -150,6 +150,11 @@ func (c Color) String(force ...bool) string {
 | 
			
		|||
	return s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Esc retourne l’échappement ASCII complet.
 | 
			
		||||
func (c Color) Esc(force ...bool) string {
 | 
			
		||||
	return fmt.Sprintf(escTpl, c.String(force...))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format colore la chaîne donnée selon la couleur spécifiée.
 | 
			
		||||
func (c Color) Format(text string) string {
 | 
			
		||||
	if !c.IsDefined() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,10 @@ import (
 | 
			
		|||
	"gitea.zaclys.com/bvaudour/gob/collection"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const formatTpl = "\033[%sm%s\033[m"
 | 
			
		||||
const (
 | 
			
		||||
	formatTpl = "\033[%sm%s\033[m"
 | 
			
		||||
	escTpl    = "\033[%sm"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Format permet d’appliquer des styles et des couleurs à des chaînes dans un terminal de type UNIX.
 | 
			
		||||
type Format struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -154,6 +157,11 @@ func (f Format) String() string {
 | 
			
		|||
	return strings.Join(args, ";")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Esc retourne l’échappement complet
 | 
			
		||||
func (f Format) Esc() string {
 | 
			
		||||
	return fmt.Sprintf(escTpl, f.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format formate le texte selon la configuration du formateur.
 | 
			
		||||
func (f Format) Format(text string) string {
 | 
			
		||||
	return fmt.Sprintf(formatTpl, f, text)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,11 @@ func (st Style) String() string {
 | 
			
		|||
	return ""
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Esc retourne l’échappement ASCII complet.
 | 
			
		||||
func (st Style) Esc() string {
 | 
			
		||||
	return fmt.Sprintf(escTpl, st.String())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Format formate le texte donné selon le style.
 | 
			
		||||
func (st Style) Format(text string) string {
 | 
			
		||||
	if !st.IsDefined() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue