@google/gemini-cli 0.0.3-preview.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +310 -0
- package/dist/.last_build +0 -0
- package/dist/google-gemini-cli-0.3.0-preview.3.tgz +0 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/package.json +85 -0
- package/dist/src/commands/extensions/disable.d.ts +14 -0
- package/dist/src/commands/extensions/disable.js +42 -0
- package/dist/src/commands/extensions/disable.js.map +1 -0
- package/dist/src/commands/extensions/enable.d.ts +14 -0
- package/dist/src/commands/extensions/enable.js +48 -0
- package/dist/src/commands/extensions/enable.js.map +1 -0
- package/dist/src/commands/extensions/install.d.ts +13 -0
- package/dist/src/commands/extensions/install.js +48 -0
- package/dist/src/commands/extensions/install.js.map +1 -0
- package/dist/src/commands/extensions/install.test.d.ts +6 -0
- package/dist/src/commands/extensions/install.test.js +19 -0
- package/dist/src/commands/extensions/install.test.js.map +1 -0
- package/dist/src/commands/extensions/list.d.ts +8 -0
- package/dist/src/commands/extensions/list.js +32 -0
- package/dist/src/commands/extensions/list.js.map +1 -0
- package/dist/src/commands/extensions/uninstall.d.ts +12 -0
- package/dist/src/commands/extensions/uninstall.js +38 -0
- package/dist/src/commands/extensions/uninstall.js.map +1 -0
- package/dist/src/commands/extensions/uninstall.test.d.ts +6 -0
- package/dist/src/commands/extensions/uninstall.test.js +15 -0
- package/dist/src/commands/extensions/uninstall.test.js.map +1 -0
- package/dist/src/commands/extensions/update.d.ts +12 -0
- package/dist/src/commands/extensions/update.js +38 -0
- package/dist/src/commands/extensions/update.js.map +1 -0
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +29 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/mcp/add.d.ts +7 -0
- package/dist/src/commands/mcp/add.js +166 -0
- package/dist/src/commands/mcp/add.js.map +1 -0
- package/dist/src/commands/mcp/list.d.ts +8 -0
- package/dist/src/commands/mcp/list.js +110 -0
- package/dist/src/commands/mcp/list.js.map +1 -0
- package/dist/src/commands/mcp/remove.d.ts +7 -0
- package/dist/src/commands/mcp/remove.js +44 -0
- package/dist/src/commands/mcp/remove.js.map +1 -0
- package/dist/src/commands/mcp.d.ts +7 -0
- package/dist/src/commands/mcp.js +23 -0
- package/dist/src/commands/mcp.js.map +1 -0
- package/dist/src/config/auth.d.ts +6 -0
- package/dist/src/config/auth.js +34 -0
- package/dist/src/config/auth.js.map +1 -0
- package/dist/src/config/auth.test.d.ts +6 -0
- package/dist/src/config/auth.test.js +57 -0
- package/dist/src/config/auth.test.js.map +1 -0
- package/dist/src/config/config.d.ts +42 -0
- package/dist/src/config/config.js +446 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/extension.d.ts +59 -0
- package/dist/src/config/extension.js +372 -0
- package/dist/src/config/extension.js.map +1 -0
- package/dist/src/config/extensions/variableSchema.d.ts +28 -0
- package/dist/src/config/extensions/variableSchema.js +18 -0
- package/dist/src/config/extensions/variableSchema.js.map +1 -0
- package/dist/src/config/extensions/variables.d.ts +17 -0
- package/dist/src/config/extensions/variables.js +40 -0
- package/dist/src/config/extensions/variables.js.map +1 -0
- package/dist/src/config/extensions/variables.test.d.ts +6 -0
- package/dist/src/config/extensions/variables.test.js +17 -0
- package/dist/src/config/extensions/variables.test.js.map +1 -0
- package/dist/src/config/keyBindings.d.ts +66 -0
- package/dist/src/config/keyBindings.js +141 -0
- package/dist/src/config/keyBindings.js.map +1 -0
- package/dist/src/config/keyBindings.test.d.ts +6 -0
- package/dist/src/config/keyBindings.test.js +51 -0
- package/dist/src/config/keyBindings.test.js.map +1 -0
- package/dist/src/config/sandboxConfig.d.ts +13 -0
- package/dist/src/config/sandboxConfig.js +73 -0
- package/dist/src/config/sandboxConfig.js.map +1 -0
- package/dist/src/config/settings.d.ts +62 -0
- package/dist/src/config/settings.js +656 -0
- package/dist/src/config/settings.js.map +1 -0
- package/dist/src/config/settingsSchema.d.ts +750 -0
- package/dist/src/config/settingsSchema.js +723 -0
- package/dist/src/config/settingsSchema.js.map +1 -0
- package/dist/src/config/settingsSchema.test.d.ts +6 -0
- package/dist/src/config/settingsSchema.test.js +193 -0
- package/dist/src/config/settingsSchema.test.js.map +1 -0
- package/dist/src/config/trustedFolders.d.ts +37 -0
- package/dist/src/config/trustedFolders.js +118 -0
- package/dist/src/config/trustedFolders.js.map +1 -0
- package/dist/src/config/trustedFolders.test.d.ts +6 -0
- package/dist/src/config/trustedFolders.test.js +164 -0
- package/dist/src/config/trustedFolders.test.js.map +1 -0
- package/dist/src/gemini.d.ts +11 -0
- package/dist/src/gemini.js +289 -0
- package/dist/src/gemini.js.map +1 -0
- package/dist/src/gemini.test.d.ts +6 -0
- package/dist/src/gemini.test.js +247 -0
- package/dist/src/gemini.test.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +7 -0
- package/dist/src/generated/git-commit.js +10 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/nonInteractiveCli.d.ts +7 -0
- package/dist/src/nonInteractiveCli.js +92 -0
- package/dist/src/nonInteractiveCli.js.map +1 -0
- package/dist/src/patches/is-in-ci.d.ts +7 -0
- package/dist/src/patches/is-in-ci.js +15 -0
- package/dist/src/patches/is-in-ci.js.map +1 -0
- package/dist/src/services/BuiltinCommandLoader.d.ts +24 -0
- package/dist/src/services/BuiltinCommandLoader.js +82 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -0
- package/dist/src/services/BuiltinCommandLoader.test.d.ts +6 -0
- package/dist/src/services/BuiltinCommandLoader.test.js +108 -0
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -0
- package/dist/src/services/CommandService.d.ts +55 -0
- package/dist/src/services/CommandService.js +90 -0
- package/dist/src/services/CommandService.js.map +1 -0
- package/dist/src/services/CommandService.test.d.ts +6 -0
- package/dist/src/services/CommandService.test.js +233 -0
- package/dist/src/services/CommandService.test.js.map +1 -0
- package/dist/src/services/FileCommandLoader.d.ts +49 -0
- package/dist/src/services/FileCommandLoader.js +220 -0
- package/dist/src/services/FileCommandLoader.js.map +1 -0
- package/dist/src/services/McpPromptLoader.d.ts +35 -0
- package/dist/src/services/McpPromptLoader.js +218 -0
- package/dist/src/services/McpPromptLoader.js.map +1 -0
- package/dist/src/services/McpPromptLoader.test.d.ts +6 -0
- package/dist/src/services/McpPromptLoader.test.js +114 -0
- package/dist/src/services/McpPromptLoader.test.js.map +1 -0
- package/dist/src/services/prompt-processors/argumentProcessor.d.ts +16 -0
- package/dist/src/services/prompt-processors/argumentProcessor.js +21 -0
- package/dist/src/services/prompt-processors/argumentProcessor.js.map +1 -0
- package/dist/src/services/prompt-processors/atFileProcessor.d.ts +12 -0
- package/dist/src/services/prompt-processors/atFileProcessor.js +62 -0
- package/dist/src/services/prompt-processors/atFileProcessor.js.map +1 -0
- package/dist/src/services/prompt-processors/atFileProcessor.test.d.ts +6 -0
- package/dist/src/services/prompt-processors/atFileProcessor.test.js +174 -0
- package/dist/src/services/prompt-processors/atFileProcessor.test.js.map +1 -0
- package/dist/src/services/prompt-processors/injectionParser.d.ts +29 -0
- package/dist/src/services/prompt-processors/injectionParser.js +60 -0
- package/dist/src/services/prompt-processors/injectionParser.js.map +1 -0
- package/dist/src/services/prompt-processors/injectionParser.test.d.ts +6 -0
- package/dist/src/services/prompt-processors/injectionParser.test.js +189 -0
- package/dist/src/services/prompt-processors/injectionParser.test.js.map +1 -0
- package/dist/src/services/prompt-processors/shellProcessor.d.ts +27 -0
- package/dist/src/services/prompt-processors/shellProcessor.js +121 -0
- package/dist/src/services/prompt-processors/shellProcessor.js.map +1 -0
- package/dist/src/services/prompt-processors/types.d.ts +45 -0
- package/dist/src/services/prompt-processors/types.js +20 -0
- package/dist/src/services/prompt-processors/types.js.map +1 -0
- package/dist/src/services/types.d.ts +22 -0
- package/dist/src/services/types.js +7 -0
- package/dist/src/services/types.js.map +1 -0
- package/dist/src/test-utils/customMatchers.d.ts +14 -0
- package/dist/src/test-utils/customMatchers.js +40 -0
- package/dist/src/test-utils/customMatchers.js.map +1 -0
- package/dist/src/test-utils/mockCommandContext.d.ts +18 -0
- package/dist/src/test-utils/mockCommandContext.js +86 -0
- package/dist/src/test-utils/mockCommandContext.js.map +1 -0
- package/dist/src/test-utils/mockCommandContext.test.d.ts +6 -0
- package/dist/src/test-utils/mockCommandContext.test.js +51 -0
- package/dist/src/test-utils/mockCommandContext.test.js.map +1 -0
- package/dist/src/test-utils/render.d.ts +8 -0
- package/dist/src/test-utils/render.js +10 -0
- package/dist/src/test-utils/render.js.map +1 -0
- package/dist/src/ui/App.d.ts +15 -0
- package/dist/src/ui/App.js +676 -0
- package/dist/src/ui/App.js.map +1 -0
- package/dist/src/ui/IdeIntegrationNudge.d.ts +16 -0
- package/dist/src/ui/IdeIntegrationNudge.js +47 -0
- package/dist/src/ui/IdeIntegrationNudge.js.map +1 -0
- package/dist/src/ui/colors.d.ts +7 -0
- package/dist/src/ui/colors.js +54 -0
- package/dist/src/ui/colors.js.map +1 -0
- package/dist/src/ui/commands/aboutCommand.d.ts +7 -0
- package/dist/src/ui/commands/aboutCommand.js +43 -0
- package/dist/src/ui/commands/aboutCommand.js.map +1 -0
- package/dist/src/ui/commands/authCommand.d.ts +7 -0
- package/dist/src/ui/commands/authCommand.js +16 -0
- package/dist/src/ui/commands/authCommand.js.map +1 -0
- package/dist/src/ui/commands/bugCommand.d.ts +7 -0
- package/dist/src/ui/commands/bugCommand.js +71 -0
- package/dist/src/ui/commands/bugCommand.js.map +1 -0
- package/dist/src/ui/commands/chatCommand.d.ts +7 -0
- package/dist/src/ui/commands/chatCommand.js +235 -0
- package/dist/src/ui/commands/chatCommand.js.map +1 -0
- package/dist/src/ui/commands/clearCommand.d.ts +7 -0
- package/dist/src/ui/commands/clearCommand.js +27 -0
- package/dist/src/ui/commands/clearCommand.js.map +1 -0
- package/dist/src/ui/commands/compressCommand.d.ts +7 -0
- package/dist/src/ui/commands/compressCommand.js +66 -0
- package/dist/src/ui/commands/compressCommand.js.map +1 -0
- package/dist/src/ui/commands/copyCommand.d.ts +7 -0
- package/dist/src/ui/commands/copyCommand.js +59 -0
- package/dist/src/ui/commands/copyCommand.js.map +1 -0
- package/dist/src/ui/commands/corgiCommand.d.ts +7 -0
- package/dist/src/ui/commands/corgiCommand.js +15 -0
- package/dist/src/ui/commands/corgiCommand.js.map +1 -0
- package/dist/src/ui/commands/directoryCommand.d.ts +8 -0
- package/dist/src/ui/commands/directoryCommand.js +135 -0
- package/dist/src/ui/commands/directoryCommand.js.map +1 -0
- package/dist/src/ui/commands/docsCommand.d.ts +7 -0
- package/dist/src/ui/commands/docsCommand.js +31 -0
- package/dist/src/ui/commands/docsCommand.js.map +1 -0
- package/dist/src/ui/commands/editorCommand.d.ts +7 -0
- package/dist/src/ui/commands/editorCommand.js +16 -0
- package/dist/src/ui/commands/editorCommand.js.map +1 -0
- package/dist/src/ui/commands/extensionsCommand.d.ts +7 -0
- package/dist/src/ui/commands/extensionsCommand.js +31 -0
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -0
- package/dist/src/ui/commands/helpCommand.d.ts +7 -0
- package/dist/src/ui/commands/helpCommand.js +21 -0
- package/dist/src/ui/commands/helpCommand.js.map +1 -0
- package/dist/src/ui/commands/ideCommand.d.ts +8 -0
- package/dist/src/ui/commands/ideCommand.js +216 -0
- package/dist/src/ui/commands/ideCommand.js.map +1 -0
- package/dist/src/ui/commands/initCommand.d.ts +7 -0
- package/dist/src/ui/commands/initCommand.js +76 -0
- package/dist/src/ui/commands/initCommand.js.map +1 -0
- package/dist/src/ui/commands/mcpCommand.d.ts +7 -0
- package/dist/src/ui/commands/mcpCommand.js +424 -0
- package/dist/src/ui/commands/mcpCommand.js.map +1 -0
- package/dist/src/ui/commands/memoryCommand.d.ts +7 -0
- package/dist/src/ui/commands/memoryCommand.js +92 -0
- package/dist/src/ui/commands/memoryCommand.js.map +1 -0
- package/dist/src/ui/commands/privacyCommand.d.ts +7 -0
- package/dist/src/ui/commands/privacyCommand.js +16 -0
- package/dist/src/ui/commands/privacyCommand.js.map +1 -0
- package/dist/src/ui/commands/quitCommand.d.ts +7 -0
- package/dist/src/ui/commands/quitCommand.js +34 -0
- package/dist/src/ui/commands/quitCommand.js.map +1 -0
- package/dist/src/ui/commands/restoreCommand.d.ts +8 -0
- package/dist/src/ui/commands/restoreCommand.js +124 -0
- package/dist/src/ui/commands/restoreCommand.js.map +1 -0
- package/dist/src/ui/commands/settingsCommand.d.ts +7 -0
- package/dist/src/ui/commands/settingsCommand.js +16 -0
- package/dist/src/ui/commands/settingsCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.d.ts +9 -0
- package/dist/src/ui/commands/setupGithubCommand.js +154 -0
- package/dist/src/ui/commands/setupGithubCommand.js.map +1 -0
- package/dist/src/ui/commands/setupGithubCommand.test.d.ts +6 -0
- package/dist/src/ui/commands/setupGithubCommand.test.js +167 -0
- package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -0
- package/dist/src/ui/commands/statsCommand.d.ts +7 -0
- package/dist/src/ui/commands/statsCommand.js +54 -0
- package/dist/src/ui/commands/statsCommand.js.map +1 -0
- package/dist/src/ui/commands/terminalSetupCommand.d.ts +13 -0
- package/dist/src/ui/commands/terminalSetupCommand.js +41 -0
- package/dist/src/ui/commands/terminalSetupCommand.js.map +1 -0
- package/dist/src/ui/commands/themeCommand.d.ts +7 -0
- package/dist/src/ui/commands/themeCommand.js +16 -0
- package/dist/src/ui/commands/themeCommand.js.map +1 -0
- package/dist/src/ui/commands/toolsCommand.d.ts +7 -0
- package/dist/src/ui/commands/toolsCommand.js +56 -0
- package/dist/src/ui/commands/toolsCommand.js.map +1 -0
- package/dist/src/ui/commands/types.d.ts +148 -0
- package/dist/src/ui/commands/types.js +13 -0
- package/dist/src/ui/commands/types.js.map +1 -0
- package/dist/src/ui/commands/vimCommand.d.ts +7 -0
- package/dist/src/ui/commands/vimCommand.js +23 -0
- package/dist/src/ui/commands/vimCommand.js.map +1 -0
- package/dist/src/ui/components/AboutBox.d.ts +17 -0
- package/dist/src/ui/components/AboutBox.js +6 -0
- package/dist/src/ui/components/AboutBox.js.map +1 -0
- package/dist/src/ui/components/AsciiArt.d.ts +8 -0
- package/dist/src/ui/components/AsciiArt.js +36 -0
- package/dist/src/ui/components/AsciiArt.js.map +1 -0
- package/dist/src/ui/components/AuthDialog.d.ts +16 -0
- package/dist/src/ui/components/AuthDialog.js +92 -0
- package/dist/src/ui/components/AuthDialog.js.map +1 -0
- package/dist/src/ui/components/AuthDialog.test.d.ts +6 -0
- package/dist/src/ui/components/AuthDialog.test.js +276 -0
- package/dist/src/ui/components/AuthDialog.test.js.map +1 -0
- package/dist/src/ui/components/AuthInProgress.d.ts +11 -0
- package/dist/src/ui/components/AuthInProgress.js +23 -0
- package/dist/src/ui/components/AuthInProgress.js.map +1 -0
- package/dist/src/ui/components/AutoAcceptIndicator.d.ts +12 -0
- package/dist/src/ui/components/AutoAcceptIndicator.js +26 -0
- package/dist/src/ui/components/AutoAcceptIndicator.js.map +1 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.d.ts +11 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.js +11 -0
- package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/ContextSummaryDisplay.d.ts +20 -0
- package/dist/src/ui/components/ContextSummaryDisplay.js +66 -0
- package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +9 -0
- package/dist/src/ui/components/ContextUsageDisplay.js +14 -0
- package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -0
- package/dist/src/ui/components/DebugProfiler.d.ts +6 -0
- package/dist/src/ui/components/DebugProfiler.js +27 -0
- package/dist/src/ui/components/DebugProfiler.js.map +1 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.d.ts +14 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.js +34 -0
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -0
- package/dist/src/ui/components/EditorSettingsDialog.d.ts +16 -0
- package/dist/src/ui/components/EditorSettingsDialog.js +71 -0
- package/dist/src/ui/components/EditorSettingsDialog.js.map +1 -0
- package/dist/src/ui/components/FolderTrustDialog.d.ts +17 -0
- package/dist/src/ui/components/FolderTrustDialog.js +45 -0
- package/dist/src/ui/components/FolderTrustDialog.js.map +1 -0
- package/dist/src/ui/components/FolderTrustDialog.test.d.ts +6 -0
- package/dist/src/ui/components/FolderTrustDialog.test.js +63 -0
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -0
- package/dist/src/ui/components/Footer.d.ts +23 -0
- package/dist/src/ui/components/Footer.js +25 -0
- package/dist/src/ui/components/Footer.js.map +1 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.d.ts +17 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.js +18 -0
- package/dist/src/ui/components/GeminiRespondingSpinner.js.map +1 -0
- package/dist/src/ui/components/Header.d.ts +13 -0
- package/dist/src/ui/components/Header.js +28 -0
- package/dist/src/ui/components/Header.js.map +1 -0
- package/dist/src/ui/components/Header.test.d.ts +6 -0
- package/dist/src/ui/components/Header.test.js +37 -0
- package/dist/src/ui/components/Header.test.js.map +1 -0
- package/dist/src/ui/components/Help.d.ts +12 -0
- package/dist/src/ui/components/Help.js +10 -0
- package/dist/src/ui/components/Help.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.d.ts +20 -0
- package/dist/src/ui/components/HistoryItemDisplay.js +18 -0
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js +93 -0
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.d.ts +28 -0
- package/dist/src/ui/components/InputPrompt.js +562 -0
- package/dist/src/ui/components/InputPrompt.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.d.ts +15 -0
- package/dist/src/ui/components/LoadingIndicator.js +25 -0
- package/dist/src/ui/components/LoadingIndicator.js.map +1 -0
- package/dist/src/ui/components/LoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/components/LoadingIndicator.test.js +190 -0
- package/dist/src/ui/components/LoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/components/MemoryUsageDisplay.d.ts +7 -0
- package/dist/src/ui/components/MemoryUsageDisplay.js +22 -0
- package/dist/src/ui/components/MemoryUsageDisplay.js.map +1 -0
- package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
- package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/PrepareLabel.d.ts +15 -0
- package/dist/src/ui/components/PrepareLabel.js +16 -0
- package/dist/src/ui/components/PrepareLabel.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.d.ts +11 -0
- package/dist/src/ui/components/SessionSummaryDisplay.js +4 -0
- package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.d.ts +15 -0
- package/dist/src/ui/components/SettingsDialog.js +550 -0
- package/dist/src/ui/components/SettingsDialog.js.map +1 -0
- package/dist/src/ui/components/SettingsDialog.test.d.ts +6 -0
- package/dist/src/ui/components/SettingsDialog.test.js +646 -0
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -0
- package/dist/src/ui/components/ShellConfirmationDialog.d.ts +15 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js +46 -0
- package/dist/src/ui/components/ShellConfirmationDialog.js.map +1 -0
- package/dist/src/ui/components/ShellConfirmationDialog.test.d.ts +6 -0
- package/dist/src/ui/components/ShellConfirmationDialog.test.js +40 -0
- package/dist/src/ui/components/ShellConfirmationDialog.test.js.map +1 -0
- package/dist/src/ui/components/ShellModeIndicator.d.ts +7 -0
- package/dist/src/ui/components/ShellModeIndicator.js +5 -0
- package/dist/src/ui/components/ShellModeIndicator.js.map +1 -0
- package/dist/src/ui/components/ShowMoreLines.d.ts +10 -0
- package/dist/src/ui/components/ShowMoreLines.js +24 -0
- package/dist/src/ui/components/ShowMoreLines.js.map +1 -0
- package/dist/src/ui/components/StatsDisplay.d.ts +12 -0
- package/dist/src/ui/components/StatsDisplay.js +43 -0
- package/dist/src/ui/components/StatsDisplay.js.map +1 -0
- package/dist/src/ui/components/SuggestionsDisplay.d.ts +22 -0
- package/dist/src/ui/components/SuggestionsDisplay.js +40 -0
- package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -0
- package/dist/src/ui/components/ThemeDialog.d.ts +20 -0
- package/dist/src/ui/components/ThemeDialog.js +138 -0
- package/dist/src/ui/components/ThemeDialog.js.map +1 -0
- package/dist/src/ui/components/Tips.d.ts +12 -0
- package/dist/src/ui/components/Tips.js +9 -0
- package/dist/src/ui/components/Tips.js.map +1 -0
- package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
- package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/UpdateNotification.d.ts +10 -0
- package/dist/src/ui/components/UpdateNotification.js +10 -0
- package/dist/src/ui/components/UpdateNotification.js.map +1 -0
- package/dist/src/ui/components/WorkspaceMigrationDialog.d.ts +11 -0
- package/dist/src/ui/components/WorkspaceMigrationDialog.js +42 -0
- package/dist/src/ui/components/WorkspaceMigrationDialog.js.map +1 -0
- package/dist/src/ui/components/messages/CompressionMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/CompressionMessage.js +17 -0
- package/dist/src/ui/components/messages/CompressionMessage.js.map +1 -0
- package/dist/src/ui/components/messages/DiffRenderer.d.ts +16 -0
- package/dist/src/ui/components/messages/DiffRenderer.js +226 -0
- package/dist/src/ui/components/messages/DiffRenderer.js.map +1 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +6 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js +239 -0
- package/dist/src/ui/components/messages/DiffRenderer.test.js.map +1 -0
- package/dist/src/ui/components/messages/ErrorMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/ErrorMessage.js +9 -0
- package/dist/src/ui/components/messages/ErrorMessage.js.map +1 -0
- package/dist/src/ui/components/messages/GeminiMessage.d.ts +14 -0
- package/dist/src/ui/components/messages/GeminiMessage.js +11 -0
- package/dist/src/ui/components/messages/GeminiMessage.js.map +1 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.d.ts +14 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.js +15 -0
- package/dist/src/ui/components/messages/GeminiMessageContent.js.map +1 -0
- package/dist/src/ui/components/messages/InfoMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/InfoMessage.js +10 -0
- package/dist/src/ui/components/messages/InfoMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.d.ts +15 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js +162 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +122 -0
- package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.d.ts +18 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js +50 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js +259 -0
- package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.d.ts +15 -0
- package/dist/src/ui/components/messages/ToolMessage.js +62 -0
- package/dist/src/ui/components/messages/ToolMessage.js.map +1 -0
- package/dist/src/ui/components/messages/ToolMessage.test.d.ts +6 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js +118 -0
- package/dist/src/ui/components/messages/ToolMessage.test.js.map +1 -0
- package/dist/src/ui/components/messages/UserMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/UserMessage.js +14 -0
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -0
- package/dist/src/ui/components/messages/UserShellMessage.d.ts +11 -0
- package/dist/src/ui/components/messages/UserShellMessage.js +9 -0
- package/dist/src/ui/components/messages/UserShellMessage.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.d.ts +61 -0
- package/dist/src/ui/components/shared/MaxSizedBox.js +451 -0
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +6 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +154 -0
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.d.ts +46 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js +116 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.js.map +1 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +6 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js +111 -0
- package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +1 -0
- package/dist/src/ui/components/shared/text-buffer.d.ts +467 -0
- package/dist/src/ui/components/shared/text-buffer.js +1489 -0
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +72 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.js +552 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -0
- package/dist/src/ui/constants.d.ts +17 -0
- package/dist/src/ui/constants.js +22 -0
- package/dist/src/ui/constants.js.map +1 -0
- package/dist/src/ui/contexts/KeypressContext.d.ts +31 -0
- package/dist/src/ui/contexts/KeypressContext.js +318 -0
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -0
- package/dist/src/ui/contexts/KeypressContext.test.d.ts +6 -0
- package/dist/src/ui/contexts/KeypressContext.test.js +385 -0
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -0
- package/dist/src/ui/contexts/OverflowContext.d.ts +19 -0
- package/dist/src/ui/contexts/OverflowContext.js +38 -0
- package/dist/src/ui/contexts/OverflowContext.js.map +1 -0
- package/dist/src/ui/contexts/SessionContext.d.ts +39 -0
- package/dist/src/ui/contexts/SessionContext.js +55 -0
- package/dist/src/ui/contexts/SessionContext.js.map +1 -0
- package/dist/src/ui/contexts/SettingsContext.d.ts +9 -0
- package/dist/src/ui/contexts/SettingsContext.js +15 -0
- package/dist/src/ui/contexts/SettingsContext.js.map +1 -0
- package/dist/src/ui/contexts/StreamingContext.d.ts +9 -0
- package/dist/src/ui/contexts/StreamingContext.js +15 -0
- package/dist/src/ui/contexts/StreamingContext.js.map +1 -0
- package/dist/src/ui/contexts/VimModeContext.d.ts +19 -0
- package/dist/src/ui/contexts/VimModeContext.js +48 -0
- package/dist/src/ui/contexts/VimModeContext.js.map +1 -0
- package/dist/src/ui/editors/editorSettingsManager.d.ts +19 -0
- package/dist/src/ui/editors/editorSettingsManager.js +47 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -0
- package/dist/src/ui/hooks/atCommandProcessor.d.ts +31 -0
- package/dist/src/ui/hooks/atCommandProcessor.js +364 -0
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +6 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js +832 -0
- package/dist/src/ui/hooks/atCommandProcessor.test.js.map +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.d.ts +17 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js +234 -0
- package/dist/src/ui/hooks/shellCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +6 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +325 -0
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -0
- package/dist/src/ui/hooks/slashCommandProcessor.d.ts +29 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js +443 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -0
- package/dist/src/ui/hooks/useAtCompletion.d.ts +23 -0
- package/dist/src/ui/hooks/useAtCompletion.js +179 -0
- package/dist/src/ui/hooks/useAtCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useAuthCommand.d.ts +14 -0
- package/dist/src/ui/hooks/useAuthCommand.js +66 -0
- package/dist/src/ui/hooks/useAuthCommand.js.map +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.d.ts +12 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js +46 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.js.map +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.d.ts +6 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +311 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -0
- package/dist/src/ui/hooks/useBracketedPaste.d.ts +12 -0
- package/dist/src/ui/hooks/useBracketedPaste.js +32 -0
- package/dist/src/ui/hooks/useBracketedPaste.js.map +1 -0
- package/dist/src/ui/hooks/useCommandCompletion.d.ts +32 -0
- package/dist/src/ui/hooks/useCommandCompletion.js +186 -0
- package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useCompletion.d.ts +24 -0
- package/dist/src/ui/hooks/useCompletion.js +88 -0
- package/dist/src/ui/hooks/useCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useConsoleMessages.d.ts +12 -0
- package/dist/src/ui/hooks/useConsoleMessages.js +76 -0
- package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -0
- package/dist/src/ui/hooks/useEditorSettings.d.ts +16 -0
- package/dist/src/ui/hooks/useEditorSettings.js +43 -0
- package/dist/src/ui/hooks/useEditorSettings.js.map +1 -0
- package/dist/src/ui/hooks/useEditorSettings.test.d.ts +6 -0
- package/dist/src/ui/hooks/useEditorSettings.test.js +164 -0
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -0
- package/dist/src/ui/hooks/useFocus.d.ts +10 -0
- package/dist/src/ui/hooks/useFocus.js +41 -0
- package/dist/src/ui/hooks/useFocus.js.map +1 -0
- package/dist/src/ui/hooks/useFolderTrust.d.ts +13 -0
- package/dist/src/ui/hooks/useFolderTrust.js +64 -0
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -0
- package/dist/src/ui/hooks/useGeminiStream.d.ts +24 -0
- package/dist/src/ui/hooks/useGeminiStream.js +634 -0
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -0
- package/dist/src/ui/hooks/useGitBranchName.d.ts +6 -0
- package/dist/src/ui/hooks/useGitBranchName.js +61 -0
- package/dist/src/ui/hooks/useGitBranchName.js.map +1 -0
- package/dist/src/ui/hooks/useGitBranchName.test.d.ts +6 -0
- package/dist/src/ui/hooks/useGitBranchName.test.js +175 -0
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -0
- package/dist/src/ui/hooks/useHistoryManager.d.ts +22 -0
- package/dist/src/ui/hooks/useHistoryManager.js +72 -0
- package/dist/src/ui/hooks/useHistoryManager.js.map +1 -0
- package/dist/src/ui/hooks/useHistoryManager.test.d.ts +6 -0
- package/dist/src/ui/hooks/useHistoryManager.test.js +171 -0
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -0
- package/dist/src/ui/hooks/useInputHistory.d.ts +19 -0
- package/dist/src/ui/hooks/useInputHistory.js +84 -0
- package/dist/src/ui/hooks/useInputHistory.js.map +1 -0
- package/dist/src/ui/hooks/useInputHistory.test.d.ts +6 -0
- package/dist/src/ui/hooks/useInputHistory.test.js +207 -0
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -0
- package/dist/src/ui/hooks/useKeypress.d.ts +17 -0
- package/dist/src/ui/hooks/useKeypress.js +27 -0
- package/dist/src/ui/hooks/useKeypress.js.map +1 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.d.ts +15 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js +20 -0
- package/dist/src/ui/hooks/useKittyKeyboardProtocol.js.map +1 -0
- package/dist/src/ui/hooks/useLoadingIndicator.d.ts +10 -0
- package/dist/src/ui/hooks/useLoadingIndicator.js +44 -0
- package/dist/src/ui/hooks/useLoadingIndicator.js.map +1 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +6 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +91 -0
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -0
- package/dist/src/ui/hooks/useLogger.d.ts +11 -0
- package/dist/src/ui/hooks/useLogger.js +29 -0
- package/dist/src/ui/hooks/useLogger.js.map +1 -0
- package/dist/src/ui/hooks/useMessageQueue.d.ts +22 -0
- package/dist/src/ui/hooks/useMessageQueue.js +49 -0
- package/dist/src/ui/hooks/useMessageQueue.js.map +1 -0
- package/dist/src/ui/hooks/useMessageQueue.test.d.ts +6 -0
- package/dist/src/ui/hooks/useMessageQueue.test.js +158 -0
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.d.ts +14 -0
- package/dist/src/ui/hooks/usePhraseCycler.js +187 -0
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -0
- package/dist/src/ui/hooks/usePrivacySettings.d.ts +16 -0
- package/dist/src/ui/hooks/usePrivacySettings.js +119 -0
- package/dist/src/ui/hooks/usePrivacySettings.js.map +1 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +6 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.js +154 -0
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -0
- package/dist/src/ui/hooks/usePromptCompletion.d.ts +23 -0
- package/dist/src/ui/hooks/usePromptCompletion.js +177 -0
- package/dist/src/ui/hooks/usePromptCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +33 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js +186 -0
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.d.ts +6 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.js +7 -0
- package/dist/src/ui/hooks/useRefreshMemoryCommand.js.map +1 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.d.ts +19 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js +56 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +163 -0
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useSettingsCommand.d.ts +10 -0
- package/dist/src/ui/hooks/useSettingsCommand.js +21 -0
- package/dist/src/ui/hooks/useSettingsCommand.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.d.ts +14 -0
- package/dist/src/ui/hooks/useShellHistory.js +111 -0
- package/dist/src/ui/hooks/useShellHistory.js.map +1 -0
- package/dist/src/ui/hooks/useShellHistory.test.d.ts +6 -0
- package/dist/src/ui/hooks/useShellHistory.test.js +187 -0
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.d.ts +9 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.js +58 -0
- package/dist/src/ui/hooks/useShowMemoryCommand.js.map +1 -0
- package/dist/src/ui/hooks/useSlashCompletion.d.ts +20 -0
- package/dist/src/ui/hooks/useSlashCompletion.js +135 -0
- package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +6 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.js +272 -0
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -0
- package/dist/src/ui/hooks/useStateAndRef.d.ts +7 -0
- package/dist/src/ui/hooks/useStateAndRef.js +26 -0
- package/dist/src/ui/hooks/useStateAndRef.js.map +1 -0
- package/dist/src/ui/hooks/useTerminalSize.d.ts +9 -0
- package/dist/src/ui/hooks/useTerminalSize.js +27 -0
- package/dist/src/ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/ui/hooks/useThemeCommand.d.ts +15 -0
- package/dist/src/ui/hooks/useThemeCommand.js +79 -0
- package/dist/src/ui/hooks/useThemeCommand.js.map +1 -0
- package/dist/src/ui/hooks/useTimer.d.ts +12 -0
- package/dist/src/ui/hooks/useTimer.js +58 -0
- package/dist/src/ui/hooks/useTimer.js.map +1 -0
- package/dist/src/ui/hooks/useTimer.test.d.ts +6 -0
- package/dist/src/ui/hooks/useTimer.test.js +90 -0
- package/dist/src/ui/hooks/useTimer.test.js.map +1 -0
- package/dist/src/ui/hooks/useToolScheduler.test.d.ts +6 -0
- package/dist/src/ui/hooks/useToolScheduler.test.js +850 -0
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -0
- package/dist/src/ui/hooks/useWorkspaceMigration.d.ts +13 -0
- package/dist/src/ui/hooks/useWorkspaceMigration.js +53 -0
- package/dist/src/ui/hooks/useWorkspaceMigration.js.map +1 -0
- package/dist/src/ui/hooks/vim.d.ts +28 -0
- package/dist/src/ui/hooks/vim.js +639 -0
- package/dist/src/ui/hooks/vim.js.map +1 -0
- package/dist/src/ui/keyMatchers.d.ts +27 -0
- package/dist/src/ui/keyMatchers.js +68 -0
- package/dist/src/ui/keyMatchers.js.map +1 -0
- package/dist/src/ui/keyMatchers.test.d.ts +6 -0
- package/dist/src/ui/keyMatchers.test.js +276 -0
- package/dist/src/ui/keyMatchers.test.js.map +1 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.d.ts +12 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +41 -0
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.d.ts +10 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js +18 -0
- package/dist/src/ui/privacy/CloudPaidPrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.d.ts +10 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js +18 -0
- package/dist/src/ui/privacy/GeminiPrivacyNotice.js.map +1 -0
- package/dist/src/ui/privacy/PrivacyNotice.d.ts +12 -0
- package/dist/src/ui/privacy/PrivacyNotice.js +25 -0
- package/dist/src/ui/privacy/PrivacyNotice.js.map +1 -0
- package/dist/src/ui/semantic-colors.d.ts +7 -0
- package/dist/src/ui/semantic-colors.js +24 -0
- package/dist/src/ui/semantic-colors.js.map +1 -0
- package/dist/src/ui/textConstants.d.ts +9 -0
- package/dist/src/ui/textConstants.js +10 -0
- package/dist/src/ui/textConstants.js.map +1 -0
- package/dist/src/ui/themes/ansi-light.d.ts +7 -0
- package/dist/src/ui/themes/ansi-light.js +142 -0
- package/dist/src/ui/themes/ansi-light.js.map +1 -0
- package/dist/src/ui/themes/ansi.d.ts +7 -0
- package/dist/src/ui/themes/ansi.js +152 -0
- package/dist/src/ui/themes/ansi.js.map +1 -0
- package/dist/src/ui/themes/atom-one-dark.d.ts +7 -0
- package/dist/src/ui/themes/atom-one-dark.js +138 -0
- package/dist/src/ui/themes/atom-one-dark.js.map +1 -0
- package/dist/src/ui/themes/ayu-light.d.ts +7 -0
- package/dist/src/ui/themes/ayu-light.js +130 -0
- package/dist/src/ui/themes/ayu-light.js.map +1 -0
- package/dist/src/ui/themes/ayu.d.ts +7 -0
- package/dist/src/ui/themes/ayu.js +104 -0
- package/dist/src/ui/themes/ayu.js.map +1 -0
- package/dist/src/ui/themes/color-utils.d.ts +21 -0
- package/dist/src/ui/themes/color-utils.js +221 -0
- package/dist/src/ui/themes/color-utils.js.map +1 -0
- package/dist/src/ui/themes/color-utils.test.d.ts +6 -0
- package/dist/src/ui/themes/color-utils.test.js +197 -0
- package/dist/src/ui/themes/color-utils.test.js.map +1 -0
- package/dist/src/ui/themes/default-light.d.ts +7 -0
- package/dist/src/ui/themes/default-light.js +100 -0
- package/dist/src/ui/themes/default-light.js.map +1 -0
- package/dist/src/ui/themes/default.d.ts +7 -0
- package/dist/src/ui/themes/default.js +143 -0
- package/dist/src/ui/themes/default.js.map +1 -0
- package/dist/src/ui/themes/dracula.d.ts +7 -0
- package/dist/src/ui/themes/dracula.js +115 -0
- package/dist/src/ui/themes/dracula.js.map +1 -0
- package/dist/src/ui/themes/github-dark.d.ts +7 -0
- package/dist/src/ui/themes/github-dark.js +138 -0
- package/dist/src/ui/themes/github-dark.js.map +1 -0
- package/dist/src/ui/themes/github-light.d.ts +7 -0
- package/dist/src/ui/themes/github-light.js +140 -0
- package/dist/src/ui/themes/github-light.js.map +1 -0
- package/dist/src/ui/themes/googlecode.d.ts +7 -0
- package/dist/src/ui/themes/googlecode.js +137 -0
- package/dist/src/ui/themes/googlecode.js.map +1 -0
- package/dist/src/ui/themes/no-color.d.ts +7 -0
- package/dist/src/ui/themes/no-color.js +115 -0
- package/dist/src/ui/themes/no-color.js.map +1 -0
- package/dist/src/ui/themes/semantic-tokens.d.ts +37 -0
- package/dist/src/ui/themes/semantic-tokens.js +94 -0
- package/dist/src/ui/themes/semantic-tokens.js.map +1 -0
- package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
- package/dist/src/ui/themes/shades-of-purple.js +304 -0
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
- package/dist/src/ui/themes/theme-manager.d.ts +66 -0
- package/dist/src/ui/themes/theme-manager.js +262 -0
- package/dist/src/ui/themes/theme-manager.js.map +1 -0
- package/dist/src/ui/themes/theme-manager.test.d.ts +6 -0
- package/dist/src/ui/themes/theme-manager.test.js +142 -0
- package/dist/src/ui/themes/theme-manager.test.js.map +1 -0
- package/dist/src/ui/themes/theme.d.ts +130 -0
- package/dist/src/ui/themes/theme.js +379 -0
- package/dist/src/ui/themes/theme.js.map +1 -0
- package/dist/src/ui/themes/xcode.d.ts +7 -0
- package/dist/src/ui/themes/xcode.js +145 -0
- package/dist/src/ui/themes/xcode.js.map +1 -0
- package/dist/src/ui/types.d.ts +193 -0
- package/dist/src/ui/types.js +44 -0
- package/dist/src/ui/types.js.map +1 -0
- package/dist/src/ui/utils/CodeColorizer.d.ts +17 -0
- package/dist/src/ui/utils/CodeColorizer.js +110 -0
- package/dist/src/ui/utils/CodeColorizer.js.map +1 -0
- package/dist/src/ui/utils/ConsolePatcher.d.ts +25 -0
- package/dist/src/ui/utils/ConsolePatcher.js +52 -0
- package/dist/src/ui/utils/ConsolePatcher.js.map +1 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +16 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js +111 -0
- package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.d.ts +14 -0
- package/dist/src/ui/utils/MarkdownDisplay.js +208 -0
- package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +6 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js +152 -0
- package/dist/src/ui/utils/MarkdownDisplay.test.js.map +1 -0
- package/dist/src/ui/utils/TableRenderer.d.ts +17 -0
- package/dist/src/ui/utils/TableRenderer.js +84 -0
- package/dist/src/ui/utils/TableRenderer.js.map +1 -0
- package/dist/src/ui/utils/clipboardUtils.d.ts +22 -0
- package/dist/src/ui/utils/clipboardUtils.js +127 -0
- package/dist/src/ui/utils/clipboardUtils.js.map +1 -0
- package/dist/src/ui/utils/clipboardUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/clipboardUtils.test.js +65 -0
- package/dist/src/ui/utils/clipboardUtils.test.js.map +1 -0
- package/dist/src/ui/utils/commandUtils.d.ts +24 -0
- package/dist/src/ui/utils/commandUtils.js +131 -0
- package/dist/src/ui/utils/commandUtils.js.map +1 -0
- package/dist/src/ui/utils/commandUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/commandUtils.test.js +349 -0
- package/dist/src/ui/utils/commandUtils.test.js.map +1 -0
- package/dist/src/ui/utils/computeStats.d.ts +10 -0
- package/dist/src/ui/utils/computeStats.js +57 -0
- package/dist/src/ui/utils/computeStats.js.map +1 -0
- package/dist/src/ui/utils/displayUtils.d.ts +17 -0
- package/dist/src/ui/utils/displayUtils.js +24 -0
- package/dist/src/ui/utils/displayUtils.js.map +1 -0
- package/dist/src/ui/utils/displayUtils.test.d.ts +6 -0
- package/dist/src/ui/utils/displayUtils.test.js +42 -0
- package/dist/src/ui/utils/displayUtils.test.js.map +1 -0
- package/dist/src/ui/utils/formatters.d.ts +13 -0
- package/dist/src/ui/utils/formatters.js +56 -0
- package/dist/src/ui/utils/formatters.js.map +1 -0
- package/dist/src/ui/utils/formatters.test.d.ts +6 -0
- package/dist/src/ui/utils/formatters.test.js +56 -0
- package/dist/src/ui/utils/formatters.test.js.map +1 -0
- package/dist/src/ui/utils/isNarrowWidth.d.ts +6 -0
- package/dist/src/ui/utils/isNarrowWidth.js +9 -0
- package/dist/src/ui/utils/isNarrowWidth.js.map +1 -0
- package/dist/src/ui/utils/kittyProtocolDetector.d.ts +13 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js +88 -0
- package/dist/src/ui/utils/kittyProtocolDetector.js.map +1 -0
- package/dist/src/ui/utils/markdownUtilities.d.ts +6 -0
- package/dist/src/ui/utils/markdownUtilities.js +110 -0
- package/dist/src/ui/utils/markdownUtilities.js.map +1 -0
- package/dist/src/ui/utils/markdownUtilities.test.d.ts +6 -0
- package/dist/src/ui/utils/markdownUtilities.test.js +42 -0
- package/dist/src/ui/utils/markdownUtilities.test.js.map +1 -0
- package/dist/src/ui/utils/platformConstants.d.ts +52 -0
- package/dist/src/ui/utils/platformConstants.js +53 -0
- package/dist/src/ui/utils/platformConstants.js.map +1 -0
- package/dist/src/ui/utils/terminalSetup.d.ts +30 -0
- package/dist/src/ui/utils/terminalSetup.js +281 -0
- package/dist/src/ui/utils/terminalSetup.js.map +1 -0
- package/dist/src/ui/utils/textUtils.d.ts +32 -0
- package/dist/src/ui/utils/textUtils.js +80 -0
- package/dist/src/ui/utils/textUtils.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +12 -0
- package/dist/src/ui/utils/updateCheck.js +78 -0
- package/dist/src/ui/utils/updateCheck.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.test.d.ts +6 -0
- package/dist/src/ui/utils/updateCheck.test.js +145 -0
- package/dist/src/ui/utils/updateCheck.test.js.map +1 -0
- package/dist/src/utils/checks.d.ts +19 -0
- package/dist/src/utils/checks.js +24 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/utils/cleanup.d.ts +8 -0
- package/dist/src/utils/cleanup.js +35 -0
- package/dist/src/utils/cleanup.js.map +1 -0
- package/dist/src/utils/dialogScopeUtils.d.ts +32 -0
- package/dist/src/utils/dialogScopeUtils.js +48 -0
- package/dist/src/utils/dialogScopeUtils.js.map +1 -0
- package/dist/src/utils/errors.d.ts +6 -0
- package/dist/src/utils/errors.js +12 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/events.d.ts +11 -0
- package/dist/src/utils/events.js +13 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +30 -0
- package/dist/src/utils/gitUtils.js +89 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/gitUtils.test.d.ts +6 -0
- package/dist/src/utils/gitUtils.test.js +113 -0
- package/dist/src/utils/gitUtils.test.js.map +1 -0
- package/dist/src/utils/handleAutoUpdate.d.ts +11 -0
- package/dist/src/utils/handleAutoUpdate.js +102 -0
- package/dist/src/utils/handleAutoUpdate.js.map +1 -0
- package/dist/src/utils/installationInfo.d.ts +23 -0
- package/dist/src/utils/installationInfo.js +154 -0
- package/dist/src/utils/installationInfo.js.map +1 -0
- package/dist/src/utils/installationInfo.test.d.ts +6 -0
- package/dist/src/utils/installationInfo.test.js +242 -0
- package/dist/src/utils/installationInfo.test.js.map +1 -0
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +24 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/readStdin.d.ts +6 -0
- package/dist/src/utils/readStdin.js +59 -0
- package/dist/src/utils/readStdin.js.map +1 -0
- package/dist/src/utils/readStdin.test.d.ts +6 -0
- package/dist/src/utils/readStdin.test.js +88 -0
- package/dist/src/utils/readStdin.test.js.map +1 -0
- package/dist/src/utils/resolvePath.d.ts +6 -0
- package/dist/src/utils/resolvePath.js +21 -0
- package/dist/src/utils/resolvePath.js.map +1 -0
- package/dist/src/utils/sandbox-macos-permissive-closed.sb +32 -0
- package/dist/src/utils/sandbox-macos-permissive-open.sb +25 -0
- package/dist/src/utils/sandbox-macos-permissive-proxied.sb +37 -0
- package/dist/src/utils/sandbox-macos-restrictive-closed.sb +93 -0
- package/dist/src/utils/sandbox-macos-restrictive-open.sb +96 -0
- package/dist/src/utils/sandbox-macos-restrictive-proxied.sb +98 -0
- package/dist/src/utils/sandbox.d.ts +7 -0
- package/dist/src/utils/sandbox.js +724 -0
- package/dist/src/utils/sandbox.js.map +1 -0
- package/dist/src/utils/settingsUtils.d.ts +134 -0
- package/dist/src/utils/settingsUtils.js +330 -0
- package/dist/src/utils/settingsUtils.js.map +1 -0
- package/dist/src/utils/settingsUtils.test.d.ts +6 -0
- package/dist/src/utils/settingsUtils.test.js +511 -0
- package/dist/src/utils/settingsUtils.test.js.map +1 -0
- package/dist/src/utils/spawnWrapper.d.ts +7 -0
- package/dist/src/utils/spawnWrapper.js +8 -0
- package/dist/src/utils/spawnWrapper.js.map +1 -0
- package/dist/src/utils/startupWarnings.d.ts +6 -0
- package/dist/src/utils/startupWarnings.js +40 -0
- package/dist/src/utils/startupWarnings.js.map +1 -0
- package/dist/src/utils/updateEventEmitter.d.ts +11 -0
- package/dist/src/utils/updateEventEmitter.js +12 -0
- package/dist/src/utils/updateEventEmitter.js.map +1 -0
- package/dist/src/utils/userStartupWarnings.d.ts +6 -0
- package/dist/src/utils/userStartupWarnings.js +54 -0
- package/dist/src/utils/userStartupWarnings.js.map +1 -0
- package/dist/src/utils/userStartupWarnings.test.d.ts +6 -0
- package/dist/src/utils/userStartupWarnings.test.js +67 -0
- package/dist/src/utils/userStartupWarnings.test.js.map +1 -0
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +11 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/validateNonInterActiveAuth.d.ts +8 -0
- package/dist/src/validateNonInterActiveAuth.js +37 -0
- package/dist/src/validateNonInterActiveAuth.js.map +1 -0
- package/dist/src/zed-integration/acp.d.ts +63 -0
- package/dist/src/zed-integration/acp.js +226 -0
- package/dist/src/zed-integration/acp.js.map +1 -0
- package/dist/src/zed-integration/fileSystemService.d.ts +19 -0
- package/dist/src/zed-integration/fileSystemService.js +43 -0
- package/dist/src/zed-integration/fileSystemService.js.map +1 -0
- package/dist/src/zed-integration/schema.d.ts +11782 -0
- package/dist/src/zed-integration/schema.js +311 -0
- package/dist/src/zed-integration/schema.js.map +1 -0
- package/dist/src/zed-integration/zedIntegration.d.ts +10 -0
- package/dist/src/zed-integration/zedIntegration.js +740 -0
- package/dist/src/zed-integration/zedIntegration.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,1489 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import pathMod from 'node:path';
|
|
10
|
+
import { useState, useCallback, useEffect, useMemo, useReducer } from 'react';
|
|
11
|
+
import stringWidth from 'string-width';
|
|
12
|
+
import { unescapePath } from '@google/gemini-cli-core';
|
|
13
|
+
import { toCodePoints, cpLen, cpSlice, stripUnsafeCharacters, } from '../../utils/textUtils.js';
|
|
14
|
+
import { handleVimAction } from './vim-buffer-actions.js';
|
|
15
|
+
// Simple helper for word‑wise ops.
|
|
16
|
+
function isWordChar(ch) {
|
|
17
|
+
if (ch === undefined) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return !/[\s,.;!?]/.test(ch);
|
|
21
|
+
}
|
|
22
|
+
// Helper functions for line-based word navigation
|
|
23
|
+
export const isWordCharStrict = (char) => /[\w\p{L}\p{N}]/u.test(char); // Matches a single character that is any Unicode letter, any Unicode number, or an underscore
|
|
24
|
+
export const isWhitespace = (char) => /\s/.test(char);
|
|
25
|
+
// Check if a character is a combining mark (only diacritics for now)
|
|
26
|
+
export const isCombiningMark = (char) => /\p{M}/u.test(char);
|
|
27
|
+
// Check if a character should be considered part of a word (including combining marks)
|
|
28
|
+
export const isWordCharWithCombining = (char) => isWordCharStrict(char) || isCombiningMark(char);
|
|
29
|
+
// Get the script of a character (simplified for common scripts)
|
|
30
|
+
export const getCharScript = (char) => {
|
|
31
|
+
if (/[\p{Script=Latin}]/u.test(char))
|
|
32
|
+
return 'latin'; // All Latin script chars including diacritics
|
|
33
|
+
if (/[\p{Script=Han}]/u.test(char))
|
|
34
|
+
return 'han'; // Chinese
|
|
35
|
+
if (/[\p{Script=Arabic}]/u.test(char))
|
|
36
|
+
return 'arabic';
|
|
37
|
+
if (/[\p{Script=Hiragana}]/u.test(char))
|
|
38
|
+
return 'hiragana';
|
|
39
|
+
if (/[\p{Script=Katakana}]/u.test(char))
|
|
40
|
+
return 'katakana';
|
|
41
|
+
if (/[\p{Script=Cyrillic}]/u.test(char))
|
|
42
|
+
return 'cyrillic';
|
|
43
|
+
return 'other';
|
|
44
|
+
};
|
|
45
|
+
// Check if two characters are from different scripts (indicating word boundary)
|
|
46
|
+
export const isDifferentScript = (char1, char2) => {
|
|
47
|
+
if (!isWordCharStrict(char1) || !isWordCharStrict(char2))
|
|
48
|
+
return false;
|
|
49
|
+
return getCharScript(char1) !== getCharScript(char2);
|
|
50
|
+
};
|
|
51
|
+
// Find next word start within a line, starting from col
|
|
52
|
+
export const findNextWordStartInLine = (line, col) => {
|
|
53
|
+
const chars = toCodePoints(line);
|
|
54
|
+
let i = col;
|
|
55
|
+
if (i >= chars.length)
|
|
56
|
+
return null;
|
|
57
|
+
const currentChar = chars[i];
|
|
58
|
+
// Skip current word/sequence based on character type
|
|
59
|
+
if (isWordCharStrict(currentChar)) {
|
|
60
|
+
while (i < chars.length && isWordCharWithCombining(chars[i])) {
|
|
61
|
+
// Check for script boundary - if next character is from different script, stop here
|
|
62
|
+
if (i + 1 < chars.length &&
|
|
63
|
+
isWordCharStrict(chars[i + 1]) &&
|
|
64
|
+
isDifferentScript(chars[i], chars[i + 1])) {
|
|
65
|
+
i++; // Include current character
|
|
66
|
+
break; // Stop at script boundary
|
|
67
|
+
}
|
|
68
|
+
i++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (!isWhitespace(currentChar)) {
|
|
72
|
+
while (i < chars.length &&
|
|
73
|
+
!isWordCharStrict(chars[i]) &&
|
|
74
|
+
!isWhitespace(chars[i])) {
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Skip whitespace
|
|
79
|
+
while (i < chars.length && isWhitespace(chars[i])) {
|
|
80
|
+
i++;
|
|
81
|
+
}
|
|
82
|
+
return i < chars.length ? i : null;
|
|
83
|
+
};
|
|
84
|
+
// Find previous word start within a line
|
|
85
|
+
export const findPrevWordStartInLine = (line, col) => {
|
|
86
|
+
const chars = toCodePoints(line);
|
|
87
|
+
let i = col;
|
|
88
|
+
if (i <= 0)
|
|
89
|
+
return null;
|
|
90
|
+
i--;
|
|
91
|
+
// Skip whitespace moving backwards
|
|
92
|
+
while (i >= 0 && isWhitespace(chars[i])) {
|
|
93
|
+
i--;
|
|
94
|
+
}
|
|
95
|
+
if (i < 0)
|
|
96
|
+
return null;
|
|
97
|
+
if (isWordCharStrict(chars[i])) {
|
|
98
|
+
// We're in a word, move to its beginning
|
|
99
|
+
while (i >= 0 && isWordCharStrict(chars[i])) {
|
|
100
|
+
// Check for script boundary - if previous character is from different script, stop here
|
|
101
|
+
if (i - 1 >= 0 &&
|
|
102
|
+
isWordCharStrict(chars[i - 1]) &&
|
|
103
|
+
isDifferentScript(chars[i], chars[i - 1])) {
|
|
104
|
+
return i; // Return current position at script boundary
|
|
105
|
+
}
|
|
106
|
+
i--;
|
|
107
|
+
}
|
|
108
|
+
return i + 1;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// We're in punctuation, move to its beginning
|
|
112
|
+
while (i >= 0 && !isWordCharStrict(chars[i]) && !isWhitespace(chars[i])) {
|
|
113
|
+
i--;
|
|
114
|
+
}
|
|
115
|
+
return i + 1;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
// Find word end within a line
|
|
119
|
+
export const findWordEndInLine = (line, col) => {
|
|
120
|
+
const chars = toCodePoints(line);
|
|
121
|
+
let i = col;
|
|
122
|
+
// If we're already at the end of a word (including punctuation sequences), advance to next word
|
|
123
|
+
// This includes both regular word endings and script boundaries
|
|
124
|
+
const atEndOfWordChar = i < chars.length &&
|
|
125
|
+
isWordCharWithCombining(chars[i]) &&
|
|
126
|
+
(i + 1 >= chars.length ||
|
|
127
|
+
!isWordCharWithCombining(chars[i + 1]) ||
|
|
128
|
+
(isWordCharStrict(chars[i]) &&
|
|
129
|
+
i + 1 < chars.length &&
|
|
130
|
+
isWordCharStrict(chars[i + 1]) &&
|
|
131
|
+
isDifferentScript(chars[i], chars[i + 1])));
|
|
132
|
+
const atEndOfPunctuation = i < chars.length &&
|
|
133
|
+
!isWordCharWithCombining(chars[i]) &&
|
|
134
|
+
!isWhitespace(chars[i]) &&
|
|
135
|
+
(i + 1 >= chars.length ||
|
|
136
|
+
isWhitespace(chars[i + 1]) ||
|
|
137
|
+
isWordCharWithCombining(chars[i + 1]));
|
|
138
|
+
if (atEndOfWordChar || atEndOfPunctuation) {
|
|
139
|
+
// We're at the end of a word or punctuation sequence, move forward to find next word
|
|
140
|
+
i++;
|
|
141
|
+
// Skip whitespace to find next word or punctuation
|
|
142
|
+
while (i < chars.length && isWhitespace(chars[i])) {
|
|
143
|
+
i++;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// If we're not on a word character, find the next word or punctuation sequence
|
|
147
|
+
if (i < chars.length && !isWordCharWithCombining(chars[i])) {
|
|
148
|
+
// Skip whitespace to find next word or punctuation
|
|
149
|
+
while (i < chars.length && isWhitespace(chars[i])) {
|
|
150
|
+
i++;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Move to end of current word (including combining marks, but stop at script boundaries)
|
|
154
|
+
let foundWord = false;
|
|
155
|
+
let lastBaseCharPos = -1;
|
|
156
|
+
if (i < chars.length && isWordCharWithCombining(chars[i])) {
|
|
157
|
+
// Handle word characters
|
|
158
|
+
while (i < chars.length && isWordCharWithCombining(chars[i])) {
|
|
159
|
+
foundWord = true;
|
|
160
|
+
// Track the position of the last base character (not combining mark)
|
|
161
|
+
if (isWordCharStrict(chars[i])) {
|
|
162
|
+
lastBaseCharPos = i;
|
|
163
|
+
}
|
|
164
|
+
// Check if next character is from a different script (word boundary)
|
|
165
|
+
if (i + 1 < chars.length &&
|
|
166
|
+
isWordCharStrict(chars[i + 1]) &&
|
|
167
|
+
isDifferentScript(chars[i], chars[i + 1])) {
|
|
168
|
+
i++; // Include current character
|
|
169
|
+
if (isWordCharStrict(chars[i - 1])) {
|
|
170
|
+
lastBaseCharPos = i - 1;
|
|
171
|
+
}
|
|
172
|
+
break; // Stop at script boundary
|
|
173
|
+
}
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (i < chars.length && !isWhitespace(chars[i])) {
|
|
178
|
+
// Handle punctuation sequences (like ████)
|
|
179
|
+
while (i < chars.length &&
|
|
180
|
+
!isWordCharStrict(chars[i]) &&
|
|
181
|
+
!isWhitespace(chars[i])) {
|
|
182
|
+
foundWord = true;
|
|
183
|
+
lastBaseCharPos = i;
|
|
184
|
+
i++;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Only return a position if we actually found a word
|
|
188
|
+
// Return the position of the last base character, not combining marks
|
|
189
|
+
if (foundWord && lastBaseCharPos >= col) {
|
|
190
|
+
return lastBaseCharPos;
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
};
|
|
194
|
+
// Find next word across lines
|
|
195
|
+
export const findNextWordAcrossLines = (lines, cursorRow, cursorCol, searchForWordStart) => {
|
|
196
|
+
// First try current line
|
|
197
|
+
const currentLine = lines[cursorRow] || '';
|
|
198
|
+
const colInCurrentLine = searchForWordStart
|
|
199
|
+
? findNextWordStartInLine(currentLine, cursorCol)
|
|
200
|
+
: findWordEndInLine(currentLine, cursorCol);
|
|
201
|
+
if (colInCurrentLine !== null) {
|
|
202
|
+
return { row: cursorRow, col: colInCurrentLine };
|
|
203
|
+
}
|
|
204
|
+
// Search subsequent lines
|
|
205
|
+
for (let row = cursorRow + 1; row < lines.length; row++) {
|
|
206
|
+
const line = lines[row] || '';
|
|
207
|
+
const chars = toCodePoints(line);
|
|
208
|
+
// For empty lines, if we haven't found any words yet, return the empty line
|
|
209
|
+
if (chars.length === 0) {
|
|
210
|
+
// Check if there are any words in remaining lines
|
|
211
|
+
let hasWordsInLaterLines = false;
|
|
212
|
+
for (let laterRow = row + 1; laterRow < lines.length; laterRow++) {
|
|
213
|
+
const laterLine = lines[laterRow] || '';
|
|
214
|
+
const laterChars = toCodePoints(laterLine);
|
|
215
|
+
let firstNonWhitespace = 0;
|
|
216
|
+
while (firstNonWhitespace < laterChars.length &&
|
|
217
|
+
isWhitespace(laterChars[firstNonWhitespace])) {
|
|
218
|
+
firstNonWhitespace++;
|
|
219
|
+
}
|
|
220
|
+
if (firstNonWhitespace < laterChars.length) {
|
|
221
|
+
hasWordsInLaterLines = true;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// If no words in later lines, return the empty line
|
|
226
|
+
if (!hasWordsInLaterLines) {
|
|
227
|
+
return { row, col: 0 };
|
|
228
|
+
}
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
// Find first non-whitespace
|
|
232
|
+
let firstNonWhitespace = 0;
|
|
233
|
+
while (firstNonWhitespace < chars.length &&
|
|
234
|
+
isWhitespace(chars[firstNonWhitespace])) {
|
|
235
|
+
firstNonWhitespace++;
|
|
236
|
+
}
|
|
237
|
+
if (firstNonWhitespace < chars.length) {
|
|
238
|
+
if (searchForWordStart) {
|
|
239
|
+
return { row, col: firstNonWhitespace };
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
// For word end, find the end of the first word
|
|
243
|
+
const endCol = findWordEndInLine(line, firstNonWhitespace);
|
|
244
|
+
if (endCol !== null) {
|
|
245
|
+
return { row, col: endCol };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
};
|
|
252
|
+
// Find previous word across lines
|
|
253
|
+
export const findPrevWordAcrossLines = (lines, cursorRow, cursorCol) => {
|
|
254
|
+
// First try current line
|
|
255
|
+
const currentLine = lines[cursorRow] || '';
|
|
256
|
+
const colInCurrentLine = findPrevWordStartInLine(currentLine, cursorCol);
|
|
257
|
+
if (colInCurrentLine !== null) {
|
|
258
|
+
return { row: cursorRow, col: colInCurrentLine };
|
|
259
|
+
}
|
|
260
|
+
// Search previous lines
|
|
261
|
+
for (let row = cursorRow - 1; row >= 0; row--) {
|
|
262
|
+
const line = lines[row] || '';
|
|
263
|
+
const chars = toCodePoints(line);
|
|
264
|
+
if (chars.length === 0)
|
|
265
|
+
continue;
|
|
266
|
+
// Find last word start
|
|
267
|
+
let lastWordStart = chars.length;
|
|
268
|
+
while (lastWordStart > 0 && isWhitespace(chars[lastWordStart - 1])) {
|
|
269
|
+
lastWordStart--;
|
|
270
|
+
}
|
|
271
|
+
if (lastWordStart > 0) {
|
|
272
|
+
// Find start of this word
|
|
273
|
+
const wordStart = findPrevWordStartInLine(line, lastWordStart);
|
|
274
|
+
if (wordStart !== null) {
|
|
275
|
+
return { row, col: wordStart };
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
};
|
|
281
|
+
// Helper functions for vim line operations
|
|
282
|
+
export const getPositionFromOffsets = (startOffset, endOffset, lines) => {
|
|
283
|
+
let offset = 0;
|
|
284
|
+
let startRow = 0;
|
|
285
|
+
let startCol = 0;
|
|
286
|
+
let endRow = 0;
|
|
287
|
+
let endCol = 0;
|
|
288
|
+
// Find start position
|
|
289
|
+
for (let i = 0; i < lines.length; i++) {
|
|
290
|
+
const lineLength = lines[i].length + 1; // +1 for newline
|
|
291
|
+
if (offset + lineLength > startOffset) {
|
|
292
|
+
startRow = i;
|
|
293
|
+
startCol = startOffset - offset;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
offset += lineLength;
|
|
297
|
+
}
|
|
298
|
+
// Find end position
|
|
299
|
+
offset = 0;
|
|
300
|
+
for (let i = 0; i < lines.length; i++) {
|
|
301
|
+
const lineLength = lines[i].length + (i < lines.length - 1 ? 1 : 0); // +1 for newline except last line
|
|
302
|
+
if (offset + lineLength >= endOffset) {
|
|
303
|
+
endRow = i;
|
|
304
|
+
endCol = endOffset - offset;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
offset += lineLength;
|
|
308
|
+
}
|
|
309
|
+
return { startRow, startCol, endRow, endCol };
|
|
310
|
+
};
|
|
311
|
+
export const getLineRangeOffsets = (startRow, lineCount, lines) => {
|
|
312
|
+
let startOffset = 0;
|
|
313
|
+
// Calculate start offset
|
|
314
|
+
for (let i = 0; i < startRow; i++) {
|
|
315
|
+
startOffset += lines[i].length + 1; // +1 for newline
|
|
316
|
+
}
|
|
317
|
+
// Calculate end offset
|
|
318
|
+
let endOffset = startOffset;
|
|
319
|
+
for (let i = 0; i < lineCount; i++) {
|
|
320
|
+
const lineIndex = startRow + i;
|
|
321
|
+
if (lineIndex < lines.length) {
|
|
322
|
+
endOffset += lines[lineIndex].length;
|
|
323
|
+
if (lineIndex < lines.length - 1) {
|
|
324
|
+
endOffset += 1; // +1 for newline
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return { startOffset, endOffset };
|
|
329
|
+
};
|
|
330
|
+
export const replaceRangeInternal = (state, startRow, startCol, endRow, endCol, text) => {
|
|
331
|
+
const currentLine = (row) => state.lines[row] || '';
|
|
332
|
+
const currentLineLen = (row) => cpLen(currentLine(row));
|
|
333
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
334
|
+
if (startRow > endRow ||
|
|
335
|
+
(startRow === endRow && startCol > endCol) ||
|
|
336
|
+
startRow < 0 ||
|
|
337
|
+
startCol < 0 ||
|
|
338
|
+
endRow >= state.lines.length ||
|
|
339
|
+
(endRow < state.lines.length && endCol > currentLineLen(endRow))) {
|
|
340
|
+
return state; // Invalid range
|
|
341
|
+
}
|
|
342
|
+
const newLines = [...state.lines];
|
|
343
|
+
const sCol = clamp(startCol, 0, currentLineLen(startRow));
|
|
344
|
+
const eCol = clamp(endCol, 0, currentLineLen(endRow));
|
|
345
|
+
const prefix = cpSlice(currentLine(startRow), 0, sCol);
|
|
346
|
+
const suffix = cpSlice(currentLine(endRow), eCol);
|
|
347
|
+
const normalisedReplacement = text
|
|
348
|
+
.replace(/\r\n/g, '\n')
|
|
349
|
+
.replace(/\r/g, '\n');
|
|
350
|
+
const replacementParts = normalisedReplacement.split('\n');
|
|
351
|
+
// The combined first line of the new text
|
|
352
|
+
const firstLine = prefix + replacementParts[0];
|
|
353
|
+
if (replacementParts.length === 1) {
|
|
354
|
+
// No newlines in replacement: combine prefix, replacement, and suffix on one line.
|
|
355
|
+
newLines.splice(startRow, endRow - startRow + 1, firstLine + suffix);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// Newlines in replacement: create new lines.
|
|
359
|
+
const lastLine = replacementParts[replacementParts.length - 1] + suffix;
|
|
360
|
+
const middleLines = replacementParts.slice(1, -1);
|
|
361
|
+
newLines.splice(startRow, endRow - startRow + 1, firstLine, ...middleLines, lastLine);
|
|
362
|
+
}
|
|
363
|
+
const finalCursorRow = startRow + replacementParts.length - 1;
|
|
364
|
+
const finalCursorCol = (replacementParts.length > 1 ? 0 : sCol) +
|
|
365
|
+
cpLen(replacementParts[replacementParts.length - 1]);
|
|
366
|
+
return {
|
|
367
|
+
...state,
|
|
368
|
+
lines: newLines,
|
|
369
|
+
cursorRow: Math.min(Math.max(finalCursorRow, 0), newLines.length - 1),
|
|
370
|
+
cursorCol: Math.max(0, Math.min(finalCursorCol, cpLen(newLines[finalCursorRow] || ''))),
|
|
371
|
+
preferredCol: null,
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
function clamp(v, min, max) {
|
|
375
|
+
return v < min ? min : v > max ? max : v;
|
|
376
|
+
}
|
|
377
|
+
function calculateInitialCursorPosition(initialLines, offset) {
|
|
378
|
+
let remainingChars = offset;
|
|
379
|
+
let row = 0;
|
|
380
|
+
while (row < initialLines.length) {
|
|
381
|
+
const lineLength = cpLen(initialLines[row]);
|
|
382
|
+
// Add 1 for the newline character (except for the last line)
|
|
383
|
+
const totalCharsInLineAndNewline = lineLength + (row < initialLines.length - 1 ? 1 : 0);
|
|
384
|
+
if (remainingChars <= lineLength) {
|
|
385
|
+
// Cursor is on this line
|
|
386
|
+
return [row, remainingChars];
|
|
387
|
+
}
|
|
388
|
+
remainingChars -= totalCharsInLineAndNewline;
|
|
389
|
+
row++;
|
|
390
|
+
}
|
|
391
|
+
// Offset is beyond the text, place cursor at the end of the last line
|
|
392
|
+
if (initialLines.length > 0) {
|
|
393
|
+
const lastRow = initialLines.length - 1;
|
|
394
|
+
return [lastRow, cpLen(initialLines[lastRow])];
|
|
395
|
+
}
|
|
396
|
+
return [0, 0]; // Default for empty text
|
|
397
|
+
}
|
|
398
|
+
export function offsetToLogicalPos(text, offset) {
|
|
399
|
+
let row = 0;
|
|
400
|
+
let col = 0;
|
|
401
|
+
let currentOffset = 0;
|
|
402
|
+
if (offset === 0)
|
|
403
|
+
return [0, 0];
|
|
404
|
+
const lines = text.split('\n');
|
|
405
|
+
for (let i = 0; i < lines.length; i++) {
|
|
406
|
+
const line = lines[i];
|
|
407
|
+
const lineLength = cpLen(line);
|
|
408
|
+
const lineLengthWithNewline = lineLength + (i < lines.length - 1 ? 1 : 0);
|
|
409
|
+
if (offset <= currentOffset + lineLength) {
|
|
410
|
+
// Check against lineLength first
|
|
411
|
+
row = i;
|
|
412
|
+
col = offset - currentOffset;
|
|
413
|
+
return [row, col];
|
|
414
|
+
}
|
|
415
|
+
else if (offset <= currentOffset + lineLengthWithNewline) {
|
|
416
|
+
// Check if offset is the newline itself
|
|
417
|
+
row = i;
|
|
418
|
+
col = lineLength; // Position cursor at the end of the current line content
|
|
419
|
+
// If the offset IS the newline, and it's not the last line, advance to next line, col 0
|
|
420
|
+
if (offset === currentOffset + lineLengthWithNewline &&
|
|
421
|
+
i < lines.length - 1) {
|
|
422
|
+
return [i + 1, 0];
|
|
423
|
+
}
|
|
424
|
+
return [row, col]; // Otherwise, it's at the end of the current line content
|
|
425
|
+
}
|
|
426
|
+
currentOffset += lineLengthWithNewline;
|
|
427
|
+
}
|
|
428
|
+
// If offset is beyond the text length, place cursor at the end of the last line
|
|
429
|
+
// or [0,0] if text is empty
|
|
430
|
+
if (lines.length > 0) {
|
|
431
|
+
row = lines.length - 1;
|
|
432
|
+
col = cpLen(lines[row]);
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
row = 0;
|
|
436
|
+
col = 0;
|
|
437
|
+
}
|
|
438
|
+
return [row, col];
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Converts logical row/col position to absolute text offset
|
|
442
|
+
* Inverse operation of offsetToLogicalPos
|
|
443
|
+
*/
|
|
444
|
+
export function logicalPosToOffset(lines, row, col) {
|
|
445
|
+
let offset = 0;
|
|
446
|
+
// Clamp row to valid range
|
|
447
|
+
const actualRow = Math.min(row, lines.length - 1);
|
|
448
|
+
// Add lengths of all lines before the target row
|
|
449
|
+
for (let i = 0; i < actualRow; i++) {
|
|
450
|
+
offset += cpLen(lines[i]) + 1; // +1 for newline
|
|
451
|
+
}
|
|
452
|
+
// Add column offset within the target row
|
|
453
|
+
if (actualRow >= 0 && actualRow < lines.length) {
|
|
454
|
+
offset += Math.min(col, cpLen(lines[actualRow]));
|
|
455
|
+
}
|
|
456
|
+
return offset;
|
|
457
|
+
}
|
|
458
|
+
// Helper to calculate visual lines and map cursor positions
|
|
459
|
+
function calculateVisualLayout(logicalLines, logicalCursor, viewportWidth) {
|
|
460
|
+
const visualLines = [];
|
|
461
|
+
const logicalToVisualMap = [];
|
|
462
|
+
const visualToLogicalMap = [];
|
|
463
|
+
let currentVisualCursor = [0, 0];
|
|
464
|
+
logicalLines.forEach((logLine, logIndex) => {
|
|
465
|
+
logicalToVisualMap[logIndex] = [];
|
|
466
|
+
if (logLine.length === 0) {
|
|
467
|
+
// Handle empty logical line
|
|
468
|
+
logicalToVisualMap[logIndex].push([visualLines.length, 0]);
|
|
469
|
+
visualToLogicalMap.push([logIndex, 0]);
|
|
470
|
+
visualLines.push('');
|
|
471
|
+
if (logIndex === logicalCursor[0] && logicalCursor[1] === 0) {
|
|
472
|
+
currentVisualCursor = [visualLines.length - 1, 0];
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// Non-empty logical line
|
|
477
|
+
let currentPosInLogLine = 0; // Tracks position within the current logical line (code point index)
|
|
478
|
+
const codePointsInLogLine = toCodePoints(logLine);
|
|
479
|
+
while (currentPosInLogLine < codePointsInLogLine.length) {
|
|
480
|
+
let currentChunk = '';
|
|
481
|
+
let currentChunkVisualWidth = 0;
|
|
482
|
+
let numCodePointsInChunk = 0;
|
|
483
|
+
let lastWordBreakPoint = -1; // Index in codePointsInLogLine for word break
|
|
484
|
+
let numCodePointsAtLastWordBreak = 0;
|
|
485
|
+
// Iterate through code points to build the current visual line (chunk)
|
|
486
|
+
for (let i = currentPosInLogLine; i < codePointsInLogLine.length; i++) {
|
|
487
|
+
const char = codePointsInLogLine[i];
|
|
488
|
+
const charVisualWidth = stringWidth(char);
|
|
489
|
+
if (currentChunkVisualWidth + charVisualWidth > viewportWidth) {
|
|
490
|
+
// Character would exceed viewport width
|
|
491
|
+
if (lastWordBreakPoint !== -1 &&
|
|
492
|
+
numCodePointsAtLastWordBreak > 0 &&
|
|
493
|
+
currentPosInLogLine + numCodePointsAtLastWordBreak < i) {
|
|
494
|
+
// We have a valid word break point to use, and it's not the start of the current segment
|
|
495
|
+
currentChunk = codePointsInLogLine
|
|
496
|
+
.slice(currentPosInLogLine, currentPosInLogLine + numCodePointsAtLastWordBreak)
|
|
497
|
+
.join('');
|
|
498
|
+
numCodePointsInChunk = numCodePointsAtLastWordBreak;
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// No word break, or word break is at the start of this potential chunk, or word break leads to empty chunk.
|
|
502
|
+
// Hard break: take characters up to viewportWidth, or just the current char if it alone is too wide.
|
|
503
|
+
if (numCodePointsInChunk === 0 &&
|
|
504
|
+
charVisualWidth > viewportWidth) {
|
|
505
|
+
// Single character is wider than viewport, take it anyway
|
|
506
|
+
currentChunk = char;
|
|
507
|
+
numCodePointsInChunk = 1;
|
|
508
|
+
}
|
|
509
|
+
else if (numCodePointsInChunk === 0 &&
|
|
510
|
+
charVisualWidth <= viewportWidth) {
|
|
511
|
+
// This case should ideally be caught by the next iteration if the char fits.
|
|
512
|
+
// If it doesn't fit (because currentChunkVisualWidth was already > 0 from a previous char that filled the line),
|
|
513
|
+
// then numCodePointsInChunk would not be 0.
|
|
514
|
+
// This branch means the current char *itself* doesn't fit an empty line, which is handled by the above.
|
|
515
|
+
// If we are here, it means the loop should break and the current chunk (which is empty) is finalized.
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
break; // Break from inner loop to finalize this chunk
|
|
519
|
+
}
|
|
520
|
+
currentChunk += char;
|
|
521
|
+
currentChunkVisualWidth += charVisualWidth;
|
|
522
|
+
numCodePointsInChunk++;
|
|
523
|
+
// Check for word break opportunity (space)
|
|
524
|
+
if (char === ' ') {
|
|
525
|
+
lastWordBreakPoint = i; // Store code point index of the space
|
|
526
|
+
// Store the state *before* adding the space, if we decide to break here.
|
|
527
|
+
numCodePointsAtLastWordBreak = numCodePointsInChunk - 1; // Chars *before* the space
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
// If the inner loop completed without breaking (i.e., remaining text fits)
|
|
531
|
+
// or if the loop broke but numCodePointsInChunk is still 0 (e.g. first char too wide for empty line)
|
|
532
|
+
if (numCodePointsInChunk === 0 &&
|
|
533
|
+
currentPosInLogLine < codePointsInLogLine.length) {
|
|
534
|
+
// This can happen if the very first character considered for a new visual line is wider than the viewport.
|
|
535
|
+
// In this case, we take that single character.
|
|
536
|
+
const firstChar = codePointsInLogLine[currentPosInLogLine];
|
|
537
|
+
currentChunk = firstChar;
|
|
538
|
+
numCodePointsInChunk = 1; // Ensure we advance
|
|
539
|
+
}
|
|
540
|
+
// If after everything, numCodePointsInChunk is still 0 but we haven't processed the whole logical line,
|
|
541
|
+
// it implies an issue, like viewportWidth being 0 or less. Avoid infinite loop.
|
|
542
|
+
if (numCodePointsInChunk === 0 &&
|
|
543
|
+
currentPosInLogLine < codePointsInLogLine.length) {
|
|
544
|
+
// Force advance by one character to prevent infinite loop if something went wrong
|
|
545
|
+
currentChunk = codePointsInLogLine[currentPosInLogLine];
|
|
546
|
+
numCodePointsInChunk = 1;
|
|
547
|
+
}
|
|
548
|
+
logicalToVisualMap[logIndex].push([
|
|
549
|
+
visualLines.length,
|
|
550
|
+
currentPosInLogLine,
|
|
551
|
+
]);
|
|
552
|
+
visualToLogicalMap.push([logIndex, currentPosInLogLine]);
|
|
553
|
+
visualLines.push(currentChunk);
|
|
554
|
+
// Cursor mapping logic
|
|
555
|
+
// Note: currentPosInLogLine here is the start of the currentChunk within the logical line.
|
|
556
|
+
if (logIndex === logicalCursor[0]) {
|
|
557
|
+
const cursorLogCol = logicalCursor[1]; // This is a code point index
|
|
558
|
+
if (cursorLogCol >= currentPosInLogLine &&
|
|
559
|
+
cursorLogCol < currentPosInLogLine + numCodePointsInChunk // Cursor is within this chunk
|
|
560
|
+
) {
|
|
561
|
+
currentVisualCursor = [
|
|
562
|
+
visualLines.length - 1,
|
|
563
|
+
cursorLogCol - currentPosInLogLine, // Visual col is also code point index within visual line
|
|
564
|
+
];
|
|
565
|
+
}
|
|
566
|
+
else if (cursorLogCol === currentPosInLogLine + numCodePointsInChunk &&
|
|
567
|
+
numCodePointsInChunk > 0) {
|
|
568
|
+
// Cursor is exactly at the end of this non-empty chunk
|
|
569
|
+
currentVisualCursor = [
|
|
570
|
+
visualLines.length - 1,
|
|
571
|
+
numCodePointsInChunk,
|
|
572
|
+
];
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
const logicalStartOfThisChunk = currentPosInLogLine;
|
|
576
|
+
currentPosInLogLine += numCodePointsInChunk;
|
|
577
|
+
// If the chunk processed did not consume the entire logical line,
|
|
578
|
+
// and the character immediately following the chunk is a space,
|
|
579
|
+
// advance past this space as it acted as a delimiter for word wrapping.
|
|
580
|
+
if (logicalStartOfThisChunk + numCodePointsInChunk <
|
|
581
|
+
codePointsInLogLine.length &&
|
|
582
|
+
currentPosInLogLine < codePointsInLogLine.length && // Redundant if previous is true, but safe
|
|
583
|
+
codePointsInLogLine[currentPosInLogLine] === ' ') {
|
|
584
|
+
currentPosInLogLine++;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
// After all chunks of a non-empty logical line are processed,
|
|
588
|
+
// if the cursor is at the very end of this logical line, update visual cursor.
|
|
589
|
+
if (logIndex === logicalCursor[0] &&
|
|
590
|
+
logicalCursor[1] === codePointsInLogLine.length // Cursor at end of logical line
|
|
591
|
+
) {
|
|
592
|
+
const lastVisualLineIdx = visualLines.length - 1;
|
|
593
|
+
if (lastVisualLineIdx >= 0 &&
|
|
594
|
+
visualLines[lastVisualLineIdx] !== undefined) {
|
|
595
|
+
currentVisualCursor = [
|
|
596
|
+
lastVisualLineIdx,
|
|
597
|
+
cpLen(visualLines[lastVisualLineIdx]), // Cursor at end of last visual line for this logical line
|
|
598
|
+
];
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
// If the entire logical text was empty, ensure there's one empty visual line.
|
|
604
|
+
if (logicalLines.length === 0 ||
|
|
605
|
+
(logicalLines.length === 1 && logicalLines[0] === '')) {
|
|
606
|
+
if (visualLines.length === 0) {
|
|
607
|
+
visualLines.push('');
|
|
608
|
+
if (!logicalToVisualMap[0])
|
|
609
|
+
logicalToVisualMap[0] = [];
|
|
610
|
+
logicalToVisualMap[0].push([0, 0]);
|
|
611
|
+
visualToLogicalMap.push([0, 0]);
|
|
612
|
+
}
|
|
613
|
+
currentVisualCursor = [0, 0];
|
|
614
|
+
}
|
|
615
|
+
// Handle cursor at the very end of the text (after all processing)
|
|
616
|
+
// This case might be covered by the loop end condition now, but kept for safety.
|
|
617
|
+
else if (logicalCursor[0] === logicalLines.length - 1 &&
|
|
618
|
+
logicalCursor[1] === cpLen(logicalLines[logicalLines.length - 1]) &&
|
|
619
|
+
visualLines.length > 0) {
|
|
620
|
+
const lastVisLineIdx = visualLines.length - 1;
|
|
621
|
+
currentVisualCursor = [lastVisLineIdx, cpLen(visualLines[lastVisLineIdx])];
|
|
622
|
+
}
|
|
623
|
+
return {
|
|
624
|
+
visualLines,
|
|
625
|
+
visualCursor: currentVisualCursor,
|
|
626
|
+
logicalToVisualMap,
|
|
627
|
+
visualToLogicalMap,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
const historyLimit = 100;
|
|
631
|
+
export const pushUndo = (currentState) => {
|
|
632
|
+
const snapshot = {
|
|
633
|
+
lines: [...currentState.lines],
|
|
634
|
+
cursorRow: currentState.cursorRow,
|
|
635
|
+
cursorCol: currentState.cursorCol,
|
|
636
|
+
};
|
|
637
|
+
const newStack = [...currentState.undoStack, snapshot];
|
|
638
|
+
if (newStack.length > historyLimit) {
|
|
639
|
+
newStack.shift();
|
|
640
|
+
}
|
|
641
|
+
return { ...currentState, undoStack: newStack, redoStack: [] };
|
|
642
|
+
};
|
|
643
|
+
export function textBufferReducer(state, action) {
|
|
644
|
+
const pushUndoLocal = pushUndo;
|
|
645
|
+
const currentLine = (r) => state.lines[r] ?? '';
|
|
646
|
+
const currentLineLen = (r) => cpLen(currentLine(r));
|
|
647
|
+
switch (action.type) {
|
|
648
|
+
case 'set_text': {
|
|
649
|
+
let nextState = state;
|
|
650
|
+
if (action.pushToUndo !== false) {
|
|
651
|
+
nextState = pushUndoLocal(state);
|
|
652
|
+
}
|
|
653
|
+
const newContentLines = action.payload
|
|
654
|
+
.replace(/\r\n?/g, '\n')
|
|
655
|
+
.split('\n');
|
|
656
|
+
const lines = newContentLines.length === 0 ? [''] : newContentLines;
|
|
657
|
+
const lastNewLineIndex = lines.length - 1;
|
|
658
|
+
return {
|
|
659
|
+
...nextState,
|
|
660
|
+
lines,
|
|
661
|
+
cursorRow: lastNewLineIndex,
|
|
662
|
+
cursorCol: cpLen(lines[lastNewLineIndex] ?? ''),
|
|
663
|
+
preferredCol: null,
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
case 'insert': {
|
|
667
|
+
const nextState = pushUndoLocal(state);
|
|
668
|
+
const newLines = [...nextState.lines];
|
|
669
|
+
let newCursorRow = nextState.cursorRow;
|
|
670
|
+
let newCursorCol = nextState.cursorCol;
|
|
671
|
+
const currentLine = (r) => newLines[r] ?? '';
|
|
672
|
+
const str = stripUnsafeCharacters(action.payload.replace(/\r\n/g, '\n').replace(/\r/g, '\n'));
|
|
673
|
+
const parts = str.split('\n');
|
|
674
|
+
const lineContent = currentLine(newCursorRow);
|
|
675
|
+
const before = cpSlice(lineContent, 0, newCursorCol);
|
|
676
|
+
const after = cpSlice(lineContent, newCursorCol);
|
|
677
|
+
if (parts.length > 1) {
|
|
678
|
+
newLines[newCursorRow] = before + parts[0];
|
|
679
|
+
const remainingParts = parts.slice(1);
|
|
680
|
+
const lastPartOriginal = remainingParts.pop() ?? '';
|
|
681
|
+
newLines.splice(newCursorRow + 1, 0, ...remainingParts);
|
|
682
|
+
newLines.splice(newCursorRow + parts.length - 1, 0, lastPartOriginal + after);
|
|
683
|
+
newCursorRow = newCursorRow + parts.length - 1;
|
|
684
|
+
newCursorCol = cpLen(lastPartOriginal);
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
newLines[newCursorRow] = before + parts[0] + after;
|
|
688
|
+
newCursorCol = cpLen(before) + cpLen(parts[0]);
|
|
689
|
+
}
|
|
690
|
+
return {
|
|
691
|
+
...nextState,
|
|
692
|
+
lines: newLines,
|
|
693
|
+
cursorRow: newCursorRow,
|
|
694
|
+
cursorCol: newCursorCol,
|
|
695
|
+
preferredCol: null,
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
case 'backspace': {
|
|
699
|
+
const nextState = pushUndoLocal(state);
|
|
700
|
+
const newLines = [...nextState.lines];
|
|
701
|
+
let newCursorRow = nextState.cursorRow;
|
|
702
|
+
let newCursorCol = nextState.cursorCol;
|
|
703
|
+
const currentLine = (r) => newLines[r] ?? '';
|
|
704
|
+
if (newCursorCol === 0 && newCursorRow === 0)
|
|
705
|
+
return state;
|
|
706
|
+
if (newCursorCol > 0) {
|
|
707
|
+
const lineContent = currentLine(newCursorRow);
|
|
708
|
+
newLines[newCursorRow] =
|
|
709
|
+
cpSlice(lineContent, 0, newCursorCol - 1) +
|
|
710
|
+
cpSlice(lineContent, newCursorCol);
|
|
711
|
+
newCursorCol--;
|
|
712
|
+
}
|
|
713
|
+
else if (newCursorRow > 0) {
|
|
714
|
+
const prevLineContent = currentLine(newCursorRow - 1);
|
|
715
|
+
const currentLineContentVal = currentLine(newCursorRow);
|
|
716
|
+
const newCol = cpLen(prevLineContent);
|
|
717
|
+
newLines[newCursorRow - 1] = prevLineContent + currentLineContentVal;
|
|
718
|
+
newLines.splice(newCursorRow, 1);
|
|
719
|
+
newCursorRow--;
|
|
720
|
+
newCursorCol = newCol;
|
|
721
|
+
}
|
|
722
|
+
return {
|
|
723
|
+
...nextState,
|
|
724
|
+
lines: newLines,
|
|
725
|
+
cursorRow: newCursorRow,
|
|
726
|
+
cursorCol: newCursorCol,
|
|
727
|
+
preferredCol: null,
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
case 'set_viewport_width': {
|
|
731
|
+
if (action.payload === state.viewportWidth) {
|
|
732
|
+
return state;
|
|
733
|
+
}
|
|
734
|
+
return { ...state, viewportWidth: action.payload };
|
|
735
|
+
}
|
|
736
|
+
case 'move': {
|
|
737
|
+
const { dir } = action.payload;
|
|
738
|
+
const { lines, cursorRow, cursorCol, viewportWidth } = state;
|
|
739
|
+
const visualLayout = calculateVisualLayout(lines, [cursorRow, cursorCol], viewportWidth);
|
|
740
|
+
const { visualLines, visualCursor, visualToLogicalMap } = visualLayout;
|
|
741
|
+
let newVisualRow = visualCursor[0];
|
|
742
|
+
let newVisualCol = visualCursor[1];
|
|
743
|
+
let newPreferredCol = state.preferredCol;
|
|
744
|
+
const currentVisLineLen = cpLen(visualLines[newVisualRow] ?? '');
|
|
745
|
+
switch (dir) {
|
|
746
|
+
case 'left':
|
|
747
|
+
newPreferredCol = null;
|
|
748
|
+
if (newVisualCol > 0) {
|
|
749
|
+
newVisualCol--;
|
|
750
|
+
}
|
|
751
|
+
else if (newVisualRow > 0) {
|
|
752
|
+
newVisualRow--;
|
|
753
|
+
newVisualCol = cpLen(visualLines[newVisualRow] ?? '');
|
|
754
|
+
}
|
|
755
|
+
break;
|
|
756
|
+
case 'right':
|
|
757
|
+
newPreferredCol = null;
|
|
758
|
+
if (newVisualCol < currentVisLineLen) {
|
|
759
|
+
newVisualCol++;
|
|
760
|
+
}
|
|
761
|
+
else if (newVisualRow < visualLines.length - 1) {
|
|
762
|
+
newVisualRow++;
|
|
763
|
+
newVisualCol = 0;
|
|
764
|
+
}
|
|
765
|
+
break;
|
|
766
|
+
case 'up':
|
|
767
|
+
if (newVisualRow > 0) {
|
|
768
|
+
if (newPreferredCol === null)
|
|
769
|
+
newPreferredCol = newVisualCol;
|
|
770
|
+
newVisualRow--;
|
|
771
|
+
newVisualCol = clamp(newPreferredCol, 0, cpLen(visualLines[newVisualRow] ?? ''));
|
|
772
|
+
}
|
|
773
|
+
break;
|
|
774
|
+
case 'down':
|
|
775
|
+
if (newVisualRow < visualLines.length - 1) {
|
|
776
|
+
if (newPreferredCol === null)
|
|
777
|
+
newPreferredCol = newVisualCol;
|
|
778
|
+
newVisualRow++;
|
|
779
|
+
newVisualCol = clamp(newPreferredCol, 0, cpLen(visualLines[newVisualRow] ?? ''));
|
|
780
|
+
}
|
|
781
|
+
break;
|
|
782
|
+
case 'home':
|
|
783
|
+
newPreferredCol = null;
|
|
784
|
+
newVisualCol = 0;
|
|
785
|
+
break;
|
|
786
|
+
case 'end':
|
|
787
|
+
newPreferredCol = null;
|
|
788
|
+
newVisualCol = currentVisLineLen;
|
|
789
|
+
break;
|
|
790
|
+
case 'wordLeft': {
|
|
791
|
+
const { cursorRow, cursorCol, lines } = state;
|
|
792
|
+
if (cursorCol === 0 && cursorRow === 0)
|
|
793
|
+
return state;
|
|
794
|
+
let newCursorRow = cursorRow;
|
|
795
|
+
let newCursorCol = cursorCol;
|
|
796
|
+
if (cursorCol === 0) {
|
|
797
|
+
newCursorRow--;
|
|
798
|
+
newCursorCol = cpLen(lines[newCursorRow] ?? '');
|
|
799
|
+
}
|
|
800
|
+
else {
|
|
801
|
+
const lineContent = lines[cursorRow];
|
|
802
|
+
const arr = toCodePoints(lineContent);
|
|
803
|
+
let start = cursorCol;
|
|
804
|
+
let onlySpaces = true;
|
|
805
|
+
for (let i = 0; i < start; i++) {
|
|
806
|
+
if (isWordChar(arr[i])) {
|
|
807
|
+
onlySpaces = false;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (onlySpaces && start > 0) {
|
|
812
|
+
start--;
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
while (start > 0 && !isWordChar(arr[start - 1]))
|
|
816
|
+
start--;
|
|
817
|
+
while (start > 0 && isWordChar(arr[start - 1]))
|
|
818
|
+
start--;
|
|
819
|
+
}
|
|
820
|
+
newCursorCol = start;
|
|
821
|
+
}
|
|
822
|
+
return {
|
|
823
|
+
...state,
|
|
824
|
+
cursorRow: newCursorRow,
|
|
825
|
+
cursorCol: newCursorCol,
|
|
826
|
+
preferredCol: null,
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
case 'wordRight': {
|
|
830
|
+
const { cursorRow, cursorCol, lines } = state;
|
|
831
|
+
if (cursorRow === lines.length - 1 &&
|
|
832
|
+
cursorCol === cpLen(lines[cursorRow] ?? '')) {
|
|
833
|
+
return state;
|
|
834
|
+
}
|
|
835
|
+
let newCursorRow = cursorRow;
|
|
836
|
+
let newCursorCol = cursorCol;
|
|
837
|
+
const lineContent = lines[cursorRow] ?? '';
|
|
838
|
+
const arr = toCodePoints(lineContent);
|
|
839
|
+
if (cursorCol >= arr.length) {
|
|
840
|
+
newCursorRow++;
|
|
841
|
+
newCursorCol = 0;
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
let end = cursorCol;
|
|
845
|
+
while (end < arr.length && !isWordChar(arr[end]))
|
|
846
|
+
end++;
|
|
847
|
+
while (end < arr.length && isWordChar(arr[end]))
|
|
848
|
+
end++;
|
|
849
|
+
newCursorCol = end;
|
|
850
|
+
}
|
|
851
|
+
return {
|
|
852
|
+
...state,
|
|
853
|
+
cursorRow: newCursorRow,
|
|
854
|
+
cursorCol: newCursorCol,
|
|
855
|
+
preferredCol: null,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
default:
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
if (visualToLogicalMap[newVisualRow]) {
|
|
862
|
+
const [logRow, logStartCol] = visualToLogicalMap[newVisualRow];
|
|
863
|
+
return {
|
|
864
|
+
...state,
|
|
865
|
+
cursorRow: logRow,
|
|
866
|
+
cursorCol: clamp(logStartCol + newVisualCol, 0, cpLen(state.lines[logRow] ?? '')),
|
|
867
|
+
preferredCol: newPreferredCol,
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
return state;
|
|
871
|
+
}
|
|
872
|
+
case 'delete': {
|
|
873
|
+
const { cursorRow, cursorCol, lines } = state;
|
|
874
|
+
const lineContent = currentLine(cursorRow);
|
|
875
|
+
if (cursorCol < currentLineLen(cursorRow)) {
|
|
876
|
+
const nextState = pushUndoLocal(state);
|
|
877
|
+
const newLines = [...nextState.lines];
|
|
878
|
+
newLines[cursorRow] =
|
|
879
|
+
cpSlice(lineContent, 0, cursorCol) +
|
|
880
|
+
cpSlice(lineContent, cursorCol + 1);
|
|
881
|
+
return { ...nextState, lines: newLines, preferredCol: null };
|
|
882
|
+
}
|
|
883
|
+
else if (cursorRow < lines.length - 1) {
|
|
884
|
+
const nextState = pushUndoLocal(state);
|
|
885
|
+
const nextLineContent = currentLine(cursorRow + 1);
|
|
886
|
+
const newLines = [...nextState.lines];
|
|
887
|
+
newLines[cursorRow] = lineContent + nextLineContent;
|
|
888
|
+
newLines.splice(cursorRow + 1, 1);
|
|
889
|
+
return { ...nextState, lines: newLines, preferredCol: null };
|
|
890
|
+
}
|
|
891
|
+
return state;
|
|
892
|
+
}
|
|
893
|
+
case 'delete_word_left': {
|
|
894
|
+
const { cursorRow, cursorCol } = state;
|
|
895
|
+
if (cursorCol === 0 && cursorRow === 0)
|
|
896
|
+
return state;
|
|
897
|
+
if (cursorCol === 0) {
|
|
898
|
+
// Act as a backspace
|
|
899
|
+
const nextState = pushUndoLocal(state);
|
|
900
|
+
const prevLineContent = currentLine(cursorRow - 1);
|
|
901
|
+
const currentLineContentVal = currentLine(cursorRow);
|
|
902
|
+
const newCol = cpLen(prevLineContent);
|
|
903
|
+
const newLines = [...nextState.lines];
|
|
904
|
+
newLines[cursorRow - 1] = prevLineContent + currentLineContentVal;
|
|
905
|
+
newLines.splice(cursorRow, 1);
|
|
906
|
+
return {
|
|
907
|
+
...nextState,
|
|
908
|
+
lines: newLines,
|
|
909
|
+
cursorRow: cursorRow - 1,
|
|
910
|
+
cursorCol: newCol,
|
|
911
|
+
preferredCol: null,
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
const nextState = pushUndoLocal(state);
|
|
915
|
+
const lineContent = currentLine(cursorRow);
|
|
916
|
+
const arr = toCodePoints(lineContent);
|
|
917
|
+
let start = cursorCol;
|
|
918
|
+
let onlySpaces = true;
|
|
919
|
+
for (let i = 0; i < start; i++) {
|
|
920
|
+
if (isWordChar(arr[i])) {
|
|
921
|
+
onlySpaces = false;
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (onlySpaces && start > 0) {
|
|
926
|
+
start--;
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
while (start > 0 && !isWordChar(arr[start - 1]))
|
|
930
|
+
start--;
|
|
931
|
+
while (start > 0 && isWordChar(arr[start - 1]))
|
|
932
|
+
start--;
|
|
933
|
+
}
|
|
934
|
+
const newLines = [...nextState.lines];
|
|
935
|
+
newLines[cursorRow] =
|
|
936
|
+
cpSlice(lineContent, 0, start) + cpSlice(lineContent, cursorCol);
|
|
937
|
+
return {
|
|
938
|
+
...nextState,
|
|
939
|
+
lines: newLines,
|
|
940
|
+
cursorCol: start,
|
|
941
|
+
preferredCol: null,
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
case 'delete_word_right': {
|
|
945
|
+
const { cursorRow, cursorCol, lines } = state;
|
|
946
|
+
const lineContent = currentLine(cursorRow);
|
|
947
|
+
const arr = toCodePoints(lineContent);
|
|
948
|
+
if (cursorCol >= arr.length && cursorRow === lines.length - 1)
|
|
949
|
+
return state;
|
|
950
|
+
if (cursorCol >= arr.length) {
|
|
951
|
+
// Act as a delete
|
|
952
|
+
const nextState = pushUndoLocal(state);
|
|
953
|
+
const nextLineContent = currentLine(cursorRow + 1);
|
|
954
|
+
const newLines = [...nextState.lines];
|
|
955
|
+
newLines[cursorRow] = lineContent + nextLineContent;
|
|
956
|
+
newLines.splice(cursorRow + 1, 1);
|
|
957
|
+
return { ...nextState, lines: newLines, preferredCol: null };
|
|
958
|
+
}
|
|
959
|
+
const nextState = pushUndoLocal(state);
|
|
960
|
+
let end = cursorCol;
|
|
961
|
+
while (end < arr.length && !isWordChar(arr[end]))
|
|
962
|
+
end++;
|
|
963
|
+
while (end < arr.length && isWordChar(arr[end]))
|
|
964
|
+
end++;
|
|
965
|
+
const newLines = [...nextState.lines];
|
|
966
|
+
newLines[cursorRow] =
|
|
967
|
+
cpSlice(lineContent, 0, cursorCol) + cpSlice(lineContent, end);
|
|
968
|
+
return { ...nextState, lines: newLines, preferredCol: null };
|
|
969
|
+
}
|
|
970
|
+
case 'kill_line_right': {
|
|
971
|
+
const { cursorRow, cursorCol, lines } = state;
|
|
972
|
+
const lineContent = currentLine(cursorRow);
|
|
973
|
+
if (cursorCol < currentLineLen(cursorRow)) {
|
|
974
|
+
const nextState = pushUndoLocal(state);
|
|
975
|
+
const newLines = [...nextState.lines];
|
|
976
|
+
newLines[cursorRow] = cpSlice(lineContent, 0, cursorCol);
|
|
977
|
+
return { ...nextState, lines: newLines };
|
|
978
|
+
}
|
|
979
|
+
else if (cursorRow < lines.length - 1) {
|
|
980
|
+
// Act as a delete
|
|
981
|
+
const nextState = pushUndoLocal(state);
|
|
982
|
+
const nextLineContent = currentLine(cursorRow + 1);
|
|
983
|
+
const newLines = [...nextState.lines];
|
|
984
|
+
newLines[cursorRow] = lineContent + nextLineContent;
|
|
985
|
+
newLines.splice(cursorRow + 1, 1);
|
|
986
|
+
return { ...nextState, lines: newLines, preferredCol: null };
|
|
987
|
+
}
|
|
988
|
+
return state;
|
|
989
|
+
}
|
|
990
|
+
case 'kill_line_left': {
|
|
991
|
+
const { cursorRow, cursorCol } = state;
|
|
992
|
+
if (cursorCol > 0) {
|
|
993
|
+
const nextState = pushUndoLocal(state);
|
|
994
|
+
const lineContent = currentLine(cursorRow);
|
|
995
|
+
const newLines = [...nextState.lines];
|
|
996
|
+
newLines[cursorRow] = cpSlice(lineContent, cursorCol);
|
|
997
|
+
return {
|
|
998
|
+
...nextState,
|
|
999
|
+
lines: newLines,
|
|
1000
|
+
cursorCol: 0,
|
|
1001
|
+
preferredCol: null,
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return state;
|
|
1005
|
+
}
|
|
1006
|
+
case 'undo': {
|
|
1007
|
+
const stateToRestore = state.undoStack[state.undoStack.length - 1];
|
|
1008
|
+
if (!stateToRestore)
|
|
1009
|
+
return state;
|
|
1010
|
+
const currentSnapshot = {
|
|
1011
|
+
lines: [...state.lines],
|
|
1012
|
+
cursorRow: state.cursorRow,
|
|
1013
|
+
cursorCol: state.cursorCol,
|
|
1014
|
+
};
|
|
1015
|
+
return {
|
|
1016
|
+
...state,
|
|
1017
|
+
...stateToRestore,
|
|
1018
|
+
undoStack: state.undoStack.slice(0, -1),
|
|
1019
|
+
redoStack: [...state.redoStack, currentSnapshot],
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
case 'redo': {
|
|
1023
|
+
const stateToRestore = state.redoStack[state.redoStack.length - 1];
|
|
1024
|
+
if (!stateToRestore)
|
|
1025
|
+
return state;
|
|
1026
|
+
const currentSnapshot = {
|
|
1027
|
+
lines: [...state.lines],
|
|
1028
|
+
cursorRow: state.cursorRow,
|
|
1029
|
+
cursorCol: state.cursorCol,
|
|
1030
|
+
};
|
|
1031
|
+
return {
|
|
1032
|
+
...state,
|
|
1033
|
+
...stateToRestore,
|
|
1034
|
+
redoStack: state.redoStack.slice(0, -1),
|
|
1035
|
+
undoStack: [...state.undoStack, currentSnapshot],
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
case 'replace_range': {
|
|
1039
|
+
const { startRow, startCol, endRow, endCol, text } = action.payload;
|
|
1040
|
+
const nextState = pushUndoLocal(state);
|
|
1041
|
+
return replaceRangeInternal(nextState, startRow, startCol, endRow, endCol, text);
|
|
1042
|
+
}
|
|
1043
|
+
case 'move_to_offset': {
|
|
1044
|
+
const { offset } = action.payload;
|
|
1045
|
+
const [newRow, newCol] = offsetToLogicalPos(state.lines.join('\n'), offset);
|
|
1046
|
+
return {
|
|
1047
|
+
...state,
|
|
1048
|
+
cursorRow: newRow,
|
|
1049
|
+
cursorCol: newCol,
|
|
1050
|
+
preferredCol: null,
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
case 'create_undo_snapshot': {
|
|
1054
|
+
return pushUndoLocal(state);
|
|
1055
|
+
}
|
|
1056
|
+
// Vim-specific operations
|
|
1057
|
+
case 'vim_delete_word_forward':
|
|
1058
|
+
case 'vim_delete_word_backward':
|
|
1059
|
+
case 'vim_delete_word_end':
|
|
1060
|
+
case 'vim_change_word_forward':
|
|
1061
|
+
case 'vim_change_word_backward':
|
|
1062
|
+
case 'vim_change_word_end':
|
|
1063
|
+
case 'vim_delete_line':
|
|
1064
|
+
case 'vim_change_line':
|
|
1065
|
+
case 'vim_delete_to_end_of_line':
|
|
1066
|
+
case 'vim_change_to_end_of_line':
|
|
1067
|
+
case 'vim_change_movement':
|
|
1068
|
+
case 'vim_move_left':
|
|
1069
|
+
case 'vim_move_right':
|
|
1070
|
+
case 'vim_move_up':
|
|
1071
|
+
case 'vim_move_down':
|
|
1072
|
+
case 'vim_move_word_forward':
|
|
1073
|
+
case 'vim_move_word_backward':
|
|
1074
|
+
case 'vim_move_word_end':
|
|
1075
|
+
case 'vim_delete_char':
|
|
1076
|
+
case 'vim_insert_at_cursor':
|
|
1077
|
+
case 'vim_append_at_cursor':
|
|
1078
|
+
case 'vim_open_line_below':
|
|
1079
|
+
case 'vim_open_line_above':
|
|
1080
|
+
case 'vim_append_at_line_end':
|
|
1081
|
+
case 'vim_insert_at_line_start':
|
|
1082
|
+
case 'vim_move_to_line_start':
|
|
1083
|
+
case 'vim_move_to_line_end':
|
|
1084
|
+
case 'vim_move_to_first_nonwhitespace':
|
|
1085
|
+
case 'vim_move_to_first_line':
|
|
1086
|
+
case 'vim_move_to_last_line':
|
|
1087
|
+
case 'vim_move_to_line':
|
|
1088
|
+
case 'vim_escape_insert_mode':
|
|
1089
|
+
return handleVimAction(state, action);
|
|
1090
|
+
default: {
|
|
1091
|
+
const exhaustiveCheck = action;
|
|
1092
|
+
console.error(`Unknown action encountered: ${exhaustiveCheck}`);
|
|
1093
|
+
return state;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
// --- End of reducer logic ---
|
|
1098
|
+
export function useTextBuffer({ initialText = '', initialCursorOffset = 0, viewport, stdin, setRawMode, onChange, isValidPath, shellModeActive = false, }) {
|
|
1099
|
+
const initialState = useMemo(() => {
|
|
1100
|
+
const lines = initialText.split('\n');
|
|
1101
|
+
const [initialCursorRow, initialCursorCol] = calculateInitialCursorPosition(lines.length === 0 ? [''] : lines, initialCursorOffset);
|
|
1102
|
+
return {
|
|
1103
|
+
lines: lines.length === 0 ? [''] : lines,
|
|
1104
|
+
cursorRow: initialCursorRow,
|
|
1105
|
+
cursorCol: initialCursorCol,
|
|
1106
|
+
preferredCol: null,
|
|
1107
|
+
undoStack: [],
|
|
1108
|
+
redoStack: [],
|
|
1109
|
+
clipboard: null,
|
|
1110
|
+
selectionAnchor: null,
|
|
1111
|
+
viewportWidth: viewport.width,
|
|
1112
|
+
};
|
|
1113
|
+
}, [initialText, initialCursorOffset, viewport.width]);
|
|
1114
|
+
const [state, dispatch] = useReducer(textBufferReducer, initialState);
|
|
1115
|
+
const { lines, cursorRow, cursorCol, preferredCol, selectionAnchor } = state;
|
|
1116
|
+
const text = useMemo(() => lines.join('\n'), [lines]);
|
|
1117
|
+
const visualLayout = useMemo(() => calculateVisualLayout(lines, [cursorRow, cursorCol], state.viewportWidth), [lines, cursorRow, cursorCol, state.viewportWidth]);
|
|
1118
|
+
const { visualLines, visualCursor } = visualLayout;
|
|
1119
|
+
const [visualScrollRow, setVisualScrollRow] = useState(0);
|
|
1120
|
+
useEffect(() => {
|
|
1121
|
+
if (onChange) {
|
|
1122
|
+
onChange(text);
|
|
1123
|
+
}
|
|
1124
|
+
}, [text, onChange]);
|
|
1125
|
+
useEffect(() => {
|
|
1126
|
+
dispatch({ type: 'set_viewport_width', payload: viewport.width });
|
|
1127
|
+
}, [viewport.width]);
|
|
1128
|
+
// Update visual scroll (vertical)
|
|
1129
|
+
useEffect(() => {
|
|
1130
|
+
const { height } = viewport;
|
|
1131
|
+
let newVisualScrollRow = visualScrollRow;
|
|
1132
|
+
if (visualCursor[0] < visualScrollRow) {
|
|
1133
|
+
newVisualScrollRow = visualCursor[0];
|
|
1134
|
+
}
|
|
1135
|
+
else if (visualCursor[0] >= visualScrollRow + height) {
|
|
1136
|
+
newVisualScrollRow = visualCursor[0] - height + 1;
|
|
1137
|
+
}
|
|
1138
|
+
if (newVisualScrollRow !== visualScrollRow) {
|
|
1139
|
+
setVisualScrollRow(newVisualScrollRow);
|
|
1140
|
+
}
|
|
1141
|
+
}, [visualCursor, visualScrollRow, viewport]);
|
|
1142
|
+
const insert = useCallback((ch, { paste = false } = {}) => {
|
|
1143
|
+
if (/[\n\r]/.test(ch)) {
|
|
1144
|
+
dispatch({ type: 'insert', payload: ch });
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
const minLengthToInferAsDragDrop = 3;
|
|
1148
|
+
if (ch.length >= minLengthToInferAsDragDrop &&
|
|
1149
|
+
!shellModeActive &&
|
|
1150
|
+
paste) {
|
|
1151
|
+
let potentialPath = ch.trim();
|
|
1152
|
+
const quoteMatch = potentialPath.match(/^'(.*)'$/);
|
|
1153
|
+
if (quoteMatch) {
|
|
1154
|
+
potentialPath = quoteMatch[1];
|
|
1155
|
+
}
|
|
1156
|
+
potentialPath = potentialPath.trim();
|
|
1157
|
+
if (isValidPath(unescapePath(potentialPath))) {
|
|
1158
|
+
ch = `@${potentialPath} `;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
let currentText = '';
|
|
1162
|
+
for (const char of toCodePoints(ch)) {
|
|
1163
|
+
if (char.codePointAt(0) === 127) {
|
|
1164
|
+
if (currentText.length > 0) {
|
|
1165
|
+
dispatch({ type: 'insert', payload: currentText });
|
|
1166
|
+
currentText = '';
|
|
1167
|
+
}
|
|
1168
|
+
dispatch({ type: 'backspace' });
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
currentText += char;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (currentText.length > 0) {
|
|
1175
|
+
dispatch({ type: 'insert', payload: currentText });
|
|
1176
|
+
}
|
|
1177
|
+
}, [isValidPath, shellModeActive]);
|
|
1178
|
+
const newline = useCallback(() => {
|
|
1179
|
+
dispatch({ type: 'insert', payload: '\n' });
|
|
1180
|
+
}, []);
|
|
1181
|
+
const backspace = useCallback(() => {
|
|
1182
|
+
dispatch({ type: 'backspace' });
|
|
1183
|
+
}, []);
|
|
1184
|
+
const del = useCallback(() => {
|
|
1185
|
+
dispatch({ type: 'delete' });
|
|
1186
|
+
}, []);
|
|
1187
|
+
const move = useCallback((dir) => {
|
|
1188
|
+
dispatch({ type: 'move', payload: { dir } });
|
|
1189
|
+
}, []);
|
|
1190
|
+
const undo = useCallback(() => {
|
|
1191
|
+
dispatch({ type: 'undo' });
|
|
1192
|
+
}, []);
|
|
1193
|
+
const redo = useCallback(() => {
|
|
1194
|
+
dispatch({ type: 'redo' });
|
|
1195
|
+
}, []);
|
|
1196
|
+
const setText = useCallback((newText) => {
|
|
1197
|
+
dispatch({ type: 'set_text', payload: newText });
|
|
1198
|
+
}, []);
|
|
1199
|
+
const deleteWordLeft = useCallback(() => {
|
|
1200
|
+
dispatch({ type: 'delete_word_left' });
|
|
1201
|
+
}, []);
|
|
1202
|
+
const deleteWordRight = useCallback(() => {
|
|
1203
|
+
dispatch({ type: 'delete_word_right' });
|
|
1204
|
+
}, []);
|
|
1205
|
+
const killLineRight = useCallback(() => {
|
|
1206
|
+
dispatch({ type: 'kill_line_right' });
|
|
1207
|
+
}, []);
|
|
1208
|
+
const killLineLeft = useCallback(() => {
|
|
1209
|
+
dispatch({ type: 'kill_line_left' });
|
|
1210
|
+
}, []);
|
|
1211
|
+
// Vim-specific operations
|
|
1212
|
+
const vimDeleteWordForward = useCallback((count) => {
|
|
1213
|
+
dispatch({ type: 'vim_delete_word_forward', payload: { count } });
|
|
1214
|
+
}, []);
|
|
1215
|
+
const vimDeleteWordBackward = useCallback((count) => {
|
|
1216
|
+
dispatch({ type: 'vim_delete_word_backward', payload: { count } });
|
|
1217
|
+
}, []);
|
|
1218
|
+
const vimDeleteWordEnd = useCallback((count) => {
|
|
1219
|
+
dispatch({ type: 'vim_delete_word_end', payload: { count } });
|
|
1220
|
+
}, []);
|
|
1221
|
+
const vimChangeWordForward = useCallback((count) => {
|
|
1222
|
+
dispatch({ type: 'vim_change_word_forward', payload: { count } });
|
|
1223
|
+
}, []);
|
|
1224
|
+
const vimChangeWordBackward = useCallback((count) => {
|
|
1225
|
+
dispatch({ type: 'vim_change_word_backward', payload: { count } });
|
|
1226
|
+
}, []);
|
|
1227
|
+
const vimChangeWordEnd = useCallback((count) => {
|
|
1228
|
+
dispatch({ type: 'vim_change_word_end', payload: { count } });
|
|
1229
|
+
}, []);
|
|
1230
|
+
const vimDeleteLine = useCallback((count) => {
|
|
1231
|
+
dispatch({ type: 'vim_delete_line', payload: { count } });
|
|
1232
|
+
}, []);
|
|
1233
|
+
const vimChangeLine = useCallback((count) => {
|
|
1234
|
+
dispatch({ type: 'vim_change_line', payload: { count } });
|
|
1235
|
+
}, []);
|
|
1236
|
+
const vimDeleteToEndOfLine = useCallback(() => {
|
|
1237
|
+
dispatch({ type: 'vim_delete_to_end_of_line' });
|
|
1238
|
+
}, []);
|
|
1239
|
+
const vimChangeToEndOfLine = useCallback(() => {
|
|
1240
|
+
dispatch({ type: 'vim_change_to_end_of_line' });
|
|
1241
|
+
}, []);
|
|
1242
|
+
const vimChangeMovement = useCallback((movement, count) => {
|
|
1243
|
+
dispatch({ type: 'vim_change_movement', payload: { movement, count } });
|
|
1244
|
+
}, []);
|
|
1245
|
+
// New vim navigation and operation methods
|
|
1246
|
+
const vimMoveLeft = useCallback((count) => {
|
|
1247
|
+
dispatch({ type: 'vim_move_left', payload: { count } });
|
|
1248
|
+
}, []);
|
|
1249
|
+
const vimMoveRight = useCallback((count) => {
|
|
1250
|
+
dispatch({ type: 'vim_move_right', payload: { count } });
|
|
1251
|
+
}, []);
|
|
1252
|
+
const vimMoveUp = useCallback((count) => {
|
|
1253
|
+
dispatch({ type: 'vim_move_up', payload: { count } });
|
|
1254
|
+
}, []);
|
|
1255
|
+
const vimMoveDown = useCallback((count) => {
|
|
1256
|
+
dispatch({ type: 'vim_move_down', payload: { count } });
|
|
1257
|
+
}, []);
|
|
1258
|
+
const vimMoveWordForward = useCallback((count) => {
|
|
1259
|
+
dispatch({ type: 'vim_move_word_forward', payload: { count } });
|
|
1260
|
+
}, []);
|
|
1261
|
+
const vimMoveWordBackward = useCallback((count) => {
|
|
1262
|
+
dispatch({ type: 'vim_move_word_backward', payload: { count } });
|
|
1263
|
+
}, []);
|
|
1264
|
+
const vimMoveWordEnd = useCallback((count) => {
|
|
1265
|
+
dispatch({ type: 'vim_move_word_end', payload: { count } });
|
|
1266
|
+
}, []);
|
|
1267
|
+
const vimDeleteChar = useCallback((count) => {
|
|
1268
|
+
dispatch({ type: 'vim_delete_char', payload: { count } });
|
|
1269
|
+
}, []);
|
|
1270
|
+
const vimInsertAtCursor = useCallback(() => {
|
|
1271
|
+
dispatch({ type: 'vim_insert_at_cursor' });
|
|
1272
|
+
}, []);
|
|
1273
|
+
const vimAppendAtCursor = useCallback(() => {
|
|
1274
|
+
dispatch({ type: 'vim_append_at_cursor' });
|
|
1275
|
+
}, []);
|
|
1276
|
+
const vimOpenLineBelow = useCallback(() => {
|
|
1277
|
+
dispatch({ type: 'vim_open_line_below' });
|
|
1278
|
+
}, []);
|
|
1279
|
+
const vimOpenLineAbove = useCallback(() => {
|
|
1280
|
+
dispatch({ type: 'vim_open_line_above' });
|
|
1281
|
+
}, []);
|
|
1282
|
+
const vimAppendAtLineEnd = useCallback(() => {
|
|
1283
|
+
dispatch({ type: 'vim_append_at_line_end' });
|
|
1284
|
+
}, []);
|
|
1285
|
+
const vimInsertAtLineStart = useCallback(() => {
|
|
1286
|
+
dispatch({ type: 'vim_insert_at_line_start' });
|
|
1287
|
+
}, []);
|
|
1288
|
+
const vimMoveToLineStart = useCallback(() => {
|
|
1289
|
+
dispatch({ type: 'vim_move_to_line_start' });
|
|
1290
|
+
}, []);
|
|
1291
|
+
const vimMoveToLineEnd = useCallback(() => {
|
|
1292
|
+
dispatch({ type: 'vim_move_to_line_end' });
|
|
1293
|
+
}, []);
|
|
1294
|
+
const vimMoveToFirstNonWhitespace = useCallback(() => {
|
|
1295
|
+
dispatch({ type: 'vim_move_to_first_nonwhitespace' });
|
|
1296
|
+
}, []);
|
|
1297
|
+
const vimMoveToFirstLine = useCallback(() => {
|
|
1298
|
+
dispatch({ type: 'vim_move_to_first_line' });
|
|
1299
|
+
}, []);
|
|
1300
|
+
const vimMoveToLastLine = useCallback(() => {
|
|
1301
|
+
dispatch({ type: 'vim_move_to_last_line' });
|
|
1302
|
+
}, []);
|
|
1303
|
+
const vimMoveToLine = useCallback((lineNumber) => {
|
|
1304
|
+
dispatch({ type: 'vim_move_to_line', payload: { lineNumber } });
|
|
1305
|
+
}, []);
|
|
1306
|
+
const vimEscapeInsertMode = useCallback(() => {
|
|
1307
|
+
dispatch({ type: 'vim_escape_insert_mode' });
|
|
1308
|
+
}, []);
|
|
1309
|
+
const openInExternalEditor = useCallback(async (opts = {}) => {
|
|
1310
|
+
const editor = opts.editor ??
|
|
1311
|
+
process.env['VISUAL'] ??
|
|
1312
|
+
process.env['EDITOR'] ??
|
|
1313
|
+
(process.platform === 'win32' ? 'notepad' : 'vi');
|
|
1314
|
+
const tmpDir = fs.mkdtempSync(pathMod.join(os.tmpdir(), 'gemini-edit-'));
|
|
1315
|
+
const filePath = pathMod.join(tmpDir, 'buffer.txt');
|
|
1316
|
+
fs.writeFileSync(filePath, text, 'utf8');
|
|
1317
|
+
dispatch({ type: 'create_undo_snapshot' });
|
|
1318
|
+
const wasRaw = stdin?.isRaw ?? false;
|
|
1319
|
+
try {
|
|
1320
|
+
setRawMode?.(false);
|
|
1321
|
+
const { status, error } = spawnSync(editor, [filePath], {
|
|
1322
|
+
stdio: 'inherit',
|
|
1323
|
+
});
|
|
1324
|
+
if (error)
|
|
1325
|
+
throw error;
|
|
1326
|
+
if (typeof status === 'number' && status !== 0)
|
|
1327
|
+
throw new Error(`External editor exited with status ${status}`);
|
|
1328
|
+
let newText = fs.readFileSync(filePath, 'utf8');
|
|
1329
|
+
newText = newText.replace(/\r\n?/g, '\n');
|
|
1330
|
+
dispatch({ type: 'set_text', payload: newText, pushToUndo: false });
|
|
1331
|
+
}
|
|
1332
|
+
catch (err) {
|
|
1333
|
+
console.error('[useTextBuffer] external editor error', err);
|
|
1334
|
+
}
|
|
1335
|
+
finally {
|
|
1336
|
+
if (wasRaw)
|
|
1337
|
+
setRawMode?.(true);
|
|
1338
|
+
try {
|
|
1339
|
+
fs.unlinkSync(filePath);
|
|
1340
|
+
}
|
|
1341
|
+
catch {
|
|
1342
|
+
/* ignore */
|
|
1343
|
+
}
|
|
1344
|
+
try {
|
|
1345
|
+
fs.rmdirSync(tmpDir);
|
|
1346
|
+
}
|
|
1347
|
+
catch {
|
|
1348
|
+
/* ignore */
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}, [text, stdin, setRawMode]);
|
|
1352
|
+
const handleInput = useCallback((key) => {
|
|
1353
|
+
const { sequence: input } = key;
|
|
1354
|
+
if (key.paste) {
|
|
1355
|
+
// Do not do any other processing on pastes so ensure we handle them
|
|
1356
|
+
// before all other cases.
|
|
1357
|
+
insert(input, { paste: key.paste });
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1360
|
+
if (key.name === 'return' ||
|
|
1361
|
+
input === '\r' ||
|
|
1362
|
+
input === '\n' ||
|
|
1363
|
+
input === '\\\r' // VSCode terminal represents shift + enter this way
|
|
1364
|
+
)
|
|
1365
|
+
newline();
|
|
1366
|
+
else if (key.name === 'left' && !key.meta && !key.ctrl)
|
|
1367
|
+
move('left');
|
|
1368
|
+
else if (key.ctrl && key.name === 'b')
|
|
1369
|
+
move('left');
|
|
1370
|
+
else if (key.name === 'right' && !key.meta && !key.ctrl)
|
|
1371
|
+
move('right');
|
|
1372
|
+
else if (key.ctrl && key.name === 'f')
|
|
1373
|
+
move('right');
|
|
1374
|
+
else if (key.name === 'up')
|
|
1375
|
+
move('up');
|
|
1376
|
+
else if (key.name === 'down')
|
|
1377
|
+
move('down');
|
|
1378
|
+
else if ((key.ctrl || key.meta) && key.name === 'left')
|
|
1379
|
+
move('wordLeft');
|
|
1380
|
+
else if (key.meta && key.name === 'b')
|
|
1381
|
+
move('wordLeft');
|
|
1382
|
+
else if ((key.ctrl || key.meta) && key.name === 'right')
|
|
1383
|
+
move('wordRight');
|
|
1384
|
+
else if (key.meta && key.name === 'f')
|
|
1385
|
+
move('wordRight');
|
|
1386
|
+
else if (key.name === 'home')
|
|
1387
|
+
move('home');
|
|
1388
|
+
else if (key.ctrl && key.name === 'a')
|
|
1389
|
+
move('home');
|
|
1390
|
+
else if (key.name === 'end')
|
|
1391
|
+
move('end');
|
|
1392
|
+
else if (key.ctrl && key.name === 'e')
|
|
1393
|
+
move('end');
|
|
1394
|
+
else if (key.ctrl && key.name === 'w')
|
|
1395
|
+
deleteWordLeft();
|
|
1396
|
+
else if ((key.meta || key.ctrl) &&
|
|
1397
|
+
(key.name === 'backspace' || input === '\x7f'))
|
|
1398
|
+
deleteWordLeft();
|
|
1399
|
+
else if ((key.meta || key.ctrl) && key.name === 'delete')
|
|
1400
|
+
deleteWordRight();
|
|
1401
|
+
else if (key.name === 'backspace' ||
|
|
1402
|
+
input === '\x7f' ||
|
|
1403
|
+
(key.ctrl && key.name === 'h'))
|
|
1404
|
+
backspace();
|
|
1405
|
+
else if (key.name === 'delete' || (key.ctrl && key.name === 'd'))
|
|
1406
|
+
del();
|
|
1407
|
+
else if (input && !key.ctrl && !key.meta) {
|
|
1408
|
+
insert(input, { paste: key.paste });
|
|
1409
|
+
}
|
|
1410
|
+
}, [newline, move, deleteWordLeft, deleteWordRight, backspace, del, insert]);
|
|
1411
|
+
const renderedVisualLines = useMemo(() => visualLines.slice(visualScrollRow, visualScrollRow + viewport.height), [visualLines, visualScrollRow, viewport.height]);
|
|
1412
|
+
const replaceRange = useCallback((startRow, startCol, endRow, endCol, text) => {
|
|
1413
|
+
dispatch({
|
|
1414
|
+
type: 'replace_range',
|
|
1415
|
+
payload: { startRow, startCol, endRow, endCol, text },
|
|
1416
|
+
});
|
|
1417
|
+
}, []);
|
|
1418
|
+
const replaceRangeByOffset = useCallback((startOffset, endOffset, replacementText) => {
|
|
1419
|
+
const [startRow, startCol] = offsetToLogicalPos(text, startOffset);
|
|
1420
|
+
const [endRow, endCol] = offsetToLogicalPos(text, endOffset);
|
|
1421
|
+
replaceRange(startRow, startCol, endRow, endCol, replacementText);
|
|
1422
|
+
}, [text, replaceRange]);
|
|
1423
|
+
const moveToOffset = useCallback((offset) => {
|
|
1424
|
+
dispatch({ type: 'move_to_offset', payload: { offset } });
|
|
1425
|
+
}, []);
|
|
1426
|
+
const returnValue = {
|
|
1427
|
+
lines,
|
|
1428
|
+
text,
|
|
1429
|
+
cursor: [cursorRow, cursorCol],
|
|
1430
|
+
preferredCol,
|
|
1431
|
+
selectionAnchor,
|
|
1432
|
+
allVisualLines: visualLines,
|
|
1433
|
+
viewportVisualLines: renderedVisualLines,
|
|
1434
|
+
visualCursor,
|
|
1435
|
+
visualScrollRow,
|
|
1436
|
+
setText,
|
|
1437
|
+
insert,
|
|
1438
|
+
newline,
|
|
1439
|
+
backspace,
|
|
1440
|
+
del,
|
|
1441
|
+
move,
|
|
1442
|
+
undo,
|
|
1443
|
+
redo,
|
|
1444
|
+
replaceRange,
|
|
1445
|
+
replaceRangeByOffset,
|
|
1446
|
+
moveToOffset,
|
|
1447
|
+
deleteWordLeft,
|
|
1448
|
+
deleteWordRight,
|
|
1449
|
+
killLineRight,
|
|
1450
|
+
killLineLeft,
|
|
1451
|
+
handleInput,
|
|
1452
|
+
openInExternalEditor,
|
|
1453
|
+
// Vim-specific operations
|
|
1454
|
+
vimDeleteWordForward,
|
|
1455
|
+
vimDeleteWordBackward,
|
|
1456
|
+
vimDeleteWordEnd,
|
|
1457
|
+
vimChangeWordForward,
|
|
1458
|
+
vimChangeWordBackward,
|
|
1459
|
+
vimChangeWordEnd,
|
|
1460
|
+
vimDeleteLine,
|
|
1461
|
+
vimChangeLine,
|
|
1462
|
+
vimDeleteToEndOfLine,
|
|
1463
|
+
vimChangeToEndOfLine,
|
|
1464
|
+
vimChangeMovement,
|
|
1465
|
+
vimMoveLeft,
|
|
1466
|
+
vimMoveRight,
|
|
1467
|
+
vimMoveUp,
|
|
1468
|
+
vimMoveDown,
|
|
1469
|
+
vimMoveWordForward,
|
|
1470
|
+
vimMoveWordBackward,
|
|
1471
|
+
vimMoveWordEnd,
|
|
1472
|
+
vimDeleteChar,
|
|
1473
|
+
vimInsertAtCursor,
|
|
1474
|
+
vimAppendAtCursor,
|
|
1475
|
+
vimOpenLineBelow,
|
|
1476
|
+
vimOpenLineAbove,
|
|
1477
|
+
vimAppendAtLineEnd,
|
|
1478
|
+
vimInsertAtLineStart,
|
|
1479
|
+
vimMoveToLineStart,
|
|
1480
|
+
vimMoveToLineEnd,
|
|
1481
|
+
vimMoveToFirstNonWhitespace,
|
|
1482
|
+
vimMoveToFirstLine,
|
|
1483
|
+
vimMoveToLastLine,
|
|
1484
|
+
vimMoveToLine,
|
|
1485
|
+
vimEscapeInsertMode,
|
|
1486
|
+
};
|
|
1487
|
+
return returnValue;
|
|
1488
|
+
}
|
|
1489
|
+
//# sourceMappingURL=text-buffer.js.map
|