Skip to content

Commit

Permalink
handle text content
Browse files Browse the repository at this point in the history
  • Loading branch information
treethought committed Sep 9, 2021
1 parent f08f9a9 commit 9fc6422
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ui/view.go → ui/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ui

import (
"bytes"
"fmt"
"image/color"
"io"
"log"
Expand All @@ -27,6 +28,7 @@ func NewContentView(app *App) *Content {
TextView: cview.NewTextView(),
app: app,
}

m.SetBorder(true)
m.SetPadding(1, 1, 1, 1)
m.SetTitle("content")
Expand All @@ -36,6 +38,8 @@ func NewContentView(app *App) *Content {
}

func (c *Content) SetItem(path string, entry *api.MfsLsEntry) {
c.Clear()
// go c.app.ui.QueueUpdateDraw(func() {

data, err := c.app.client.ReadFile(path, entry)
if err != nil {
Expand All @@ -60,9 +64,19 @@ func (c *Content) SetItem(path string, entry *api.MfsLsEntry) {
log.Fatal(err)
}
c.SetText(string(markdown))

case "text/plain; charset=utf-8":
c.Write(data)

case "audio/wave", "audio/mp3", "audio/ogg":
c.SetText(fmt.Sprintf("contentType: %s\nPress 'o' to play in browser", contentType))

default:
c.SetText(contentType)
c.SetText(fmt.Sprintf("ContentType: %s\nPress 'o' to open in browser", contentType))
}

c.ScrollToBeginning()
// })
}

func translateImage(reader io.Reader, x, y int) string {
Expand Down

0 comments on commit 9fc6422

Please sign in to comment.