diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-06-02 00:43:56 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-06-02 00:43:56 +0300 |
commit | 134604edce935a0017b50c16687429e0b25248e6 (patch) | |
tree | ee0288388c84c54e060b2e29fe390ae163c1c962 /ui/messages/imagemessage.go | |
parent | 7868bd90fab77faa1e37674d543eefc1ff315fff (diff) |
Add ui toggle for image rendering
Diffstat (limited to 'ui/messages/imagemessage.go')
-rw-r--r-- | ui/messages/imagemessage.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ui/messages/imagemessage.go b/ui/messages/imagemessage.go index 3f50193..671148b 100644 --- a/ui/messages/imagemessage.go +++ b/ui/messages/imagemessage.go @@ -29,6 +29,7 @@ import ( "maunium.net/go/gomuks/lib/ansimage" "maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/tcell" + "maunium.net/go/gomuks/config" ) func init() { @@ -92,13 +93,13 @@ func (msg *ImageMessage) Path() string { // CalculateBuffer generates the internal buffer for this message that consists // of the text of this message split into lines at most as wide as the width // parameter. -func (msg *ImageMessage) CalculateBuffer(bare bool, width int) { +func (msg *ImageMessage) CalculateBuffer(prefs config.UserPreferences, width int) { if width < 2 { return } - if bare { - msg.calculateBufferWithText(bare, tstring.NewTString(msg.PlainText()), width) + if prefs.BareMessageView || prefs.DisableImages { + msg.calculateBufferWithText(prefs, tstring.NewTString(msg.PlainText()), width) return } @@ -111,10 +112,10 @@ func (msg *ImageMessage) CalculateBuffer(bare bool, width int) { msg.buffer = image.Render() msg.prevBufferWidth = width - msg.prevBareMode = false + msg.prevPrefs = prefs } // RecalculateBuffer calculates the buffer again with the previously provided width. func (msg *ImageMessage) RecalculateBuffer() { - msg.CalculateBuffer(msg.prevBareMode, msg.prevBufferWidth) + msg.CalculateBuffer(msg.prevPrefs, msg.prevBufferWidth) } |