Get image display working

This commit is contained in:
Kovid Goyal 2023-03-27 11:00:21 +05:30
parent 9cc54978e6
commit a3f1d3e132
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 5 additions and 5 deletions

View File

@ -309,7 +309,7 @@ func image_lines(left_path, right_path string, screen_size screen_size, margin_s
}
return margin_filler_format(m) + filler
}
for i := 0; i < utils.Min(len(left_lines), len(right_lines)); i++ {
for i := 0; i < utils.Max(len(left_lines), len(right_lines)); i++ {
left, right := get_line(i, left_lines, removed_margin_format), get_line(i, right_lines, added_margin_format)
ll.screen_lines = append(ll.screen_lines, left+right)
}

View File

@ -322,7 +322,7 @@ func (self *Handler) draw_image_pair(ll *LogicalLine, starting_row int) {
}
if ll.right_image.key != "" {
self.lp.MoveCursorHorizontally(self.logical_lines.margin_size + self.logical_lines.columns/2)
self.draw_image(ll.left_image.key, ll.left_image.count, starting_row)
self.draw_image(ll.right_image.key, ll.right_image.count, starting_row)
self.lp.QueueWriteString("\r")
}
}
@ -344,9 +344,9 @@ func (self *Handler) draw_screen() {
ll := self.logical_lines.At(pos.logical_line)
is_image := ll != nil && ll.line_type == IMAGE_LINE
sl := self.logical_lines.ScreenLineAt(pos)
if is_image && seen_images.Has(pos.logical_line) {
if is_image && !seen_images.Has(pos.logical_line) && pos.screen_line >= ll.image_lines_offset {
seen_images.Add(pos.logical_line)
self.draw_image_pair(ll, pos.screen_line)
self.draw_image_pair(ll, pos.screen_line-ll.image_lines_offset)
}
if self.current_search != nil {
sl = self.current_search.markup_line(sl, pos)

View File

@ -174,7 +174,7 @@ func (self *ImageCollection) PlaceImageSubRect(lp *loop.Loop, key string, page_s
height = utils.Max(0, utils.Min(r.img.Height-top, height))
gc := &GraphicsCommand{}
gc.SetAction(GRT_action_display).SetLeftEdge(uint64(left)).SetTopEdge(uint64(top)).SetWidth(uint64(width)).SetHeight(uint64(height))
gc.SetImageId(r.image_id).SetPlacementId(1)
gc.SetImageId(r.image_id).SetPlacementId(1).SetCursorMovement(GRT_cursor_static)
gc.WriteWithPayloadToLoop(lp, nil)
}