дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-26 03:14:38 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
6087b8b8e8 |
No files matched your search
Створено
+35
-39
@@ -4038,7 +4038,7 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "ide-agent"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4061,7 +4061,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-analysis"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ast-grep-core",
|
||||
"ide-core",
|
||||
@@ -4075,7 +4075,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-build"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
@@ -4090,7 +4090,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-clipboard"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
@@ -4099,7 +4099,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-core"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4115,7 +4115,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-coverage"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4129,7 +4129,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-dap"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-jsonrpc",
|
||||
@@ -4147,7 +4147,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-db"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"bb8",
|
||||
"dirs 6.0.0",
|
||||
@@ -4169,7 +4169,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-docker"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4183,7 +4183,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-fonts"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-text",
|
||||
@@ -4194,7 +4194,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-github"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-vcs",
|
||||
@@ -4208,7 +4208,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-host"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
@@ -4253,7 +4253,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-http"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4271,7 +4271,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-index"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4293,7 +4293,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-jsonrpc"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"encoding_rs",
|
||||
"futures",
|
||||
@@ -4309,7 +4309,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-language"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"criterion",
|
||||
@@ -4364,7 +4364,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-lsp"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"futures",
|
||||
@@ -4388,7 +4388,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-notebook"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"ide-core",
|
||||
@@ -4411,7 +4411,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-plugin"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4429,7 +4429,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-profiler"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-run",
|
||||
@@ -4442,7 +4442,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-remote"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"globset",
|
||||
"ide-core",
|
||||
@@ -4459,7 +4459,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-run"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4482,7 +4482,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-sdk"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"ide-core",
|
||||
@@ -4501,7 +4501,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-search"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"globset",
|
||||
@@ -4521,7 +4521,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-spell"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"parking_lot",
|
||||
@@ -4534,7 +4534,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-ssh"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"flate2",
|
||||
@@ -4553,7 +4553,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-syntax"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"ide-language",
|
||||
@@ -4568,7 +4568,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-terminal"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"libc",
|
||||
@@ -4581,7 +4581,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-text"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"ide-core",
|
||||
@@ -4593,7 +4593,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-tools"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"hex",
|
||||
@@ -4614,7 +4614,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vcs"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"encoding_rs",
|
||||
@@ -4633,7 +4633,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-vfs"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"chardetng",
|
||||
"dunce",
|
||||
@@ -4655,7 +4655,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-web"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"ide-core",
|
||||
"open",
|
||||
@@ -4671,7 +4671,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ide-workspace"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"dunce",
|
||||
@@ -6141,10 +6141,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openidea"
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"block2 0.6.2",
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"ide-agent",
|
||||
@@ -6181,9 +6180,6 @@ dependencies = [
|
||||
"ide-vfs",
|
||||
"ide-web",
|
||||
"ide-workspace",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-foundation 0.3.2",
|
||||
"parking_lot",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ resolver = "3"
|
||||
members = ["crates/*", "src-tauri"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.32"
|
||||
version = "0.1.29"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use ide_core::NullSink;
|
||||
#[cfg(unix)]
|
||||
use ide_host::ops;
|
||||
use ide_host::{Host, HostConfig, trust::TrustStore};
|
||||
use ide_host::{Host, HostConfig, ops, trust::TrustStore};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
#[cfg(unix)]
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
fn host(base: &Path, environment: bool) -> Arc<Host> {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "openidea",
|
||||
"private": true,
|
||||
"description": "An open-source IDE inspired by IntelliJ IDEA",
|
||||
"version": "0.1.32",
|
||||
"version": "0.1.29",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -69,9 +69,3 @@ ide-tools = { path = "../crates/ide-tools" }
|
||||
ide-plugin = { path = "../crates/ide-plugin" }
|
||||
ide-docker = { path = "../crates/ide-docker" }
|
||||
ide-github = { path = "../crates/ide-github" }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
block2 = "0.6"
|
||||
objc2 = "0.6"
|
||||
objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSButton", "NSResponder", "NSView", "NSWindow"] }
|
||||
objc2-foundation = { version = "0.3", default-features = false, features = ["std", "block2", "NSNotification", "NSOperation", "NSString"] }
|
||||
@@ -356,7 +356,6 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
|
||||
window::window_open_settings,
|
||||
window::window_cycle,
|
||||
window::window_toggle_fullscreen,
|
||||
window::window_set_titlebar_height,
|
||||
window::window_take_launch,
|
||||
window::window_close_context,
|
||||
window::window_open_projects,
|
||||
|
||||
@@ -102,20 +102,6 @@ pub fn window_toggle_fullscreen(window: WebviewWindow) -> IdeResult<bool> {
|
||||
Ok(on)
|
||||
}
|
||||
|
||||
/// Height of the web title bar in native logical pixels (CSS height × IDE zoom).
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub fn window_set_titlebar_height(window: WebviewWindow, height: f64) -> IdeResult<()> {
|
||||
if !height.is_finite() || !(1.0..=1000.0).contains(&height) {
|
||||
return Err(IdeError::invalid("invalid title bar height"));
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
crate::titlebar::set_height(&window, height).map_err(|e| IdeError::internal(e.to_string()))?;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let _ = window;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What this window was opened for (taken once).
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
|
||||
@@ -13,8 +13,6 @@ mod remote_dev;
|
||||
|
||||
mod state;
|
||||
mod theme_frame;
|
||||
#[cfg(target_os = "macos")]
|
||||
mod titlebar;
|
||||
mod window_groups;
|
||||
mod windows;
|
||||
|
||||
@@ -140,8 +138,6 @@ pub fn run() {
|
||||
}
|
||||
}
|
||||
tauri::WindowEvent::Destroyed => {
|
||||
#[cfg(target_os = "macos")]
|
||||
titlebar::forget(window);
|
||||
window_groups::destroyed(window.app_handle(), window.label());
|
||||
if let Some(settings) = window.app_handle().get_webview_window(&windows::settings_label(window.label())) {
|
||||
let _ = settings.destroy();
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
//! Keep the native window buttons aligned with the web toolbar, in AppKit points.
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
use block2::RcBlock;
|
||||
use objc2::rc::Retained;
|
||||
use objc2::runtime::ProtocolObject;
|
||||
use objc2_app_kit::{NSWindow, NSWindowButton, NSWindowDidUpdateNotification, NSWindowStyleMask};
|
||||
use objc2_foundation::{NSNotificationCenter, NSObjectProtocol, NSPoint};
|
||||
|
||||
struct Titlebar {
|
||||
height: Rc<Cell<f64>>,
|
||||
observer: Retained<ProtocolObject<dyn NSObjectProtocol>>,
|
||||
}
|
||||
|
||||
impl Drop for Titlebar {
|
||||
fn drop(&mut self) {
|
||||
unsafe { NSNotificationCenter::defaultCenter().removeObserver((*self.observer).as_ref()) };
|
||||
}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static TITLEBARS: RefCell<HashMap<String, Titlebar>> = RefCell::default();
|
||||
}
|
||||
|
||||
pub fn set_height(window: &tauri::WebviewWindow, height: f64) -> tauri::Result<()> {
|
||||
let label = window.label().to_owned();
|
||||
// with_webview runs on the AppKit thread; the observer is also delivered there.
|
||||
window.with_webview(move |webview| unsafe {
|
||||
let native = &*webview.ns_window().cast::<NSWindow>();
|
||||
TITLEBARS.with_borrow_mut(|bars| {
|
||||
let bar = bars.entry(label).or_insert_with(|| {
|
||||
let height = Rc::new(Cell::new(height));
|
||||
let current = height.clone();
|
||||
let pointer = native as *const NSWindow;
|
||||
let block = RcBlock::new(move |_| center_buttons(&*pointer, current.get()));
|
||||
let observer = NSNotificationCenter::defaultCenter().addObserverForName_object_queue_usingBlock(
|
||||
Some(NSWindowDidUpdateNotification),
|
||||
Some(native),
|
||||
None,
|
||||
&block,
|
||||
);
|
||||
Titlebar { height, observer }
|
||||
});
|
||||
bar.height.set(height);
|
||||
center_buttons(native, height);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
pub fn forget(window: &tauri::Window) {
|
||||
let label = window.label().to_owned();
|
||||
let _ = window.run_on_main_thread(move || {
|
||||
TITLEBARS.with_borrow_mut(|bars| bars.remove(&label));
|
||||
});
|
||||
}
|
||||
|
||||
unsafe fn center_buttons(window: &NSWindow, height: f64) {
|
||||
// Fullscreen uses AppKit's own revealable title bar.
|
||||
if window.styleMask().contains(NSWindowStyleMask::FullScreen) {
|
||||
return;
|
||||
}
|
||||
let Some(close) = window.standardWindowButton(NSWindowButton::CloseButton) else { return };
|
||||
let Some(minimize) = window.standardWindowButton(NSWindowButton::MiniaturizeButton) else { return };
|
||||
let spacing = minimize.frame().origin.x - close.frame().origin.x;
|
||||
let Some(container) = (unsafe { close.superview().and_then(|view| view.superview()) }) else { return };
|
||||
let Some(content) = window.contentView() else { return };
|
||||
let mut frame = container.frame();
|
||||
let top = frame.origin.y + frame.size.height;
|
||||
if (frame.size.height - height).abs() > 0.01 {
|
||||
frame.size.height = height;
|
||||
frame.origin.y = top - height;
|
||||
container.setFrame(frame);
|
||||
}
|
||||
let bounds = content.bounds();
|
||||
let y = bounds.origin.y + if content.isFlipped() { height / 2.0 } else { bounds.size.height - height / 2.0 };
|
||||
for (index, kind) in [NSWindowButton::CloseButton, NSWindowButton::MiniaturizeButton, NSWindowButton::ZoomButton]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let Some(button) = window.standardWindowButton(kind) else { continue };
|
||||
let Some(parent) = (unsafe { button.superview() }) else { continue };
|
||||
let center = parent.convertPoint_fromView(NSPoint::new(0.0, y), Some(&content));
|
||||
let frame = button.frame();
|
||||
let x = 14.0 + index as f64 * spacing;
|
||||
let target = center.y - frame.size.height / 2.0;
|
||||
if (frame.origin.x - x).abs() > 0.01 || (frame.origin.y - target).abs() > 0.01 {
|
||||
button.setFrameOrigin(NSPoint::new(x, target));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,17 +297,27 @@ fn build_project_window(app: &AppHandle, mut config: WindowConfig) -> IdeResult<
|
||||
.and_then(|b| b.build())
|
||||
.map_err(|e| IdeError::internal(format!("cannot create window: {e}")))?;
|
||||
apply_zoom(app, &window);
|
||||
#[cfg(target_os = "macos")]
|
||||
align_titlebar(app, &window);
|
||||
match_native_theme(&window, config.background_color);
|
||||
// "Sync with OS" needs the OS mode, known once the window exists.
|
||||
if let Some(a) = appearance.filter(|a| plugin_frame.is_none() && (a.sync_with_os || a.theme == "system"))
|
||||
&& window.theme().is_ok_and(|t| t == Theme::Dark)
|
||||
{
|
||||
let _ = window.set_background_color(Some(frame_color(&a, true)));
|
||||
let color = frame_color(&a, true);
|
||||
let _ = window.set_background_color(Some(color));
|
||||
match_native_theme(&window, Some(color));
|
||||
}
|
||||
Ok(window)
|
||||
}
|
||||
|
||||
/// Pins the native window appearance (outline, shadow, traffic lights) to the light/dark
|
||||
/// of the app's frame colour; otherwise it follows the OS, so a light app theme in OS dark
|
||||
/// mode gets a dark window border.
|
||||
fn match_native_theme(window: &WebviewWindow, frame: Option<Color>) {
|
||||
let Some(Color(r, g, b, _)) = frame else { return };
|
||||
let luma = 0.299 * f64::from(r) + 0.587 * f64::from(g) + 0.114 * f64::from(b);
|
||||
let _ = window.set_theme(Some(if luma < 128.0 { Theme::Dark } else { Theme::Light }));
|
||||
}
|
||||
|
||||
/// Sets the saved IDE zoom before the page loads; applied later by the frontend,
|
||||
/// it would visibly scale up the splash.
|
||||
fn apply_zoom(app: &AppHandle, window: &WebviewWindow) {
|
||||
@@ -319,20 +329,6 @@ fn apply_zoom(app: &AppHandle, window: &WebviewWindow) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Aligns the native window buttons before the page reports its title bar height,
|
||||
/// so they don't visibly move once it loads.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn align_titlebar(app: &AppHandle, window: &WebviewWindow) {
|
||||
// `--h-titlebar` in tokens.css.
|
||||
const HEIGHT: f64 = 40.0;
|
||||
const COMPACT_HEIGHT: f64 = 32.0;
|
||||
let Some(a) = app.try_state::<AppState>().map(|s| s.global_settings.effective().appearance) else {
|
||||
return;
|
||||
};
|
||||
let height = if a.compact_mode { COMPACT_HEIGHT } else { HEIGHT };
|
||||
let _ = crate::titlebar::set_height(window, height * f64::from(a.zoom.clamp(50, 300)) / 100.0);
|
||||
}
|
||||
|
||||
/// The first window (`create: false` in tauri.conf.json so it can take the theme's colour).
|
||||
pub fn create_main_window(app: &AppHandle) -> IdeResult<WebviewWindow> {
|
||||
build_project_window(app, window_config(app)?)
|
||||
@@ -763,8 +759,7 @@ pub fn open_settings_window(
|
||||
.and_then(|b| b.build())
|
||||
.map_err(|e| IdeError::internal(format!("cannot create settings window: {e}")))?;
|
||||
apply_zoom(app, &window);
|
||||
#[cfg(target_os = "macos")]
|
||||
align_titlebar(app, &window);
|
||||
match_native_theme(&window, config.background_color);
|
||||
// Restore runs during build; fit its size to the parent's current display before showing.
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Err(e) = fit_settings_window(&window, &parent) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "OpenIDEA",
|
||||
"version": "0.1.32",
|
||||
"version": "0.1.29",
|
||||
"identifier": "ai.l0ng.openidea",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
@@ -21,6 +21,10 @@
|
||||
"minHeight": 500,
|
||||
"titleBarStyle": "Overlay",
|
||||
"hiddenTitle": true,
|
||||
"trafficLightPosition": {
|
||||
"x": 14,
|
||||
"y": 22
|
||||
},
|
||||
"backgroundColor": "#E9EAEE",
|
||||
"dragDropEnabled": true
|
||||
}
|
||||
|
||||
@@ -720,8 +720,6 @@ export const commands = {
|
||||
/** Focuses the next / previous window (⌘` / ⇧⌘`). */
|
||||
windowCycle: (forward: boolean) => __TAURI_INVOKE<void>("window_cycle", { forward }),
|
||||
windowToggleFullscreen: () => typedError<boolean, IdeError>(__TAURI_INVOKE("window_toggle_fullscreen")),
|
||||
/** Height of the web title bar in native logical pixels (CSS height × IDE zoom). */
|
||||
windowSetTitlebarHeight: (height: number | null) => typedError<null, IdeError>(__TAURI_INVOKE("window_set_titlebar_height", { height })),
|
||||
/** What this window was opened for (taken once). */
|
||||
windowTakeLaunch: () => __TAURI_INVOKE<{
|
||||
/** Project folder to open. */
|
||||
|
||||
@@ -11,17 +11,23 @@
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: var(--h-row);
|
||||
padding: 0 10px;
|
||||
font-size: var(--fs-small);
|
||||
color: var(--fg-subtle);
|
||||
border-bottom: 1px solid var(--border-popup);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.title {
|
||||
flex: 1;
|
||||
}
|
||||
.search {
|
||||
margin: 0 8px 4px;
|
||||
border-bottom: 1px solid var(--border-popup);
|
||||
.filter {
|
||||
font-family: var(--font-mono);
|
||||
color: var(--fg-strong);
|
||||
background: var(--accent-soft);
|
||||
border-radius: var(--radius-small);
|
||||
padding: 0 4px;
|
||||
}
|
||||
.list {
|
||||
max-height: 360px;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { useMemo, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { HighlightedText, Icon, List, Popup, SearchField, fileIconName, listNavigate, T } from "@/ui";
|
||||
import { HighlightedText, Icon, List, Popup, fileIconName, listNavigate, T } from "@/ui";
|
||||
import { chooserRows, type LanguageRow, type ScratchLanguage } from "./model";
|
||||
import { closeChooser, rememberLanguage, useScratch } from "./store";
|
||||
import { createScratch } from "./scratches";
|
||||
import styles from "./ScratchChooser.module.css";
|
||||
|
||||
/** Overlay: IDEA's "New Scratch File" popup — searchable languages, recent first. */
|
||||
/** Overlay: IDEA's "New Scratch File" popup — languages, speed search, recent first. */
|
||||
export function ScratchChooserHost() {
|
||||
const languages = useScratch((s) => s.languages);
|
||||
const seq = useScratch((s) => s.seq);
|
||||
@@ -16,7 +16,6 @@ export function ScratchChooserHost() {
|
||||
|
||||
function ScratchChooser({ languages }: { languages: readonly ScratchLanguage[] }) {
|
||||
const recent = useScratch((s) => s.recent);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const [filter, setFilter] = useState("");
|
||||
const [active, setActive] = useState(0);
|
||||
const rows = useMemo(() => chooserRows(languages, recent, filter), [languages, recent, filter]);
|
||||
@@ -30,19 +29,22 @@ function ScratchChooser({ languages }: { languages: readonly ScratchLanguage[] }
|
||||
void createScratch(row.lang);
|
||||
};
|
||||
|
||||
const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.nativeEvent.isComposing || e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
const next = listNavigate(e.key === "Home" || e.key === "End" ? "" : e.key, {
|
||||
items: rows,
|
||||
active: current,
|
||||
wrap: true,
|
||||
});
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
const next = listNavigate(e.key, { items: rows, active: current, wrap: true });
|
||||
if (next !== null) {
|
||||
e.preventDefault();
|
||||
setActive(next);
|
||||
} else if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
pick(rows[current]);
|
||||
} else if (e.key === "Backspace") {
|
||||
e.preventDefault();
|
||||
setFilter((f) => f.slice(0, -1));
|
||||
setActive(0);
|
||||
} else if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
||||
e.preventDefault();
|
||||
setFilter((f) => f + e.key);
|
||||
setActive(0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,27 +58,13 @@ function ScratchChooser({ languages }: { languages: readonly ScratchLanguage[] }
|
||||
aria-label="New Scratch File"
|
||||
className={styles.popup}
|
||||
>
|
||||
<div className={styles.body}>
|
||||
<div className={styles.body} tabIndex={0} data-autofocus onKeyDown={onKeyDown}>
|
||||
<div className={styles.header}>
|
||||
<span className={styles.title}>
|
||||
<T>New Scratch File</T>
|
||||
</span>
|
||||
{filter && <span className={styles.filter}>{filter}</span>}
|
||||
</div>
|
||||
<SearchField
|
||||
ref={inputRef}
|
||||
variant="bare"
|
||||
data-autofocus
|
||||
value={filter}
|
||||
placeholder="Filter languages"
|
||||
aria-label="Filter languages"
|
||||
className={styles.search}
|
||||
onChange={(value) => {
|
||||
setFilter(value);
|
||||
setActive(0);
|
||||
inputRef.current?.focus();
|
||||
}}
|
||||
onKeyDown={onKeyDown}
|
||||
/>
|
||||
<List
|
||||
items={rows}
|
||||
getKey={(r) => r.lang.id}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { getAction } from "@/platform/actions";
|
||||
import { onIdeEvent } from "@/platform/ipc";
|
||||
import { useProjectViewRoots } from "@/workbench/contributions";
|
||||
@@ -104,20 +103,12 @@ describe("creating scratch files", () => {
|
||||
await action.run({ ctx: {} as never, arg: undefined });
|
||||
});
|
||||
render(<ScratchChooserHost />);
|
||||
const user = userEvent.setup();
|
||||
const input = screen.getByRole("textbox", { name: "Filter languages" });
|
||||
expect(input).toHaveFocus();
|
||||
await user.paste("java");
|
||||
expect(input).toHaveValue("java");
|
||||
expect(screen.queryByText("Python")).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Clear" }));
|
||||
expect(input).toHaveFocus();
|
||||
expect(input).toHaveValue("");
|
||||
await user.type(input, "pyton");
|
||||
await user.keyboard("{ArrowLeft}{ArrowLeft}h");
|
||||
expect(input).toHaveValue("python");
|
||||
const dialog = screen.getByRole("dialog", { name: "New Scratch File" });
|
||||
const body = dialog.querySelector<HTMLElement>("[tabindex]")!;
|
||||
for (const ch of "pyt") fireEvent.keyDown(body, { key: ch });
|
||||
expect(dialog.textContent).toContain("pyt");
|
||||
await act(async () => {
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
fireEvent.keyDown(body, { key: "Enter" });
|
||||
});
|
||||
await vi.waitFor(() => expect(opened).toEqual(["/data/scratches/scratch.py"]));
|
||||
expect(useScratch.getState().languages).toBeNull();
|
||||
|
||||
@@ -10,7 +10,7 @@ import { uiFontFamily } from "@/platform/fonts";
|
||||
import { call, commands, isTauri } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { setDragRequiresAlt } from "@/ui";
|
||||
import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
import { ZOOM_LIMITS } from "./model/behaviorSchema";
|
||||
import { DEFAULT_SETTINGS, validateSettings, type ValidSettings } from "./model/schema";
|
||||
|
||||
const FONT_VARS = [
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import { BUILTIN_THEME_IDS, type BuiltinThemeId } from "@/platform/themes";
|
||||
import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
|
||||
export type Antialiasing = "subpixel" | "greyscale" | "none";
|
||||
export type OpenProjectIn = "ask" | "new" | "same" | "attach";
|
||||
@@ -62,6 +61,7 @@ export interface NotificationsValid {
|
||||
groups: Record<string, NotificationGroupValid>;
|
||||
}
|
||||
|
||||
export const ZOOM_LIMITS = { min: 50, max: 300 } as const;
|
||||
export const IDLE_LIMITS = { min: 1, max: 3600 } as const;
|
||||
|
||||
export const DEFAULT_APPEARANCE_EXTRAS: AppearanceExtras = {
|
||||
|
||||
@@ -11,7 +11,6 @@ import clsx from "clsx";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { isTauri } from "@/platform/ipc";
|
||||
import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
import { SCHEMES as EDITOR_SCHEMES, listSchemes, customSchemes } from "@/platform/colorScheme";
|
||||
import { formatTimestamp } from "@/platform/dateFormat";
|
||||
import { Checkbox, IconButton, Input, Popup, type SelectOption, T } from "@/ui";
|
||||
@@ -19,6 +18,7 @@ import { NOTIFICATION_GROUPS } from "@/workbench/notificationStore";
|
||||
import { ColorSwatches, NumberInput, Row, SearchLabel, Select, Toggle } from "../components/Form";
|
||||
import { useLabelMatch, useSetting } from "../components/context";
|
||||
import {
|
||||
ZOOM_LIMITS,
|
||||
IDLE_LIMITS,
|
||||
type Antialiasing,
|
||||
type ConcreteTheme,
|
||||
|
||||
@@ -86,9 +86,6 @@ function paneMenu(e: MouseEvent, key: string) {
|
||||
e.preventDefault();
|
||||
const session = getSession(key);
|
||||
if (!session) return;
|
||||
// Right-clicking focuses the terminal, like IDEA; otherwise the menu closing
|
||||
// restores focus to whatever was focused before it, often the editor.
|
||||
session.focus();
|
||||
const exited = session.state.status === "exited" || session.state.status === "error";
|
||||
const mac = usePlatform.getState().os === "macos";
|
||||
const items: MenuItem[] = [
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export const ZOOM_LIMITS = { min: 50, max: 300 } as const;
|
||||
|
||||
/** The IDE zoom in percent that a settings value applies as. */
|
||||
export function clampZoom(value: unknown): number {
|
||||
if (typeof value !== "number" || !Number.isFinite(value)) return 100;
|
||||
return Math.min(ZOOM_LIMITS.max, Math.max(ZOOM_LIMITS.min, Math.round(value)));
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { act, fireEvent, render, screen } from "@testing-library/react";
|
||||
import { getContext, setContext } from "@/platform/context";
|
||||
import { registerAction } from "@/platform/actions";
|
||||
import { Popup } from "./Popup";
|
||||
import { ContextMenuHost, Menu, MenuList, hideContextMenu, showContextMenu } from "./Menu";
|
||||
import { Menu, MenuList } from "./Menu";
|
||||
import { Dialog } from "./Dialog";
|
||||
|
||||
function Harness({ onClose }: { onClose?: (r: string) => void }) {
|
||||
@@ -177,21 +177,6 @@ describe("Dialog initial focus", () => {
|
||||
});
|
||||
|
||||
describe("Menu action enablement", () => {
|
||||
it("returns focus to the element focused before a context menu opened", () => {
|
||||
render(
|
||||
<>
|
||||
<textarea aria-label="input" />
|
||||
<ContextMenuHost />
|
||||
</>,
|
||||
);
|
||||
const input = screen.getByRole("textbox", { name: "input" });
|
||||
input.focus();
|
||||
act(() => showContextMenu({ x: 0, y: 0 }, [{ label: "Paste", run: () => undefined }]));
|
||||
expect(screen.getByRole("menuitem", { name: /Paste/ })).toHaveFocus();
|
||||
act(() => hideContextMenu());
|
||||
expect(input).toHaveFocus();
|
||||
});
|
||||
|
||||
it("follows context changes after the menu opened", () => {
|
||||
const dispose = registerAction({ id: "test.menuWhen", title: "Needs Flag", when: "qaMenuFlag", run: () => {} });
|
||||
setContext("qaMenuFlag", false);
|
||||
|
||||
+2
-12
@@ -3,16 +3,7 @@
|
||||
* window-deactivation dismissal (top-most popup only for Escape), optional
|
||||
* focus trap and focus restore.
|
||||
*/
|
||||
import {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type CSSProperties,
|
||||
type ReactNode,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, type CSSProperties, type ReactNode, type RefObject } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
@@ -117,11 +108,10 @@ function PopupInner({
|
||||
useLayoutEffect(() => {
|
||||
onCloseRef.current = onClose;
|
||||
});
|
||||
// Read while rendering: content such as a menu focuses itself before any effect here runs.
|
||||
const [previous] = useState(() => document.activeElement as HTMLElement | null);
|
||||
|
||||
useEffect(() => {
|
||||
const layer = openLayer(() => elRef.current);
|
||||
const previous = document.activeElement as HTMLElement | null;
|
||||
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (!layer.isTop()) return;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
}
|
||||
/* Room for the native macOS traffic lights (Overlay title bar). */
|
||||
.overlay {
|
||||
padding-left: max(82px, calc(82px / var(--titlebar-zoom, 1)));
|
||||
padding-left: 82px;
|
||||
}
|
||||
/* Welcome window: plain title on the frame colour with a hairline, like IntelliJ's welcome frame. */
|
||||
.minimal {
|
||||
|
||||
@@ -26,7 +26,6 @@ import { projectInitials } from "./projectColor";
|
||||
import { keymapItems, themeItems, VIEW_MODE_ITEMS } from "./quickSwitch";
|
||||
import { currentThemeId, useThemeOverride } from "./theme";
|
||||
import styles from "./TitleBar.module.css";
|
||||
import { useNativeTitlebar } from "./nativeTitlebar";
|
||||
|
||||
export function orderTitleItems(items: Iterable<TitleItemContribution>) {
|
||||
const all = [...items];
|
||||
@@ -278,14 +277,12 @@ export function TitleBar({
|
||||
const frameless = usePlatform((s) => s.framelessTitleBar);
|
||||
const { map, shown, menu } = useToolbar();
|
||||
const [menuExpanded, setMenuExpanded] = useState(false);
|
||||
const [bar, setBar] = useState<HTMLElement | null>(null);
|
||||
useNativeTitlebar(bar);
|
||||
const className = clsx(styles.bar, overlay && styles.overlay, frameless && styles.frameless);
|
||||
// Distraction Free Mode: the window frame only. Where the title bar carries the
|
||||
// main menu (Windows, Linux) it stays, or nothing would lead back out of the mode.
|
||||
if (bare)
|
||||
return (
|
||||
<header ref={setBar} className={className} data-tauri-drag-region data-titlebar="bare">
|
||||
<header className={className} data-tauri-drag-region data-titlebar="bare">
|
||||
{frameless && (
|
||||
<>
|
||||
<MainMenu />
|
||||
@@ -299,7 +296,6 @@ export function TitleBar({
|
||||
const toolbar = !minimal && !lightEdit;
|
||||
return (
|
||||
<header
|
||||
ref={setBar}
|
||||
className={clsx(className, minimal && styles.minimal, dialog && styles.dialogBar)}
|
||||
data-tauri-drag-region
|
||||
onContextMenu={(e) => {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import type { Settings } from "@/platform/ipc";
|
||||
import { useNativeTitlebar } from "./nativeTitlebar";
|
||||
|
||||
const { setHeight } = vi.hoisted(() => ({ setHeight: vi.fn().mockResolvedValue({ status: "ok" }) }));
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const ipc = await original<typeof import("@/platform/ipc")>();
|
||||
return { ...ipc, commands: { ...ipc.commands, windowSetTitlebarHeight: setHeight } };
|
||||
});
|
||||
|
||||
const platform = usePlatform.getState();
|
||||
const project = useProject.getState();
|
||||
let resize: () => void;
|
||||
const disconnect = vi.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
setHeight.mockClear();
|
||||
disconnect.mockClear();
|
||||
usePlatform.setState({ overlayTitleBar: true });
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class {
|
||||
constructor(callback: () => void) {
|
||||
resize = callback;
|
||||
}
|
||||
observe() {}
|
||||
disconnect = disconnect;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
usePlatform.setState(platform);
|
||||
useProject.setState(project);
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
function zoom(percent: number) {
|
||||
useProject.setState({ settings: { appearance: { zoom: percent } } as Settings });
|
||||
}
|
||||
|
||||
function titlebar(height: number) {
|
||||
const bar = document.createElement("header");
|
||||
const rect = vi.spyOn(bar, "getBoundingClientRect").mockReturnValue(new DOMRect(0, 0, 800, height));
|
||||
return { bar, rect };
|
||||
}
|
||||
|
||||
describe("native title bar alignment", () => {
|
||||
it.each([50, 100, 125, 150, 200, 300])("converts CSS height to AppKit points at %s%%", (percent) => {
|
||||
zoom(percent);
|
||||
const { bar } = titlebar(40);
|
||||
renderHook(() => useNativeTitlebar(bar));
|
||||
expect(setHeight).toHaveBeenLastCalledWith((40 * percent) / 100);
|
||||
});
|
||||
|
||||
it("uses the zoom the webview applies when the setting is out of range", () => {
|
||||
zoom(500);
|
||||
const { bar } = titlebar(40);
|
||||
renderHook(() => useNativeTitlebar(bar));
|
||||
expect(setHeight).toHaveBeenLastCalledWith(120);
|
||||
});
|
||||
|
||||
it("updates when zoom or compact mode changes, and disconnects on unmount", () => {
|
||||
zoom(100);
|
||||
const { bar, rect } = titlebar(40);
|
||||
const { unmount } = renderHook(() => useNativeTitlebar(bar));
|
||||
act(() => zoom(150));
|
||||
expect(setHeight).toHaveBeenLastCalledWith(60);
|
||||
rect.mockReturnValue(new DOMRect(0, 0, 800, 32));
|
||||
act(() => resize());
|
||||
expect(setHeight).toHaveBeenLastCalledWith(48);
|
||||
unmount();
|
||||
expect(disconnect).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("leaves windows without native overlay buttons alone", () => {
|
||||
usePlatform.setState({ overlayTitleBar: false });
|
||||
const { bar } = titlebar(40);
|
||||
renderHook(() => useNativeTitlebar(bar));
|
||||
expect(setHeight).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,29 +0,0 @@
|
||||
import { useEffect } from "react";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { clampZoom } from "@/platform/zoom";
|
||||
|
||||
export function useNativeTitlebar(bar: HTMLElement | null) {
|
||||
const overlay = usePlatform((s) => s.overlayTitleBar);
|
||||
const zoom = useProject((s) => clampZoom(s.settings?.appearance?.zoom));
|
||||
useEffect(() => {
|
||||
if (!overlay || !bar) return;
|
||||
bar.style.setProperty("--titlebar-zoom", String(zoom / 100));
|
||||
const update = () => {
|
||||
// Webview zoom scales CSS pixels; Retina scale is already handled by AppKit.
|
||||
const height = (bar.getBoundingClientRect().height * zoom) / 100;
|
||||
if (height > 0)
|
||||
void call(commands.windowSetTitlebarHeight(height)).catch((e) =>
|
||||
console.warn("cannot align window buttons", e),
|
||||
);
|
||||
};
|
||||
update();
|
||||
const observer = new ResizeObserver(update);
|
||||
observer.observe(bar);
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
bar.style.removeProperty("--titlebar-zoom");
|
||||
};
|
||||
}, [bar, overlay, zoom]);
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача