4 "github.com/zyedidia/micro/internal/config"
5 "github.com/zyedidia/tcell"
16 // Message represents the information for a gutter message
20 // Start and End locations for the message
22 // The Kind stores the message type
24 // The Owner of the message
28 // NewMessage creates a new gutter message
29 func NewMessage(owner string, msg string, start, end Loc, kind MsgType) *Message {
39 // NewMessageAtLine creates a new gutter message at a given line
40 func NewMessageAtLine(owner string, msg string, line int, kind MsgType) *Message {
41 start := Loc{-1, line - 1}
43 return NewMessage(owner, msg, start, end, kind)
46 func (m *Message) Style() tcell.Style {
49 if style, ok := config.Colorscheme["gutter-info"]; ok {
53 if style, ok := config.Colorscheme["gutter-warning"]; ok {
57 if style, ok := config.Colorscheme["gutter-error"]; ok {
61 return config.DefStyle
64 func (b *Buffer) AddMessage(m *Message) {
65 b.Messages = append(b.Messages, m)
68 func (b *Buffer) removeMsg(i int) {
69 copy(b.Messages[i:], b.Messages[i+1:])
70 b.Messages[len(b.Messages)-1] = nil
71 b.Messages = b.Messages[:len(b.Messages)-1]
74 func (b *Buffer) ClearMessages(owner string) {
75 for i := len(b.Messages) - 1; i >= 0; i-- {
76 if b.Messages[i].Owner == owner {
82 func (b *Buffer) ClearAllMessages() {
83 b.Messages = make([]*Message, 0)