|
|
@@ -110,6 +110,12 @@ private:
|
|
|
double line_height_ = 0;
|
|
|
double ascent_ = 0;
|
|
|
|
|
|
+ // Layout padding
|
|
|
+ static constexpr double PADDING_LEFT = 8.0;
|
|
|
+ static constexpr double PADDING_TOP = 8.0;
|
|
|
+ static constexpr double PADDING_RIGHT = 8.0;
|
|
|
+ static constexpr double PADDING_BOTTOM = 8.0;
|
|
|
+
|
|
|
// Cursor blinking
|
|
|
bool cursor_visible_ = true;
|
|
|
sigc::connection cursor_timer_connection_;
|
|
|
@@ -177,9 +183,9 @@ protected:
|
|
|
layout->get_pixel_extents(ink_rect, logical_rect);
|
|
|
char_width_ = (double)logical_rect.get_width(); // Already in pixels, no PANGO_SCALE needed
|
|
|
|
|
|
- // Update core's viewport size based on actual font metrics
|
|
|
- int content_width_px = width; // Use actual width from parameter
|
|
|
- int content_height_px = height; // Use actual height from parameter
|
|
|
+ // Update core's viewport size based on actual font metrics and padding
|
|
|
+ int content_width_px = width - static_cast<int>(PADDING_LEFT + PADDING_RIGHT);
|
|
|
+ int content_height_px = height - static_cast<int>(PADDING_TOP + PADDING_BOTTOM);
|
|
|
|
|
|
int visible_lines = static_cast<int>(content_height_px / line_height_);
|
|
|
int visible_cols = static_cast<int>(content_width_px / char_width_);
|
|
|
@@ -211,20 +217,21 @@ protected:
|
|
|
layout->set_text(visible_text);
|
|
|
|
|
|
// Render text at proper position (Cairo expects top-left, not baseline)
|
|
|
- double text_y = screen_y * line_height_;
|
|
|
- cr->move_to(0, text_y);
|
|
|
+ double text_x = PADDING_LEFT;
|
|
|
+ double text_y = PADDING_TOP + screen_y * line_height_;
|
|
|
+ cr->move_to(text_x, text_y);
|
|
|
layout->show_in_cairo_context(cr);
|
|
|
}
|
|
|
|
|
|
// Render Cursor - Emacs-style blinking block cursor with color inversion
|
|
|
if (cursor_visible_ && cursor.line >= static_cast<size_t>(start_line) && cursor.line < static_cast<size_t>(end_line)) {
|
|
|
- // Account for horizontal scrolling
|
|
|
- double cursor_screen_x = (static_cast<int>(cursor.column) - horizontal_offset) * char_width_;
|
|
|
+ // Account for horizontal scrolling and padding
|
|
|
+ double cursor_screen_x = PADDING_LEFT + (static_cast<int>(cursor.column) - horizontal_offset) * char_width_;
|
|
|
int screen_y = cursor.line - start_line;
|
|
|
- double cursor_y = screen_y * line_height_;
|
|
|
+ double cursor_y = PADDING_TOP + screen_y * line_height_;
|
|
|
|
|
|
// Only render cursor if it's visible horizontally
|
|
|
- if (cursor_screen_x >= 0 && cursor_screen_x < content_width_px) {
|
|
|
+ if (cursor_screen_x >= PADDING_LEFT && cursor_screen_x < (width - PADDING_RIGHT)) {
|
|
|
// Get the character under cursor for rendering with inverted colors
|
|
|
size_t buffer_line_idx = cursor.line;
|
|
|
const auto& cursor_line_text = buffer.line(buffer_line_idx);
|