Adds a terminal mode change to disallow line wrapping by the terminal, also fixes a resize scroll issue and disallows escape characters in text files
This commit is contained in:
parent
0879592015
commit
fdaf6312ab
21
client.go
21
client.go
|
@ -73,7 +73,7 @@ func (c *client) GetSize() {
|
|||
if h != c.Height || w != c.Width {
|
||||
c.Height = h
|
||||
c.Width = w
|
||||
c.Draw()
|
||||
c.Scroll(0)
|
||||
}
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
@ -732,13 +732,18 @@ func (c *client) Visit(url string) {
|
|||
}
|
||||
switch capsule.Status {
|
||||
case 2:
|
||||
pg := MakePage(u, capsule.Content, capsule.Links)
|
||||
pg.WrapContent(c.Width)
|
||||
c.PageState.Add(pg)
|
||||
c.Scroll(0)
|
||||
c.ClearMessage()
|
||||
c.SetHeaderUrl()
|
||||
c.Draw()
|
||||
if capsule.MimeMaj == "text" {
|
||||
pg := MakePage(u, capsule.Content, capsule.Links)
|
||||
pg.WrapContent(c.Width)
|
||||
c.PageState.Add(pg)
|
||||
c.Scroll(0)
|
||||
c.ClearMessage()
|
||||
c.SetHeaderUrl()
|
||||
c.Draw()
|
||||
} else {
|
||||
c.SetMessage("Still mulling how to handle binary files... come back soon", false)
|
||||
c.DrawMessage()
|
||||
}
|
||||
case 3:
|
||||
c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false)
|
||||
c.DrawMessage()
|
||||
|
|
|
@ -65,6 +65,7 @@ func Exit() {
|
|||
|
||||
fmt.Print("\n")
|
||||
fmt.Print("\033[?25h")
|
||||
HandleAlternateScreen("smam")
|
||||
HandleAlternateScreen("rmcup")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -94,6 +94,7 @@ func initClient() error {
|
|||
}
|
||||
|
||||
func main() {
|
||||
cui.HandleAlternateScreen("rmam")
|
||||
cui.HandleAlternateScreen("smcup")
|
||||
defer cui.Exit()
|
||||
err := initClient()
|
||||
|
|
7
page.go
7
page.go
|
@ -46,7 +46,7 @@ func (p *Page) WrapContent(width int) {
|
|||
counter := 0
|
||||
var content strings.Builder
|
||||
content.Grow(len(p.RawContent))
|
||||
for _, ch := range p.RawContent {
|
||||
for _, ch := range []rune(p.RawContent) {
|
||||
if ch == '\n' {
|
||||
content.WriteRune(ch)
|
||||
counter = 0
|
||||
|
@ -58,9 +58,8 @@ func (p *Page) WrapContent(width int) {
|
|||
content.WriteRune('\n')
|
||||
counter = 0
|
||||
}
|
||||
} else if ch == '\r' {
|
||||
// This handles non-linux line endings...
|
||||
// to some degree...
|
||||
} else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == 27 {
|
||||
// Get rid of control characters we dont want
|
||||
continue
|
||||
} else {
|
||||
if counter < width {
|
||||
|
|
Loading…
Reference in New Issue