mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #477 from mitchellh/notcurses-input
notcurses-input bugs
This commit is contained in:
@ -1283,8 +1283,11 @@ fn mouseReport(
|
|||||||
mods: input.Mods,
|
mods: input.Mods,
|
||||||
pos: apprt.CursorPos,
|
pos: apprt.CursorPos,
|
||||||
) !void {
|
) !void {
|
||||||
// TODO: posToViewport currently clamps to the surface boundary,
|
// The maximum pos values so we can determine if we're outside the window.
|
||||||
// do we want to not report mouse events at all outside the surface?
|
// If we're outside the window, we do not report mouse events.
|
||||||
|
const max_x: f32 = @floatFromInt(self.screen_size.width);
|
||||||
|
const max_y: f32 = @floatFromInt(self.screen_size.height);
|
||||||
|
if (pos.x < 0 or pos.y < 0 or pos.x > max_x or pos.y > max_y) return;
|
||||||
|
|
||||||
// Depending on the event, we may do nothing at all.
|
// Depending on the event, we may do nothing at all.
|
||||||
switch (self.io.terminal.flags.mouse_event) {
|
switch (self.io.terminal.flags.mouse_event) {
|
||||||
@ -1444,6 +1447,9 @@ fn mouseReport(
|
|||||||
},
|
},
|
||||||
|
|
||||||
.sgr_pixels => {
|
.sgr_pixels => {
|
||||||
|
assert(pos.x >= 0);
|
||||||
|
assert(pos.y >= 0);
|
||||||
|
|
||||||
// Final character to send in the CSI
|
// Final character to send in the CSI
|
||||||
const final: u8 = if (action == .release) 'm' else 'M';
|
const final: u8 = if (action == .release) 'm' else 'M';
|
||||||
|
|
||||||
@ -1452,8 +1458,8 @@ fn mouseReport(
|
|||||||
var data: termio.Message.WriteReq.Small.Array = undefined;
|
var data: termio.Message.WriteReq.Small.Array = undefined;
|
||||||
const resp = try std.fmt.bufPrint(&data, "\x1B[<{d};{d};{d}{c}", .{
|
const resp = try std.fmt.bufPrint(&data, "\x1B[<{d};{d};{d}{c}", .{
|
||||||
button_code,
|
button_code,
|
||||||
pos.x,
|
@as(u32, @intFromFloat(@round(pos.x))),
|
||||||
pos.y,
|
@as(u32, @intFromFloat(@round(pos.y))),
|
||||||
final,
|
final,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -300,7 +300,9 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
// Scroll Up (SD)
|
// Scroll Up (SD)
|
||||||
'S' => if (@hasDecl(T, "scrollUp")) try self.handler.scrollUp(
|
|
||||||
|
'S' => switch (action.intermediates.len) {
|
||||||
|
0 => if (@hasDecl(T, "scrollUp")) try self.handler.scrollUp(
|
||||||
switch (action.params.len) {
|
switch (action.params.len) {
|
||||||
0 => 1,
|
0 => 1,
|
||||||
1 => action.params[0],
|
1 => action.params[0],
|
||||||
@ -311,6 +313,12 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
},
|
},
|
||||||
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
|
else => log.warn(
|
||||||
|
"ignoring unimplemented CSI S with intermediates: {s}",
|
||||||
|
.{action.intermediates},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
// Scroll Down (SD)
|
// Scroll Down (SD)
|
||||||
'T' => if (@hasDecl(T, "scrollDown")) try self.handler.scrollDown(
|
'T' => if (@hasDecl(T, "scrollDown")) try self.handler.scrollDown(
|
||||||
switch (action.params.len) {
|
switch (action.params.len) {
|
||||||
|
Reference in New Issue
Block a user