diff options
Diffstat (limited to 'core/mouse.zig')
| -rw-r--r-- | core/mouse.zig | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/core/mouse.zig b/core/mouse.zig index ad76c313..aab8a752 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -581,6 +581,21 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void { v.hover_col = mcol; v.hover_row = mrow; + // The notice row: the execute or the look button on a word there runs + // it or Looks at it, as on a header (a place a message names, its + // cause); nothing else happens on it. + const foot = layout.noticeRowHeight(p); + if (foot > 0 and mrow >= v.screen_h - foot and v.drag == .none and v.header_sweep == null and !v.header_drag) { + if (m.kind != .press or (m.button != config.exec_button and m.button != config.look_button)) return; + var buf: [pardes.Messages.notice_row_cap]u8 = undefined; + const row = pardes.Messages.noticeRow(p, layout.tagCapacity(p, v.screen_w -| TAG_TEXT_INSET) -| 1, &buf); + const col = Layer.columnAt(p, .notice_row, 0, v.pointer_tag_hit, false, 0) orelse (mcol -| TAG_TEXT_INSET); + const bounds = tagline.wordBoundsAtCol(row.text, panes.File.rawAtDisplay(p.settings.tab, row.text, col)) orelse return; + const word = p.scratch.allocator().dupe(u8, row.text[bounds.lo..bounds.hi]) catch |err| return p.reportError(.at(v.active), "notice row", err); + if (m.button == config.exec_button) _ = exec.execute(p, v.active, word) else exec.runBuiltin(p, config.look_cmd, v.active, "", word); + return; + } + const hovered = paneAt(p, mcol, mrow); // any press that is NOT the execute+select chord abandons a pending @@ -938,9 +953,9 @@ pub fn dragUpdate(p: *Pardes, mcol: u16, mrow: u16, body_hit: ?Mouse.BodyHit) vo else if (mrow < body_y) -1 else if (mrow >= body_y + body_h or - // The pointer cannot leave the screen: at a bottom pane, - // its last row is the edge. - (body_y + body_h >= v.screen_h and mrow + 1 >= body_y + body_h)) + // The pointer cannot leave the screen: at a bottom pane + // (over the notice row), its last row is the edge. + (body_y + body_h + layout.noticeRowHeight(p) >= v.screen_h and mrow + 1 >= body_y + body_h)) 1 else 0; |
