forked from 1b-agent/opencadstudio-upstream
#1798 follow-up: wrap lines over 100 columns
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
87c44cee78
commit
3893165ac7
4 files changed
+69
-25
No files matched your search
+21
-5
@@ -289,8 +289,12 @@ impl OpenCADStudio {
|
||||
pub(super) fn import_alias_pgp(&mut self, bytes: &[u8]) {
|
||||
let parsed = pgp::parse(&pgp::decode(bytes));
|
||||
let known = crate::command::all_registered_command_names();
|
||||
let mut rows: FxHashMap<String, String> = self.alias_editor_rows.iter()
|
||||
.filter(|(a, c)| !a.is_empty() && !c.is_empty()).cloned().collect();
|
||||
let mut rows: FxHashMap<String, String> = self
|
||||
.alias_editor_rows
|
||||
.iter()
|
||||
.filter(|(a, c)| !a.is_empty() && !c.is_empty())
|
||||
.cloned()
|
||||
.collect();
|
||||
let mut imported = 0;
|
||||
let mut unsupported = std::collections::BTreeSet::new();
|
||||
for (alias, target) in parsed {
|
||||
@@ -310,9 +314,15 @@ impl OpenCADStudio {
|
||||
self.alias_close_confirm = false;
|
||||
}
|
||||
self.alias_import_report = if imported == 0 && unsupported.is_empty() {
|
||||
crate::t!("PGP: no valid aliases found. The working rows were not changed.").into_owned()
|
||||
crate::t!("PGP: no valid aliases found. The working rows were not changed.")
|
||||
.into_owned()
|
||||
} else {
|
||||
crate::tf!("PGP: {} alias(es) loaded for review; {} unsupported command(s) skipped. No changes activated. Apply to save.", imported, unsupported.len()).into_owned()
|
||||
crate::tf!(
|
||||
"PGP: {} alias(es) loaded for review; {} unsupported command(s) skipped. No changes activated. Apply to save.",
|
||||
imported,
|
||||
unsupported.len()
|
||||
)
|
||||
.into_owned()
|
||||
};
|
||||
self.command_line.push_info(&self.alias_import_report);
|
||||
// Unsupported AutoCAD/Civil 3D commands are an expected compatibility
|
||||
@@ -443,7 +453,13 @@ mod tests {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
let original = app.command_aliases.clone();
|
||||
app.alias_editor_rows = vec![("KEEP".into(), "LINE".into()), ("E".into(), "ERASE".into())];
|
||||
app.import_alias_pgp(b"E,*BORRA\nE,*EMPALME\nSQ,*SCP\nCIVIL,*AECCUNSUPPORTED\nNOTEPAD,START NOTEPAD,1,,\n");
|
||||
app.import_alias_pgp(concat!(
|
||||
"E,*BORRA\n",
|
||||
"E,*EMPALME\n",
|
||||
"SQ,*SCP\n",
|
||||
"CIVIL,*AECCUNSUPPORTED\n",
|
||||
"NOTEPAD,START NOTEPAD,1,,\n",
|
||||
).as_bytes());
|
||||
assert!(app.alias_editor_rows.contains(&("E".into(), "FILLET".into())));
|
||||
assert!(app.alias_editor_rows.contains(&("SQ".into(), "UCS".into())));
|
||||
assert!(app.alias_editor_rows.contains(&("KEEP".into(), "LINE".into())));
|
||||
|
||||
+19
-6
@@ -7,8 +7,10 @@ pub(super) fn decode(bytes: &[u8]) -> String {
|
||||
return text.trim_start_matches('\u{feff}').to_owned();
|
||||
}
|
||||
const HIGH: [char; 32] = [
|
||||
'€', '\u{81}', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '\u{8d}', 'Ž', '\u{8f}',
|
||||
'\u{90}', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', '\u{9d}', 'ž', 'Ÿ',
|
||||
'€', '\u{81}', '‚', 'ƒ', '„', '…', '†', '‡',
|
||||
'ˆ', '‰', 'Š', '‹', 'Œ', '\u{8d}', 'Ž', '\u{8f}',
|
||||
'\u{90}', '‘', '’', '“', '”', '•', '–', '—',
|
||||
'˜', '™', 'š', '›', 'œ', '\u{9d}', 'ž', 'Ÿ',
|
||||
];
|
||||
bytes.iter().map(|&b| match b {
|
||||
0x80..=0x9f => HIGH[(b - 0x80) as usize],
|
||||
@@ -92,9 +94,12 @@ pub(super) fn canonical(target: &str) -> String {
|
||||
"ESCALA3D" => "3DSCALE", "ALINEAR3D" => "3DALIGN", "CAMARA" => "CAMERA",
|
||||
"CILINDRO" => "CYLINDER", "REFEXTERNAS" => "EXTERNALREFERENCES", "GEOPLANA" => "FLATSHOT",
|
||||
"POLISOLIDO" => "POLYSOLID", "PIRAMIDE" => "PYRAMID", "PLANOSECCION" => "SECTIONPLANE",
|
||||
"ESTILVISUAL" => "VISUALSTYLES", "ESTVISACTUAL" => "VSCURRENT", "EDITATRINSITU" => "ATTIPEDIT",
|
||||
"EXTRACDAT" => "DATAEXTRACTION", "ESTADOCAPAS" => "LAYERSTATE", "LUZPUNTUAL" => "POINTLIGHT",
|
||||
"DIRECTRIZM" => "MLEADER", "ESTILDIRECTRIZM" => "MLEADERSTYLE", "EDITARDIRECTRIZM" => "MLEADEREDIT",
|
||||
"ESTILVISUAL" => "VISUALSTYLES", "ESTVISACTUAL" => "VSCURRENT",
|
||||
"EDITATRINSITU" => "ATTIPEDIT",
|
||||
"EXTRACDAT" => "DATAEXTRACTION", "ESTADOCAPAS" => "LAYERSTATE",
|
||||
"LUZPUNTUAL" => "POINTLIGHT",
|
||||
"DIRECTRIZM" => "MLEADER", "ESTILDIRECTRIZM" => "MLEADERSTYLE",
|
||||
"EDITARDIRECTRIZM" => "MLEADEREDIT",
|
||||
"ALINDIRECTRIZM" => "MLEADERALIGN", "COLECDIRECTRIZM" => "MLEADERCOLLECT",
|
||||
"MEDIRGEOM" => "MEASUREGEOM", "PARAMETROS" => "PARAMETERS", "TIPOPUNTO" => "PTYPE",
|
||||
"ALINEARTEXTO" => "TEXTALIGN", "ENLAZARNUBEPUNTOS" => "POINTCLOUDATTACH",
|
||||
@@ -112,7 +117,15 @@ mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn user_overrides_and_external_commands() {
|
||||
let rows = parse("\u{feff}; header\r\nB,*BORRA\r\nNOTEPAD, START NOTEPAD,1,*File:,\nB,*BUSCAR ; custom\nE,*EMPALME\nBAD,*LINE,extra\nL,LINE\n");
|
||||
let rows = parse(concat!(
|
||||
"\u{feff}; header\r\n",
|
||||
"B,*BORRA\r\n",
|
||||
"NOTEPAD, START NOTEPAD,1,*File:,\n",
|
||||
"B,*BUSCAR ; custom\n",
|
||||
"E,*EMPALME\n",
|
||||
"BAD,*LINE,extra\n",
|
||||
"L,LINE\n",
|
||||
));
|
||||
assert_eq!(rows.len(), 3);
|
||||
assert_eq!(canonical(&rows["B"]), "FIND");
|
||||
assert_eq!(canonical(&rows["E"]), "FILLET");
|
||||
|
||||
@@ -15,17 +15,27 @@ impl OpenCADStudio {
|
||||
let current = self.tabs[i].scene.ucs_follow();
|
||||
match value {
|
||||
None => {
|
||||
self.command_line.push_output(crate::tf!(
|
||||
"UCSFOLLOW: enter 0 (keep view) or 1 (follow UCS) <{}>:",
|
||||
u8::from(current)
|
||||
).as_ref());
|
||||
self.command_line.push_output(
|
||||
crate::tf!(
|
||||
"UCSFOLLOW: enter 0 (keep view) or 1 (follow UCS) <{}>:",
|
||||
u8::from(current)
|
||||
)
|
||||
.as_ref(),
|
||||
);
|
||||
self.pending_setvar = Some("UCSFOLLOW".into());
|
||||
}
|
||||
Some("0" | "1") => {
|
||||
let next = value == Some("1");
|
||||
if next && self.tabs[i].scene.current_layout != "Model"
|
||||
&& self.tabs[i].scene.active_viewport.is_none() {
|
||||
self.command_line.push_error(crate::t!("UCSFOLLOW: activate a model viewport; paper space cannot follow the UCS.").as_ref());
|
||||
if next
|
||||
&& self.tabs[i].scene.current_layout != "Model"
|
||||
&& self.tabs[i].scene.active_viewport.is_none()
|
||||
{
|
||||
self.command_line.push_error(
|
||||
crate::t!(
|
||||
"UCSFOLLOW: activate a model viewport; paper space cannot follow the UCS."
|
||||
)
|
||||
.as_ref(),
|
||||
);
|
||||
} else {
|
||||
if current != next {
|
||||
self.push_undo_snapshot(i, "UCSFOLLOW");
|
||||
@@ -48,7 +58,8 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
Some(_) => {
|
||||
self.command_line.push_error(crate::t!("UCSFOLLOW: only 0 or 1 is allowed.").as_ref());
|
||||
self.command_line
|
||||
.push_error(crate::t!("UCSFOLLOW: only 0 or 1 is allowed.").as_ref());
|
||||
}
|
||||
}
|
||||
Some(Task::none())
|
||||
@@ -107,10 +118,12 @@ mod tests {
|
||||
fn floating_viewport_setting_does_not_leak_into_model_or_paper() {
|
||||
let mut app = app();
|
||||
let i = app.active_tab;
|
||||
let first = app.tabs[i].scene.add_entity(codec::EntityType::Viewport(
|
||||
codec::entities::Viewport::new()));
|
||||
let second = app.tabs[i].scene.add_entity(codec::EntityType::Viewport(
|
||||
codec::entities::Viewport::new()));
|
||||
let first = app.tabs[i]
|
||||
.scene
|
||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
||||
let second = app.tabs[i]
|
||||
.scene
|
||||
.add_entity(codec::EntityType::Viewport(codec::entities::Viewport::new()));
|
||||
app.tabs[i].scene.active_viewport = Some(first);
|
||||
let _ = app.run_command_line("UCSFOLLOW 1");
|
||||
assert!(app.tabs[i].scene.ucs_follow());
|
||||
|
||||
@@ -258,10 +258,12 @@ mod tests {
|
||||
fn spanish_and_international_options_work() {
|
||||
for option in ["Universal", "U", "_World"] {
|
||||
let mut cmd = UcsCommand::new();
|
||||
assert!(matches!(cmd.on_text_input(option), Some(CmdResult::Dispatch(s)) if s == "UCS WORLD"));
|
||||
let result = cmd.on_text_input(option);
|
||||
assert!(matches!(result, Some(CmdResult::Dispatch(s)) if s == "UCS WORLD"));
|
||||
}
|
||||
let mut cmd = UcsCommand::new();
|
||||
assert!(matches!(cmd.on_text_input("Guardar"), Some(CmdResult::NeedPoint)));
|
||||
assert!(matches!(cmd.on_text_input("MiPlano"), Some(CmdResult::Dispatch(s)) if s == "UCS SAVE MiPlano"));
|
||||
let result = cmd.on_text_input("MiPlano");
|
||||
assert!(matches!(result, Some(CmdResult::Dispatch(s)) if s == "UCS SAVE MiPlano"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user