← back to debugtheworldbot__vimIn

Function bodies 32 total

All specs Real LLM only Function bodies
getInitialTheme function · typescript · L14-L18 (5 LOC)
src/App.tsx
function getInitialTheme(): ThemeMode {
  const saved = localStorage.getItem("theme");
  if (saved === "dark" || saved === "light") return saved;
  return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
formatShortcutDisplay function · typescript · L20-L28 (9 LOC)
src/App.tsx
function formatShortcutDisplay(shortcut: string): string {
  return shortcut
    .replace(/Alt/g, "⌥")
    .replace(/Shift/g, "⇧")
    .replace(/Control/g, "⌃")
    .replace(/Meta/g, "⌘")
    .replace(/Cmd/g, "⌘")
    .replace(/\+/g, " ");
}
App function · typescript · L30-L236 (207 LOC)
src/App.tsx
function App() {
  const [mode, setMode] = useState("NORMAL");
  const [copied, setCopied] = useState(false);
  const [showSettings, setShowSettings] = useState(false);
  const [currentShortcut, setCurrentShortcut] = useState(DEFAULT_SHORTCUT);
  const [theme, setTheme] = useState<ThemeMode>(getInitialTheme);
  const [visibilitySettings, setVisibilitySettings] = useState<VisibilitySettings>({
    hide_menu_bar_icon: false,
  });

  const themeStyles = theme === "dark"
    ? {
        appBackground: "rgba(19, 20, 23, 0.55)",
        border: "1px solid rgba(255, 255, 255, 0.08)",
        shadow: "0 10px 24px rgba(0, 0, 0, 0.08), 0 28px 90px rgba(0, 0, 0, 0.24), 0 48px 140px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.16)",
      }
    : {
        appBackground: "rgba(255, 255, 255, 0.18)",
        border: "1px solid rgba(255, 255, 255, 0.22)",
        shadow: "0 8px 20px rgba(15, 23, 42, 0.06), 0 26px 80px rgba(15, 23, 42, 0.12), 0 42px 130px rgba(15, 23, 42, 0.08), inset 0 
keyToCode function · typescript · L17-L70 (54 LOC)
src/components/ShortcutRecorder.tsx
function keyToCode(key: string, code: string): string | null {
  // Letter keys
  if (/^Key([A-Z])$/.test(code)) {
    return code.replace("Key", "");
  }
  // Digit keys
  if (/^Digit(\d)$/.test(code)) {
    return code.replace("Digit", "");
  }
  // Function keys
  if (/^F(\d+)$/.test(key)) {
    return key;
  }
  // Special keys mapping
  const specialMap: Record<string, string> = {
    " ": "Space",
    Space: "Space",
    Enter: "Enter",
    Tab: "Tab",
    Escape: "Escape",
    Backspace: "Backspace",
    Delete: "Delete",
    ArrowUp: "Up",
    ArrowDown: "Down",
    ArrowLeft: "Left",
    ArrowRight: "Right",
    Home: "Home",
    End: "End",
    PageUp: "PageUp",
    PageDown: "PageDown",
    Insert: "Insert",
    Minus: "-",
    Equal: "=",
    BracketLeft: "[",
    BracketRight: "]",
    Backslash: "\\",
    Semicolon: ";",
    Quote: "'",
    Comma: ",",
    Period: ".",
    Slash: "/",
    Backquote: "`",
  };

  if (specialMap[key]) return specialMap[key];
  if (specialMa
formatShortcutDisplay function · typescript · L72-L80 (9 LOC)
src/components/ShortcutRecorder.tsx
function formatShortcutDisplay(shortcut: string): string {
  return shortcut
    .replace(/Alt/g, "⌥")
    .replace(/Shift/g, "⇧")
    .replace(/Control/g, "⌃")
    .replace(/Meta/g, "⌘")
    .replace(/Cmd/g, "⌘")
    .replace(/\+/g, " ");
}
ShortcutRecorder function · typescript · L82-L452 (371 LOC)
src/components/ShortcutRecorder.tsx
export default function ShortcutRecorder({
  currentShortcut,
  onShortcutChange,
  visibilitySettings,
  onVisibilitySettingsChange,
  onClose,
  theme,
}: ShortcutRecorderProps) {
  const [recording, setRecording] = useState(false);
  const [pendingShortcut, setPendingShortcut] = useState<string | null>(null);
  const recorderRef = useRef<HTMLDivElement>(null);
  const isDark = theme === "dark";
  const colors = isDark
    ? {
        overlay: "rgba(0, 0, 0, 0.6)",
        modal: "rgba(39, 39, 42, 0.98)",
        border: "1px solid rgba(255, 255, 255, 0.1)",
        subtleBorder: "1px solid rgba(255, 255, 255, 0.06)",
        title: "#e4e4e7",
        body: "#71717a",
        displayBorder: "1px solid rgba(255, 255, 255, 0.12)",
        displayBg: "rgba(255, 255, 255, 0.04)",
        text: "#e4e4e7",
        muted: "#52525b",
        buttonBorder: "1px solid rgba(255, 255, 255, 0.1)",
        buttonText: "#a1a1aa",
        buttonHover: "rgba(255, 255, 255, 0.06)",
      }
    : {
   
StatusBar function · typescript · L16-L167 (152 LOC)
src/components/StatusBar.tsx
export default function StatusBar({ mode, copied, onCopyClick, theme }: StatusBarProps) {
  const modeColor = modeColors[mode] || "#a78bfa";
  const isDark = theme === "dark";
  const colors = isDark
    ? {
        background: "rgba(255, 255, 255, 0.04)",
        border: "1px solid rgba(255, 255, 255, 0.08)",
        appText: "rgba(255, 255, 255, 0.5)",
        hintText: "rgba(255, 255, 255, 0.3)",
        buttonBg: "rgba(255, 255, 255, 0.08)",
        buttonBgHover: "rgba(255, 255, 255, 0.14)",
        buttonText: "rgba(255, 255, 255, 0.72)",
        buttonTextHover: "#ffffff",
        kbdBg: "rgba(255, 255, 255, 0.09)",
        kbdBorder: "1px solid rgba(255, 255, 255, 0.12)",
        kbdText: "rgba(255, 255, 255, 0.46)",
      }
    : {
        background: "rgba(255, 255, 255, 0.08)",
        border: "1px solid rgba(255, 255, 255, 0.34)",
        appText: "rgba(17, 24, 39, 0.48)",
        hintText: "rgba(17, 24, 39, 0.32)",
        buttonBg: "rgba(99, 102, 241, 0.18)",
        butt
Open data scored by Repobility · https://repobility.com
TitleBar function · typescript · L11-L250 (240 LOC)
src/components/TitleBar.tsx
export default function TitleBar({
  onClose,
  onSettingsClick,
  shortcutDisplay,
  theme,
  onThemeToggle,
}: TitleBarProps) {
  const [isCloseHovered, setIsCloseHovered] = useState(false);
  const isDark = theme === "dark";
  const colors = isDark
    ? {
        background: "rgba(255, 255, 255, 0.04)",
        border: "1px solid rgba(255, 255, 255, 0.08)",
        title: "rgba(255, 255, 255, 0.56)",
        shortcut: "rgba(255, 255, 255, 0.32)",
        icon: "rgba(255, 255, 255, 0.42)",
        iconHover: "rgba(255, 255, 255, 0.82)",
        iconHoverBg: "rgba(255, 255, 255, 0.06)",
        trafficIdle: "rgba(255, 255, 255, 0.1)",
      }
    : {
        background: "rgba(255, 255, 255, 0.1)",
        border: "1px solid rgba(255, 255, 255, 0.38)",
        title: "rgba(17, 24, 39, 0.62)",
        shortcut: "rgba(17, 24, 39, 0.34)",
        icon: "rgba(17, 24, 39, 0.46)",
        iconHover: "rgba(17, 24, 39, 0.9)",
        iconHoverBg: "rgba(255, 255, 255, 0.28)",
        trafficId
VimEditor function · typescript · L195-L363 (169 LOC)
src/components/VimEditor.tsx
export default function VimEditor({ onCopy, onModeChange, theme }: VimEditorProps) {
  const editorRef = useRef<HTMLDivElement>(null);
  const viewRef = useRef<EditorView | null>(null);

  const handleCopy = useCallback((text: string) => {
    onCopy(text);
  }, [onCopy]);

  const hasVimState = (cm: ReturnType<typeof getCM>): cm is CodeMirrorV => {
    return Boolean(cm?.state?.vim);
  };

  useEffect(() => {
    if (!editorRef.current) return;

    // Define :w and :wq commands for copy
    Vim.defineEx("write", "w", function () {
      if (viewRef.current) {
        const text = viewRef.current.state.doc.toString();
        handleCopy(text);
      }
    });

    Vim.defineEx("quit", "q", function () {
      if (viewRef.current) {
        // Clear and hide
        viewRef.current.dispatch({
          changes: { from: 0, to: viewRef.current.state.doc.length, insert: "" },
        });
        // Invoke Tauri hide
        import("@tauri-apps/api/core").then(({ invoke }) => {
          i
main function · rust · L1-L3 (3 LOC)
src-tauri/build.rs
fn main() {
    tauri_build::build()
}
default function · rust · L38-L45 (8 LOC)
src-tauri/src/lib.rs
    fn default() -> Self {
        Self {
            shortcut: DEFAULT_SHORTCUT.to_string(),
            window_bounds: None,
            hide_menu_bar_icon: false,
            hide_dock_icon: false,
        }
    }
settings_path function · rust · L52-L60 (9 LOC)
src-tauri/src/lib.rs
fn settings_path(app: &AppHandle) -> PathBuf {
    let dir = app
        .path()
        .app_config_dir()
        .unwrap_or_else(|_| PathBuf::from("."));
    fs::create_dir_all(&dir).ok();
    dir.join("settings.json")
}
load_settings function · rust · L61-L72 (12 LOC)
src-tauri/src/lib.rs
fn load_settings(app: &AppHandle) -> AppSettings {
    let path = settings_path(app);
    if path.exists() {
        if let Ok(data) = fs::read_to_string(&path) {
            if let Ok(settings) = serde_json::from_str::<AppSettings>(&data) {
                return settings;
            }
        }
    }
    AppSettings::default()
}
save_settings function · rust · L73-L79 (7 LOC)
src-tauri/src/lib.rs
fn save_settings(app: &AppHandle, settings: &AppSettings) {
    let path = settings_path(app);
    if let Ok(data) = serde_json::to_string_pretty(settings) {
        fs::write(path, data).ok();
    }
}
parse_modifiers function · rust · L82-L95 (14 LOC)
src-tauri/src/lib.rs
fn parse_modifiers(s: &str) -> Modifiers {
    let mut mods = Modifiers::empty();
    for part in s.split('+') {
        match part.trim() {
            "Alt" => mods |= Modifiers::ALT,
            "Shift" => mods |= Modifiers::SHIFT,
            "Control" => mods |= Modifiers::CONTROL,
            "Meta" | "Cmd" | "Super" => mods |= Modifiers::META,
            _ => {}
        }
    }
    mods
}
All rows above produced by Repobility · https://repobility.com
parse_code function · rust · L96-L177 (82 LOC)
src-tauri/src/lib.rs
fn parse_code(s: &str) -> Option<Code> {
    let key_part = s.split('+').last()?.trim();
    let code = match key_part {
        "Space" => Code::Space,
        "Enter" => Code::Enter,
        "Tab" => Code::Tab,
        "Escape" => Code::Escape,
        "Backspace" => Code::Backspace,
        "Delete" => Code::Delete,
        "Up" => Code::ArrowUp,
        "Down" => Code::ArrowDown,
        "Left" => Code::ArrowLeft,
        "Right" => Code::ArrowRight,
        "Home" => Code::Home,
        "End" => Code::End,
        "PageUp" => Code::PageUp,
        "PageDown" => Code::PageDown,
        "Insert" => Code::Insert,
        "F1" => Code::F1,
        "F2" => Code::F2,
        "F3" => Code::F3,
        "F4" => Code::F4,
        "F5" => Code::F5,
        "F6" => Code::F6,
        "F7" => Code::F7,
        "F8" => Code::F8,
        "F9" => Code::F9,
        "F10" => Code::F10,
        "F11" => Code::F11,
        "F12" => Code::F12,
        "A" => Code::KeyA,
        "B" => Code::KeyB,
    
parse_shortcut function · rust · L178-L184 (7 LOC)
src-tauri/src/lib.rs
fn parse_shortcut(s: &str) -> Option<Shortcut> {
    let mods = parse_modifiers(s);
    let code = parse_code(s)?;
    let mods_opt = if mods.is_empty() { None } else { Some(mods) };
    Some(Shortcut::new(mods_opt, code))
}
apply_saved_window_bounds function · rust · L187-L200 (14 LOC)
src-tauri/src/lib.rs
fn apply_saved_window_bounds(app: &AppHandle) {
    let settings = load_settings(app);

    if let (Some(window), Some(bounds)) = (app.get_webview_window("main"), settings.window_bounds) {
        let _ = window.set_size(Size::Physical(PhysicalSize::new(
            bounds.width,
            bounds.height,
        )));
        let _ = window.set_position(Position::Physical(PhysicalPosition::new(
            bounds.x, bounds.y,
        )));
    }
}
persist_window_bounds function · rust · L201-L220 (20 LOC)
src-tauri/src/lib.rs
fn persist_window_bounds(app: &AppHandle) {
    if let Some(window) = app.get_webview_window("main") {
        let Ok(position) = window.outer_position() else {
            return;
        };
        let Ok(size) = window.inner_size() else {
            return;
        };

        let mut settings = load_settings(app);
        settings.window_bounds = Some(WindowBounds {
            x: position.x,
            y: position.y,
            width: size.width,
            height: size.height,
        });
        save_settings(app, &settings);
    }
}
toggle_window function · rust · L221-L237 (17 LOC)
src-tauri/src/lib.rs
fn toggle_window(app: &AppHandle) {
    if let Some(window) = app.get_webview_window("main") {
        if window.is_visible().unwrap_or(false) {
            let _ = window.hide();
        } else {
            if load_settings(app).window_bounds.is_some() {
                apply_saved_window_bounds(app);
            } else {
                let _ = window.center();
            }
            let _ = window.show();
            let _ = window.set_focus();
            let _ = window.emit("window-shown", ());
        }
    }
}
show_window function · rust · L238-L250 (13 LOC)
src-tauri/src/lib.rs
fn show_window(app: &AppHandle) {
    if let Some(window) = app.get_webview_window("main") {
        if load_settings(app).window_bounds.is_some() {
            apply_saved_window_bounds(app);
        } else {
            let _ = window.center();
        }
        let _ = window.show();
        let _ = window.set_focus();
        let _ = window.emit("window-shown", ());
    }
}
hide_window_inner function · rust · L251-L256 (6 LOC)
src-tauri/src/lib.rs
fn hide_window_inner(app: &AppHandle) {
    if let Some(window) = app.get_webview_window("main") {
        let _ = window.hide();
    }
}
current_visibility_settings function · rust · L257-L263 (7 LOC)
src-tauri/src/lib.rs
fn current_visibility_settings(app: &AppHandle) -> VisibilitySettings {
    let settings = load_settings(app);
    VisibilitySettings {
        hide_menu_bar_icon: settings.hide_menu_bar_icon,
    }
}
Methodology: Repobility · https://repobility.com/research/state-of-ai-code-2026/
apply_visibility_settings function · rust · L264-L275 (12 LOC)
src-tauri/src/lib.rs
fn apply_visibility_settings(app: &AppHandle, settings: &AppSettings) {
    if let Some(tray) = app.tray_by_id(TRAY_ID) {
        let _ = tray.set_visible(!settings.hide_menu_bar_icon);
    }

    #[cfg(target_os = "macos")]
    {
        let _ = settings;
        let _ = app.set_activation_policy(ActivationPolicy::Accessory);
    }
}
hide_window function · rust · L280-L282 (3 LOC)
src-tauri/src/lib.rs
fn hide_window(app: AppHandle) {
    hide_window_inner(&app);
}
show_main_window function · rust · L285-L287 (3 LOC)
src-tauri/src/lib.rs
fn show_main_window(app: AppHandle) {
    show_window(&app);
}
get_shortcut function · rust · L290-L293 (4 LOC)
src-tauri/src/lib.rs
fn get_shortcut(app: AppHandle) -> String {
    let settings = load_settings(&app);
    settings.shortcut
}
get_visibility_settings function · rust · L296-L298 (3 LOC)
src-tauri/src/lib.rs
fn get_visibility_settings(app: AppHandle) -> VisibilitySettings {
    current_visibility_settings(&app)
}
update_shortcut function · rust · L301-L339 (39 LOC)
src-tauri/src/lib.rs
fn update_shortcut(
    app: AppHandle,
    shortcut: String,
    state: tauri::State<'_, ShortcutState_>,
) -> Result<(), String> {
    // Parse the new shortcut
    let new_sc = parse_shortcut(&shortcut).ok_or("Invalid shortcut format")?;

    // Unregister old shortcut
    let old_shortcut_str = {
        let guard = state.current.lock().map_err(|e| e.to_string())?;
        guard.clone()
    };
    if let Some(old_sc) = parse_shortcut(&old_shortcut_str) {
        app.global_shortcut().unregister(old_sc).ok();
    }

    // Register new shortcut
    app.global_shortcut()
        .on_shortcut(new_sc, |app, _shortcut, event| {
            if event.state == ShortcutState::Pressed {
                toggle_window(app);
            }
        })
        .map_err(|e| format!("Failed to register shortcut: {}", e))?;

    // Save to settings
    let mut settings = load_settings(&app);
    settings.shortcut = shortcut.clone();
    save_settings(&app, &settings);

    // Update state
    {
     
update_visibility_settings function · rust · L342-L351 (10 LOC)
src-tauri/src/lib.rs
fn update_visibility_settings(
    app: AppHandle,
    hide_menu_bar_icon: bool,
) {
    let mut settings = load_settings(&app);
    settings.hide_menu_bar_icon = hide_menu_bar_icon;
    settings.hide_dock_icon = true;
    save_settings(&app, &settings);
    apply_visibility_settings(&app, &settings);
}
run function · rust · L362-L488 (127 LOC)
src-tauri/src/lib.rs
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_clipboard_manager::init())
        .plugin(tauri_plugin_liquid_glass::init())
        .plugin(tauri_plugin_shell::init())
        .plugin(
            tauri_plugin_global_shortcut::Builder::new()
                .with_handler(|_app, _shortcut, _event| {
                    // Handler is set per-shortcut via on_shortcut, this is a no-op fallback
                })
                .build(),
        )
        .manage(ShortcutState_ {
            current: Mutex::new(DEFAULT_SHORTCUT.to_string()),
        })
        .setup(|app| {
            // Setup logging in debug mode
            if cfg!(debug_assertions) {
                app.handle().plugin(
                    tauri_plugin_log::Builder::default()
                        .level(log::LevelFilter::Info)
                        .build(),
                )?;
            }

            // Load saved settings
            let settings = load_settings(app.handle());
  
Repobility — same analyzer, your code, free for public repos · /scan/
main function · rust · L3-L6 (4 LOC)
src-tauri/src/main.rs
fn main() {
    app_lib::run();
}