A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/e0956f7452442eec0e34457a15501e98d06c06c9 below:

correctly forward mouse events · neovim/neovim@e0956f7 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+100

-23

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+100

-23

lines changed Original file line number Diff line number Diff line change

@@ -135,7 +135,6 @@ struct terminal {

135 135

int row, col;

136 136

bool visible;

137 137

} cursor;

138 -

int pressed_button; // which mouse button is pressed

139 138

bool pending_resize; // pending width/height

140 139 141 140

bool color_set[16];

@@ -1209,21 +1208,12 @@ static VTermKey convert_key(int key, VTermModifier *statep)

1209 1208

}

1210 1209

}

1211 1210 1212 -

static void mouse_action(Terminal *term, int button, int row, int col, bool drag, VTermModifier mod)

1211 +

static void mouse_action(Terminal *term, int button, int row, int col, bool pressed,

1212 +

VTermModifier mod)

1213 1213

{

1214 -

if (term->pressed_button && (term->pressed_button != button || !drag)) {

1215 -

// release the previous button

1216 -

vterm_mouse_button(term->vt, term->pressed_button, 0, mod);

1217 -

term->pressed_button = 0;

1218 -

}

1219 - 1220 -

// move the mouse

1221 1214

vterm_mouse_move(term->vt, row, col, mod);

1222 - 1223 -

if (!term->pressed_button) {

1224 -

// press the button if not already pressed

1225 -

vterm_mouse_button(term->vt, button, 1, mod);

1226 -

term->pressed_button = button;

1215 +

if (button) {

1216 +

vterm_mouse_button(term->vt, button, pressed, mod);

1227 1217

}

1228 1218

}

1229 1219

@@ -1242,32 +1232,35 @@ static bool send_mouse_event(Terminal *term, int c)

1242 1232

// event in the terminal window and mouse events was enabled by the

1243 1233

// program. translate and forward the event

1244 1234

int button;

1245 -

bool drag = false;

1235 +

bool pressed = false;

1246 1236 1247 1237

switch (c) {

1248 1238

case K_LEFTDRAG:

1249 -

drag = true; FALLTHROUGH;

1250 1239

case K_LEFTMOUSE:

1240 +

pressed = true; FALLTHROUGH;

1241 +

case K_LEFTRELEASE:

1251 1242

button = 1; break;

1252 1243

case K_MOUSEMOVE:

1253 -

drag = true; button = 0; break;

1244 +

button = 0; break;

1254 1245

case K_MIDDLEDRAG:

1255 -

drag = true; FALLTHROUGH;

1256 1246

case K_MIDDLEMOUSE:

1247 +

pressed = true; FALLTHROUGH;

1248 +

case K_MIDDLERELEASE:

1257 1249

button = 2; break;

1258 1250

case K_RIGHTDRAG:

1259 -

drag = true; FALLTHROUGH;

1260 1251

case K_RIGHTMOUSE:

1252 +

pressed = true; FALLTHROUGH;

1253 +

case K_RIGHTRELEASE:

1261 1254

button = 3; break;

1262 1255

case K_MOUSEDOWN:

1263 -

button = 4; break;

1256 +

pressed = true; button = 4; break;

1264 1257

case K_MOUSEUP:

1265 -

button = 5; break;

1258 +

pressed = true; button = 5; break;

1266 1259

default:

1267 1260

return false;

1268 1261

}

1269 1262 1270 -

mouse_action(term, button, row, col - offset, drag, 0);

1263 +

mouse_action(term, button, row, col - offset, pressed, 0);

1271 1264

size_t len = vterm_output_read(term->vt, term->textbuf,

1272 1265

sizeof(term->textbuf));

1273 1266

terminal_send(term, term->textbuf, len);

Original file line number Diff line number Diff line change

@@ -66,7 +66,7 @@ describe(':terminal mouse', function()

66 66

]])

67 67

end)

68 68 69 -

it('will forward mouse clicks to the program', function()

69 +

it('will forward mouse press, drag and release to the program', function()

70 70

if helpers.pending_win32(pending) then return end

71 71

feed('<LeftMouse><1,2>')

72 72

screen:expect([[

@@ -78,6 +78,36 @@ describe(':terminal mouse', function()

78 78

"#{1: } |

79 79

{3:-- TERMINAL --} |

80 80

]])

81 +

feed('<LeftDrag><2,2>')

82 +

screen:expect([[

83 +

line27 |

84 +

line28 |

85 +

line29 |

86 +

line30 |

87 +

mouse enabled |

88 +

@##{1: } |

89 +

{3:-- TERMINAL --} |

90 +

]])

91 +

feed('<LeftDrag><3,2>')

92 +

screen:expect([[

93 +

line27 |

94 +

line28 |

95 +

line29 |

96 +

line30 |

97 +

mouse enabled |

98 +

@$#{1: } |

99 +

{3:-- TERMINAL --} |

100 +

]])

101 +

feed('<LeftRelease><3,2>')

102 +

screen:expect([[

103 +

line27 |

104 +

line28 |

105 +

line29 |

106 +

line30 |

107 +

mouse enabled |

108 +

#$#{1: } |

109 +

{3:-- TERMINAL --} |

110 +

]])

81 111

end)

82 112 83 113

it('will forward mouse scroll to the program', function()

@@ -94,6 +124,60 @@ describe(':terminal mouse', function()

94 124

]])

95 125

end)

96 126 127 +

it('dragging and scrolling do not interfere with each other', function()

128 +

if helpers.pending_win32(pending) then return end

129 +

feed('<LeftMouse><1,2>')

130 +

screen:expect([[

131 +

line27 |

132 +

line28 |

133 +

line29 |

134 +

line30 |

135 +

mouse enabled |

136 +

"#{1: } |

137 +

{3:-- TERMINAL --} |

138 +

]])

139 +

feed('<ScrollWheelUp><1,2>')

140 +

screen:expect([[

141 +

line27 |

142 +

line28 |

143 +

line29 |

144 +

line30 |

145 +

mouse enabled |

146 +

`"#{1: } |

147 +

{3:-- TERMINAL --} |

148 +

]])

149 +

feed('<LeftDrag><2,2>')

150 +

screen:expect([[

151 +

line27 |

152 +

line28 |

153 +

line29 |

154 +

line30 |

155 +

mouse enabled |

156 +

@##{1: } |

157 +

{3:-- TERMINAL --} |

158 +

]])

159 +

feed('<ScrollWheelUp><2,2>')

160 +

screen:expect([[

161 +

line27 |

162 +

line28 |

163 +

line29 |

164 +

line30 |

165 +

mouse enabled |

166 +

`##{1: } |

167 +

{3:-- TERMINAL --} |

168 +

]])

169 +

feed('<LeftRelease><2,2>')

170 +

screen:expect([[

171 +

line27 |

172 +

line28 |

173 +

line29 |

174 +

line30 |

175 +

mouse enabled |

176 +

###{1: } |

177 +

{3:-- TERMINAL --} |

178 +

]])

179 +

end)

180 + 97 181

it('will forward mouse clicks to the program with the correct even if set nu', function()

98 182

if helpers.pending_win32(pending) then return end

99 183

nvim('command', 'set number')

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4