mirror of https://github.com/liamg/aminal.git
Merge pull request #38 from liamg/vertical-resize-improvements
improved vertical resize calcs
This commit is contained in:
commit
88f0731e76
26
README.md
26
README.md
|
@ -49,22 +49,22 @@ Ensure you have your latest graphics card drivers installed before use.
|
||||||
|
|
||||||
## Planned Features
|
## Planned Features
|
||||||
|
|
||||||
| Feature | Done | Notes |
|
| Feature | Done | Notes |
|
||||||
| --------------------------- | ---- | ------------------------------------------------------------------ |
|
|-----------------------------|------|-------|
|
||||||
| Pty allocation | ✔ | Needs work for OSX + Windows |
|
| Pty allocation | ✔ |
|
||||||
| OpenGL rendering | ✔ |
|
| OpenGL rendering | ✔ |
|
||||||
| 8-bit (256) colour | ✔ |
|
| 8-bit (256) colour | ✔ |
|
||||||
| 24-bit (true) colour | ✔ |
|
| 24-bit (true) colour | ✔ |
|
||||||
| Resizing/content reordering | ⏳ |
|
| Resizing/content reordering | ✔ |
|
||||||
| ANSI escape codes | ⏳ | Most of these are handled now |
|
| ANSI escape codes | ✔ |
|
||||||
| UTF-8 input | ✔ |
|
| UTF-8 input | ✔ |
|
||||||
| UTF-8 output | ✔ | Works as long as the font in use supports the relevant characters. |
|
| UTF-8 output | ✔ | Works as long as the font in use supports the relevant characters.
|
||||||
| Copy/paste | | Paste working, no mouse interaction for copy |
|
| Copy/paste | | Paste working, no mouse interaction for copy
|
||||||
| Customisable colour schemes | ✔ | Complete, but the config file has no entry for this yet |
|
| Customisable colour schemes | ✔ | Complete, but the config file has no entry for this yet
|
||||||
| Config file | ⏳ | Minimal options atm |
|
| Config file | ✔ | Minimal options atm
|
||||||
| Scrolling | ⏳ | Infinite buffer implemented, need GUI scrollbar & render updates |
|
| Scrolling | ✔ |
|
||||||
| Mouse interaction | |
|
| Mouse interaction | |
|
||||||
| Sweet render effects | |
|
| Sweet render effects | |
|
||||||
|
|
||||||
## Keyboard Shortcuts
|
## Keyboard Shortcuts
|
||||||
|
|
||||||
|
|
|
@ -610,6 +610,8 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
||||||
line := buffer.getCurrentLine()
|
line := buffer.getCurrentLine()
|
||||||
cXFromEndOfLine := len(line.cells) - int(buffer.cursorX+1)
|
cXFromEndOfLine := len(line.cells) - int(buffer.cursorX+1)
|
||||||
|
|
||||||
|
cursorYMovement := 0
|
||||||
|
|
||||||
if width < buffer.viewWidth { // wrap lines if we're shrinking
|
if width < buffer.viewWidth { // wrap lines if we're shrinking
|
||||||
for i := 0; i < len(buffer.lines); i++ {
|
for i := 0; i < len(buffer.lines); i++ {
|
||||||
line := &buffer.lines[i]
|
line := &buffer.lines[i]
|
||||||
|
@ -629,6 +631,10 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if i+1 <= int(buffer.cursorY) {
|
||||||
|
cursorYMovement++
|
||||||
|
}
|
||||||
|
|
||||||
newLine := newLine()
|
newLine := newLine()
|
||||||
newLine.setWrapped(true)
|
newLine.setWrapped(true)
|
||||||
newLine.cells = sillyCells
|
newLine.cells = sillyCells
|
||||||
|
@ -657,6 +663,11 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
||||||
}
|
}
|
||||||
line.cells = append(line.cells, nextLine.cells[:moveCount]...)
|
line.cells = append(line.cells, nextLine.cells[:moveCount]...)
|
||||||
if moveCount == len(nextLine.cells) {
|
if moveCount == len(nextLine.cells) {
|
||||||
|
|
||||||
|
if i+offset <= int(buffer.cursorY) {
|
||||||
|
cursorYMovement--
|
||||||
|
}
|
||||||
|
|
||||||
// if we unwrapped all cells off the next line, delete it
|
// if we unwrapped all cells off the next line, delete it
|
||||||
buffer.lines = append(buffer.lines[:i+offset], buffer.lines[i+offset+1:]...)
|
buffer.lines = append(buffer.lines[:i+offset], buffer.lines[i+offset+1:]...)
|
||||||
|
|
||||||
|
@ -671,22 +682,20 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo handle vertical resize?
|
fromBottom := buffer.viewHeight - buffer.cursorY
|
||||||
|
|
||||||
if buffer.Height() < int(buffer.viewHeight) {
|
|
||||||
// we might need to move back up if the buffer is now smaller
|
|
||||||
if int(buffer.cursorY) < buffer.Height()-1 {
|
|
||||||
buffer.cursorY = uint16(buffer.Height() - 1)
|
|
||||||
} else {
|
|
||||||
buffer.cursorY = uint16(buffer.Height() - 1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buffer.cursorY = buffer.viewHeight - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.viewWidth = width
|
buffer.viewWidth = width
|
||||||
buffer.viewHeight = height
|
buffer.viewHeight = height
|
||||||
|
|
||||||
|
if buffer.cursorY >= buffer.viewHeight-1 {
|
||||||
|
buffer.cursorY = buffer.viewHeight - 1
|
||||||
|
} else {
|
||||||
|
buffer.cursorY = (buffer.viewHeight - fromBottom) + uint16(cursorYMovement)
|
||||||
|
if int(buffer.cursorY) >= buffer.Height() {
|
||||||
|
buffer.cursorY = uint16(buffer.Height() - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// position cursorX
|
// position cursorX
|
||||||
line = buffer.getCurrentLine()
|
line = buffer.getCurrentLine()
|
||||||
buffer.cursorX = uint16((len(line.cells) - cXFromEndOfLine) - 1)
|
buffer.cursorX = uint16((len(line.cells) - cXFromEndOfLine) - 1)
|
||||||
|
|
Loading…
Reference in New Issue