diff --git a/README.md b/README.md index 2250e44..dc58448 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Die Weboberflaeche bildet die wichtigsten P-touch-Editor-Funktionen nach: - QR-Code und Code128-Barcode - Layout speichern/laden im Browser - serverseitige Vorschau und Druck ueber `ptouch-print` -- Band-Erkennung mit Breite, Bandtyp, Hintergrundfarbe und Schriftfarbe +- Band-Erkennung mit Breite, bedruckbarer Pixelbreite, Bandtyp, Hintergrundfarbe und Schriftfarbe - einfache Text-only Mobile-Webansicht unter `/mobile` - Schnittmodi: normal, Kettendruck/Streifen, Schnittmarke und Streifen mit Schnittmarke diff --git a/app/app.py b/app/app.py index 515a33c..1cad06f 100644 --- a/app/app.py +++ b/app/app.py @@ -444,6 +444,13 @@ def media_type_from_output(output: str) -> dict[str, str] | None: } +def printable_width_from_output(output: str) -> int | None: + match = re.search(r"maximum printing width[^\n]*?(\d+)\s*px", output, re.IGNORECASE) + if not match: + return None + return int(match.group(1)) + + def detect_tape_info() -> dict[str, Any]: result = subprocess.run( ["ptouch-print", "--info"], @@ -472,6 +479,7 @@ def detect_tape_info() -> dict[str, Any]: return { "width": width, + "printableWidthPx": printable_width_from_output(output), "mediaType": media_type_from_output(output), "tapeColor": color_info_from_line(output, "tape color"), "textColor": color_info_from_line(output, "text color"), diff --git a/app/static/editor.js b/app/static/editor.js index a460fbd..cb9915a 100644 --- a/app/static/editor.js +++ b/app/static/editor.js @@ -39,6 +39,7 @@ const controls = { copies: document.getElementById("copies"), tapeInfo: document.getElementById("tapeInfo"), tapeInfoType: document.getElementById("tapeInfoType"), + tapePrintableWidth: document.getElementById("tapePrintableWidth"), tapeBgSwatch: document.getElementById("tapeBgSwatch"), tapeBgText: document.getElementById("tapeBgText"), tapeTextSwatch: document.getElementById("tapeTextSwatch"), @@ -125,6 +126,7 @@ function updateTapeInfo(info) { const bg = info.tapeColor || { name: "Unbekannt", css: "#d1d5db" }; const text = info.textColor || { name: "Unbekannt", css: "#111111" }; controls.tapeInfoType.textContent = `${info.width} mm · ${media}${info.mediaType?.code ? ` (${info.mediaType.code})` : ""}`; + controls.tapePrintableWidth.textContent = info.printableWidthPx ? `${info.printableWidthPx} px` : "-"; controls.tapeBgText.textContent = `${bg.name}${bg.code ? ` (${bg.code})` : ""}`; controls.tapeBgSwatch.style.background = bg.css; controls.tapeTextText.textContent = `${text.name}${text.code ? ` (${text.code})` : ""}`; diff --git a/app/static/mobile.js b/app/static/mobile.js index 471d48d..54596d7 100644 --- a/app/static/mobile.js +++ b/app/static/mobile.js @@ -9,6 +9,7 @@ const fields = { frame: document.getElementById("mobileFrame"), tapeInfo: document.getElementById("mobileTapeInfo"), tapeInfoType: document.getElementById("mobileTapeInfoType"), + tapePrintableWidth: document.getElementById("mobileTapePrintableWidth"), tapeBgSwatch: document.getElementById("mobileTapeBgSwatch"), tapeBgText: document.getElementById("mobileTapeBgText"), tapeTextSwatch: document.getElementById("mobileTapeTextSwatch"), @@ -36,6 +37,7 @@ function updateTapeInfo(info) { const bg = info.tapeColor || { name: "Unbekannt", css: "#d1d5db" }; const text = info.textColor || { name: "Unbekannt", css: "#111111" }; fields.tapeInfoType.textContent = `${info.width} mm · ${media}${info.mediaType?.code ? ` (${info.mediaType.code})` : ""}`; + fields.tapePrintableWidth.textContent = info.printableWidthPx ? `${info.printableWidthPx} px` : "-"; fields.tapeBgText.textContent = `${bg.name}${bg.code ? ` (${bg.code})` : ""}`; fields.tapeBgSwatch.style.background = bg.css; fields.tapeTextText.textContent = `${text.name}${text.code ? ` (${text.code})` : ""}`; diff --git a/app/templates/index.html b/app/templates/index.html index e45d9e4..33ad063 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -57,6 +57,10 @@ Band - +