Bug fix: improved line formatting
There was a long standing problem where random gaps would appear between lines. The fix was to change a magic number that adds an extra few pixels to the reported height of the 'em' character dimensions. Unfortunately I don't know what this magic number actually does. It might represent the distance between lines?
This commit is contained in:
parent
72c74f1905
commit
7232ac120f
|
@ -95,7 +95,7 @@ func sleepUntilPageLoad(maxTime time.Duration) {
|
||||||
for time.Since(start) < maxTime {
|
for time.Since(start) < maxTime {
|
||||||
if browsh.CurrentTab != nil {
|
if browsh.CurrentTab != nil {
|
||||||
if browsh.CurrentTab.PageState == "parsing_complete" {
|
if browsh.CurrentTab.PageState == "parsing_complete" {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should navigate to a new page by clicking a link", func() {
|
It("should navigate to a new page by clicking a link", func() {
|
||||||
Expect("Another▄page").To(BeInFrameAt(12, 19))
|
Expect("Another▄page").To(BeInFrameAt(12, 18))
|
||||||
mouseClick(12, 19)
|
mouseClick(12, 18)
|
||||||
Expect("Another").To(BeInFrameAt(0, 0))
|
Expect("Another").To(BeInFrameAt(0, 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
|
|
||||||
It("should scroll the page by one page", func() {
|
It("should scroll the page by one page", func() {
|
||||||
SpecialKey(tcell.KeyPgDn)
|
SpecialKey(tcell.KeyPgDn)
|
||||||
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 12))
|
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 13))
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Text Input", func() {
|
Describe("Text Input", func() {
|
||||||
|
@ -54,7 +54,7 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
SpecialKey(tcell.KeyDown)
|
SpecialKey(tcell.KeyDown)
|
||||||
SpecialKey(tcell.KeyDown)
|
SpecialKey(tcell.KeyDown)
|
||||||
simScreen.InjectMouse(12, 17, tcell.Button1, tcell.ModNone)
|
simScreen.InjectMouse(12, 16, tcell.Button1, tcell.ModNone)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should have basic cursor movement", func() {
|
It("should have basic cursor movement", func() {
|
||||||
|
@ -64,12 +64,12 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
SpecialKey(tcell.KeyLeft)
|
SpecialKey(tcell.KeyLeft)
|
||||||
SpecialKey(tcell.KeyLeft)
|
SpecialKey(tcell.KeyLeft)
|
||||||
Keyboard("1")
|
Keyboard("1")
|
||||||
Expect("|1|2|").To(BeInFrameAt(12, 17))
|
Expect("|1|2|").To(BeInFrameAt(12, 16))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should scroll single line boxes on overflow", func() {
|
It("should scroll single line boxes on overflow", func() {
|
||||||
Keyboard("12345678901234567890")
|
Keyboard("12345678901234567890")
|
||||||
Expect("45678901234567890").To(BeInFrameAt(12, 17))
|
Expect("45678901234567890").To(BeInFrameAt(12, 16))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should scroll overflowed boxes to the left and right", func() {
|
It("should scroll overflowed boxes to the left and right", func() {
|
||||||
|
@ -77,18 +77,18 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
for i := 0; i < 19; i++ {
|
for i := 0; i < 19; i++ {
|
||||||
SpecialKey(tcell.KeyLeft)
|
SpecialKey(tcell.KeyLeft)
|
||||||
}
|
}
|
||||||
Expect("23456789012345678").To(BeInFrameAt(12, 17))
|
Expect("23456789012345678").To(BeInFrameAt(12, 16))
|
||||||
for i := 0; i < 19; i++ {
|
for i := 0; i < 19; i++ {
|
||||||
SpecialKey(tcell.KeyRight)
|
SpecialKey(tcell.KeyRight)
|
||||||
}
|
}
|
||||||
Expect("45678901234567890").To(BeInFrameAt(12, 17))
|
Expect("45678901234567890").To(BeInFrameAt(12, 16))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should submit text into an input box", func() {
|
It("should submit text into an input box", func() {
|
||||||
Expect("Unsubmitted").To(BeInFrameAt(12, 21))
|
Expect("Unsubmitted").To(BeInFrameAt(12, 20))
|
||||||
Keyboard("Reverse Me!")
|
Keyboard("Reverse Me!")
|
||||||
SpecialKey(tcell.KeyEnter)
|
SpecialKey(tcell.KeyEnter)
|
||||||
Expect("!eM▄esreveR").To(BeInFrameAt(12, 21))
|
Expect("!eM▄esreveR").To(BeInFrameAt(12, 20))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
Keyboard(`So here is a lot of text that will hopefully split across lines`)
|
Keyboard(`So here is a lot of text that will hopefully split across lines`)
|
||||||
SpecialKey(tcell.KeyEnter)
|
SpecialKey(tcell.KeyEnter)
|
||||||
Keyboard(`And here is even more filler, it's endless!`)
|
Keyboard(`And here is even more filler, it's endless!`)
|
||||||
Expect("filler, it's endless!").To(BeInFrameAt(1, 7))
|
Expect("filler, it's endless!").To(BeInFrameAt(1, 6))
|
||||||
for i := 1; i <= 6; i++ {
|
for i := 1; i <= 6; i++ {
|
||||||
SpecialKey(tcell.KeyUp)
|
SpecialKey(tcell.KeyUp)
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ var _ = Describe("Showing a basic webpage", func() {
|
||||||
Describe("Rendering", func() {
|
Describe("Rendering", func() {
|
||||||
It("should reset page scroll to zero on page load", func() {
|
It("should reset page scroll to zero on page load", func() {
|
||||||
SpecialKey(tcell.KeyPgDn)
|
SpecialKey(tcell.KeyPgDn)
|
||||||
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 12))
|
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 13))
|
||||||
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
||||||
Expect("Another▄webpage").To(BeInFrameAt(1, 3))
|
Expect("Another▄webpage").To(BeInFrameAt(1, 3))
|
||||||
})
|
})
|
||||||
|
|
|
@ -43,10 +43,8 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
const window_width = parseInt(Math.round(this.tty.width * this.char.width));
|
const window_width = parseInt(Math.round(this.tty.width * this.char.width));
|
||||||
// Leave room for tabs and URL bar
|
// Leave room for tabs and URL bar
|
||||||
const tty_dom_height = this.tty.height - 2;
|
const tty_dom_height = this.tty.height - 2;
|
||||||
// I don't know why we have to add 4 more lines to the window height?? But without
|
|
||||||
// it text doesn't fill the bottom of the TTY.
|
|
||||||
const window_height = parseInt(Math.round(
|
const window_height = parseInt(Math.round(
|
||||||
(tty_dom_height + 4) * this.char.height
|
tty_dom_height * this.char.height
|
||||||
));
|
));
|
||||||
const current_window = browser.windows.getCurrent();
|
const current_window = browser.windows.getCurrent();
|
||||||
current_window.then(
|
current_window.then(
|
||||||
|
|
|
@ -14,8 +14,8 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
if (TEST) {
|
if (TEST) {
|
||||||
this._char_height_magic_number = 0;
|
this._char_height_magic_number = 0;
|
||||||
} else {
|
} else {
|
||||||
// TODO: WTF is this magic number?
|
// TODO: WTF is this magic number? The gap between lines?
|
||||||
this._char_height_magic_number = 4;
|
this._char_height_magic_number = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the region outside the visible area of the TTY that is pre-parsed and
|
// This is the region outside the visible area of the TTY that is pre-parsed and
|
||||||
|
|
|
@ -49,6 +49,7 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
_updateState() {
|
_updateState() {
|
||||||
this.tty_grid.cells = [];
|
this.tty_grid.cells = [];
|
||||||
this._parse_started_elements = [];
|
this._parse_started_elements = [];
|
||||||
|
this._previous_dom_box = {};
|
||||||
this._convertSubFrameToViewportCoords();
|
this._convertSubFrameToViewportCoords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +232,6 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
// real browser.
|
// real browser.
|
||||||
_positionSingleTextNode() {
|
_positionSingleTextNode() {
|
||||||
this._dom_box = {};
|
this._dom_box = {};
|
||||||
this._previous_dom_box = {};
|
|
||||||
for (const dom_box of this._getNodeDOMBoxes()) {
|
for (const dom_box of this._getNodeDOMBoxes()) {
|
||||||
if (!this._isDOMRectInSubFrame(dom_box)) { continue }
|
if (!this._isDOMRectInSubFrame(dom_box)) { continue }
|
||||||
this._dom_box.top = dom_box.top;
|
this._dom_box.top = dom_box.top;
|
||||||
|
@ -271,8 +271,8 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
this._dom_box = this._convertDOMRectToAbsoluteCoords(this._dom_box);
|
this._dom_box = this._convertDOMRectToAbsoluteCoords(this._dom_box);
|
||||||
this._createSyncedTTYBox();
|
this._createSyncedTTYBox();
|
||||||
this._createTrackers()
|
this._createTrackers()
|
||||||
this._ignoreUnrenderedWhitespace();
|
|
||||||
this._setCurrentCharacter();
|
this._setCurrentCharacter();
|
||||||
|
this._ignoreUnrenderedWhitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that it's possible for this._text to straddle many DOM boxes
|
// Note that it's possible for this._text to straddle many DOM boxes
|
||||||
|
@ -286,8 +286,8 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
// each step is a new single cell within the TTY.
|
// each step is a new single cell within the TTY.
|
||||||
_createTrackers() {
|
_createTrackers() {
|
||||||
this._dom_tracker = {
|
this._dom_tracker = {
|
||||||
x: utils.snap(this._dom_box.left),
|
x: this._dom_box.left,
|
||||||
y: utils.snap(this._dom_box.top)
|
y: this._dom_box.top
|
||||||
}
|
}
|
||||||
this._tty_tracker = {
|
this._tty_tracker = {
|
||||||
x: this._tty_box.col_start,
|
x: this._tty_box.col_start,
|
||||||
|
@ -327,7 +327,7 @@ export default class extends utils.mixins(CommonMixin) {
|
||||||
|
|
||||||
// Is the current DOM rectangle further down the page than the previous?
|
// Is the current DOM rectangle further down the page than the previous?
|
||||||
_isNewLine() {
|
_isNewLine() {
|
||||||
if (this._previous_dom_box === {}) return false;
|
if (Object.keys(this._previous_dom_box).length === 0) return false;
|
||||||
return this._dom_box.top > this._previous_dom_box.top
|
return this._dom_box.top > this._previous_dom_box.top
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue