|
1 | 1 | import { invoke } from '@tauri-apps/api/core'; |
2 | 2 | import { getCurrentWindow } from '@tauri-apps/api/window'; |
3 | | -import { listen } from '@tauri-apps/api/event'; |
| 3 | +import { listen, emit } from '@tauri-apps/api/event'; |
4 | 4 | import { open, save } from '@tauri-apps/plugin-dialog'; |
5 | 5 | import { writeTextFile, readTextFile } from '@tauri-apps/plugin-fs'; |
6 | | -import { parseHexString, getSettings } from './utils.js'; |
| 6 | +import { parseHexString, bytesToHex, getSettings } from './utils.js'; |
7 | 7 | import { initIcons, createElement, GripVertical, X } from './icons.js'; |
8 | 8 | import { Keybindings } from './keybindings.js'; |
9 | 9 | import { t, setLang, applyI18n, detectLang } from './i18n.js'; |
@@ -262,6 +262,20 @@ async function sendItem(item) { |
262 | 262 | try { |
263 | 263 | const s = await getSettings(); |
264 | 264 | const encoding = s.encoding || 'utf-8'; |
| 265 | + // Echo into the MAIN window's debug view via a cross-window Tauri event |
| 266 | + // (CustomEvent cannot cross webview boundaries). Same semantics as the |
| 267 | + // send box: hex sends echo the actual bytes (no re-encoding). |
| 268 | + if (item.hex) { |
| 269 | + let echo = item.text; |
| 270 | + try { |
| 271 | + echo = bytesToHex(parseHexString(item.text)); |
| 272 | + } catch (e) { |
| 273 | + /* keep raw input as echo */ |
| 274 | + } |
| 275 | + emit('send-echo', { text: echo, isHex: true }).catch(() => {}); |
| 276 | + } else { |
| 277 | + emit('send-echo', { text: item.text }).catch(() => {}); |
| 278 | + } |
265 | 279 | await invoke('send_data_raw', { data: item.text, hexMode: item.hex, encoding }); |
266 | 280 | } catch (e) { |
267 | 281 | console.error('Multi send error:', e); |
|
0 commit comments