MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / handle_click

Method handle_click

crates/opencode-tui/src/components/permission.rs:159–193  ·  view source on GitHub ↗
(&mut self, col: u16, row: u16)

Source from the content-addressed store, hash-verified

157 }
158
159 pub fn handle_click(&mut self, col: u16, row: u16) {
160 if !self.is_open || self.requests.is_empty() {
161 return;
162 }
163 // Button row is the last content line inside the border.
164 // We store the last rendered area to check clicks.
165 // For simplicity, check if the click is on the button hints row
166 // and map x-position to the three buttons.
167 if let Some(area) = self.last_rendered_area.get() {
168 if row < area.y
169 || row >= area.y + area.height
170 || col < area.x
171 || col >= area.x + area.width
172 {
173 return;
174 }
175 // The button line is at the bottom of the content (area.y + area.height - 2 for border)
176 let button_row = area.y + area.height - 2;
177 if row == button_row {
178 // "[y] Allow [n] Deny [a] Always allow"
179 // Rough column ranges inside the border:
180 let inner_col = col.saturating_sub(area.x + 1);
181 if inner_col < 11 {
182 // [y] Allow
183 self.pending_action = Some(PermissionAction::Approve);
184 } else if inner_col < 21 {
185 // [n] Deny
186 self.pending_action = Some(PermissionAction::Deny);
187 } else {
188 // [a] Always allow
189 self.pending_action = Some(PermissionAction::ApproveAlways);
190 }
191 }
192 }
193 }
194
195 pub fn take_pending_action(&mut self) -> Option<PermissionAction> {
196 self.pending_action.take()

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected