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