Handle a mouse click at the given absolute (column, row) coordinates. Toggles expand/collapse for block tools if the click lands within their region.
(&mut self, _column: u16, row: u16)
| 322 | /// Handle a mouse click at the given absolute (column, row) coordinates. |
| 323 | /// Toggles expand/collapse for block tools if the click lands within their region. |
| 324 | pub fn handle_mouse_click(&mut self, _column: u16, row: u16) { |
| 325 | // Convert absolute row to relative row within the messages area |
| 326 | let area = match self.messages_area { |
| 327 | Some(a) => a, |
| 328 | None => return, |
| 329 | }; |
| 330 | |
| 331 | if row < area.y || row >= area.y + area.height { |
| 332 | return; |
| 333 | } |
| 334 | |
| 335 | // Calculate the absolute row in the list, accounting for scroll offset |
| 336 | let relative_row = (row - area.y) as usize; |
| 337 | let list_offset = *self.list_state.offset_mut(); |
| 338 | let absolute_row = list_offset + relative_row; |
| 339 | |
| 340 | // Check against thinking regions (header line) |
| 341 | for (block_id, y_start, y_end) in &self.thinking_regions { |
| 342 | if absolute_row >= *y_start as usize && absolute_row <= *y_end as usize { |
| 343 | let block_id = block_id.clone(); |
| 344 | if self.collapsed_thinking.contains(&block_id) { |
| 345 | self.collapsed_thinking.remove(&block_id); |
| 346 | } else { |
| 347 | self.collapsed_thinking.insert(block_id.clone()); |
| 348 | } |
| 349 | self.thinking_user_overrides.insert(block_id); |
| 350 | self.invalidate_render_cache(); |
| 351 | self.hovered_thinking_block_id = None; |
| 352 | return; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // Check against block_tool_regions |
| 357 | for (tool_id, y_start, y_end) in &self.block_tool_regions { |
| 358 | if absolute_row >= *y_start as usize && absolute_row <= *y_end as usize { |
| 359 | let tool_id = tool_id.clone(); |
| 360 | if self.collapsed_tools.contains(&tool_id) { |
| 361 | self.collapsed_tools.remove(&tool_id); |
| 362 | } else { |
| 363 | self.collapsed_tools.insert(tool_id.clone()); |
| 364 | } |
| 365 | self.focused_block_tool = Some(tool_id); |
| 366 | self.invalidate_render_cache(); |
| 367 | break; |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | } |
no test coverage detected