fa-console 2.0.0__tar.gz → 2.0.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fa-console
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Correct Persian (Farsi) console input/output for Python on Windows: automatic UTF-8 setup plus visual letter shaping and bidi for the classic console.
5
5
  Author-email: Alireza Hosseini <alireza.hosseini@hotmail.com>
6
6
  License: MIT
@@ -87,9 +87,10 @@ It fixes both independent layers of the problem:
87
87
  - ✅ **Live-typing echo** — `fa_input()` renders letters joined and right-to-left
88
88
  *while you type*, with built-in-`input()`-compatible semantics
89
89
  (`KeyboardInterrupt` / `EOFError`)
90
- - ✅ **Smart detection** — Windows Terminal, VS Code-style terminals, IDEs and
91
- redirected files/pipes are detected and left untouched (standard text flows
92
- there, as it should)
90
+ - ✅ **Smart detection** — Windows Terminal and redirected files/pipes are
91
+ left untouched; the VS Code integrated terminal gets the same visual
92
+ transform as the classic console (its xterm.js engine lacks reliable
93
+ bidi reordering)
93
94
  - ✅ **Fail-open design** — the module never crashes the host application; every
94
95
  internal failure is logged through the `fa_console` logger and degrades
95
96
  gracefully to standard Python behaviour
@@ -175,7 +176,8 @@ terminal type, active bidi backend and a rendered sample.
175
176
  |-------------|-----------|
176
177
  | `cmd.exe` / standalone PowerShell (conhost) | Encoding fixed + visual transform + live typing echo |
177
178
  | Windows Terminal | Encoding fixed; native rendering (module steps aside) |
178
- | VS Code / JetBrains / IDLE consoles | Encoding fixed; module steps aside |
179
+ | VS Code integrated terminal | Encoding fixed + visual transform (xterm.js has no reliable bidi) |
180
+ | JetBrains / IDLE consoles | Encoding fixed; module steps aside (non-tty) |
179
181
  | Output redirected to file / pipe | Standard logical UTF-8 — safe for other tools |
180
182
  | Linux / macOS | Safe no-op (standard behaviour) |
181
183
 
@@ -188,6 +190,10 @@ terminal type, active bidi backend and a rendered sample.
188
190
  — the module detects it and lets it do the shaping.
189
191
  - **Does the transform corrupt my data?** No — it is display-only. Values,
190
192
  comparisons and files always hold logical text.
193
+ - **Persian looks wrong in the VS Code terminal.** That is an xterm.js
194
+ limitation — this package compensates automatically by applying the same
195
+ visual transform used for the classic console (see
196
+ `FA_CONSOLE_NO_VISUAL=1` if you ever need to switch it off).
191
197
  - **Other RTL languages?** The shaping tables cover Arabic and Persian letters;
192
198
  the engine is language-agnostic for the letters it knows.
193
199
 
@@ -50,9 +50,10 @@ It fixes both independent layers of the problem:
50
50
  - ✅ **Live-typing echo** — `fa_input()` renders letters joined and right-to-left
51
51
  *while you type*, with built-in-`input()`-compatible semantics
52
52
  (`KeyboardInterrupt` / `EOFError`)
53
- - ✅ **Smart detection** — Windows Terminal, VS Code-style terminals, IDEs and
54
- redirected files/pipes are detected and left untouched (standard text flows
55
- there, as it should)
53
+ - ✅ **Smart detection** — Windows Terminal and redirected files/pipes are
54
+ left untouched; the VS Code integrated terminal gets the same visual
55
+ transform as the classic console (its xterm.js engine lacks reliable
56
+ bidi reordering)
56
57
  - ✅ **Fail-open design** — the module never crashes the host application; every
57
58
  internal failure is logged through the `fa_console` logger and degrades
58
59
  gracefully to standard Python behaviour
@@ -138,7 +139,8 @@ terminal type, active bidi backend and a rendered sample.
138
139
  |-------------|-----------|
139
140
  | `cmd.exe` / standalone PowerShell (conhost) | Encoding fixed + visual transform + live typing echo |
140
141
  | Windows Terminal | Encoding fixed; native rendering (module steps aside) |
141
- | VS Code / JetBrains / IDLE consoles | Encoding fixed; module steps aside |
142
+ | VS Code integrated terminal | Encoding fixed + visual transform (xterm.js has no reliable bidi) |
143
+ | JetBrains / IDLE consoles | Encoding fixed; module steps aside (non-tty) |
142
144
  | Output redirected to file / pipe | Standard logical UTF-8 — safe for other tools |
143
145
  | Linux / macOS | Safe no-op (standard behaviour) |
144
146
 
@@ -151,6 +153,10 @@ terminal type, active bidi backend and a rendered sample.
151
153
  — the module detects it and lets it do the shaping.
152
154
  - **Does the transform corrupt my data?** No — it is display-only. Values,
153
155
  comparisons and files always hold logical text.
156
+ - **Persian looks wrong in the VS Code terminal.** That is an xterm.js
157
+ limitation — this package compensates automatically by applying the same
158
+ visual transform used for the classic console (see
159
+ `FA_CONSOLE_NO_VISUAL=1` if you ever need to switch it off).
154
160
  - **Other RTL languages?** The shaping tables cover Arabic and Persian letters;
155
161
  the engine is language-agnostic for the letters it knows.
156
162
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fa-console
3
- Version: 2.0.0
3
+ Version: 2.0.2
4
4
  Summary: Correct Persian (Farsi) console input/output for Python on Windows: automatic UTF-8 setup plus visual letter shaping and bidi for the classic console.
5
5
  Author-email: Alireza Hosseini <alireza.hosseini@hotmail.com>
6
6
  License: MIT
@@ -87,9 +87,10 @@ It fixes both independent layers of the problem:
87
87
  - ✅ **Live-typing echo** — `fa_input()` renders letters joined and right-to-left
88
88
  *while you type*, with built-in-`input()`-compatible semantics
89
89
  (`KeyboardInterrupt` / `EOFError`)
90
- - ✅ **Smart detection** — Windows Terminal, VS Code-style terminals, IDEs and
91
- redirected files/pipes are detected and left untouched (standard text flows
92
- there, as it should)
90
+ - ✅ **Smart detection** — Windows Terminal and redirected files/pipes are
91
+ left untouched; the VS Code integrated terminal gets the same visual
92
+ transform as the classic console (its xterm.js engine lacks reliable
93
+ bidi reordering)
93
94
  - ✅ **Fail-open design** — the module never crashes the host application; every
94
95
  internal failure is logged through the `fa_console` logger and degrades
95
96
  gracefully to standard Python behaviour
@@ -175,7 +176,8 @@ terminal type, active bidi backend and a rendered sample.
175
176
  |-------------|-----------|
176
177
  | `cmd.exe` / standalone PowerShell (conhost) | Encoding fixed + visual transform + live typing echo |
177
178
  | Windows Terminal | Encoding fixed; native rendering (module steps aside) |
178
- | VS Code / JetBrains / IDLE consoles | Encoding fixed; module steps aside |
179
+ | VS Code integrated terminal | Encoding fixed + visual transform (xterm.js has no reliable bidi) |
180
+ | JetBrains / IDLE consoles | Encoding fixed; module steps aside (non-tty) |
179
181
  | Output redirected to file / pipe | Standard logical UTF-8 — safe for other tools |
180
182
  | Linux / macOS | Safe no-op (standard behaviour) |
181
183
 
@@ -188,6 +190,10 @@ terminal type, active bidi backend and a rendered sample.
188
190
  — the module detects it and lets it do the shaping.
189
191
  - **Does the transform corrupt my data?** No — it is display-only. Values,
190
192
  comparisons and files always hold logical text.
193
+ - **Persian looks wrong in the VS Code terminal.** That is an xterm.js
194
+ limitation — this package compensates automatically by applying the same
195
+ visual transform used for the classic console (see
196
+ `FA_CONSOLE_NO_VISUAL=1` if you ever need to switch it off).
191
197
  - **Other RTL languages?** The shaping tables cover Arabic and Persian letters;
192
198
  the engine is language-agnostic for the letters it knows.
193
199
 
@@ -92,11 +92,12 @@ downstream tools receive standards-compliant UTF-8.
92
92
  Scope and limitations
93
93
  ---------------------
94
94
 
95
- * The visual transform targets classic ``conhost``. Windows Terminal
96
- (``WT_SESSION``) and VS Code-style terminals (``TERM_PROGRAM``) render
97
- Arabic correctly by themselves; the module detects them and steps
98
- aside. Escape hatches: ``FA_CONSOLE_FORCE_VISUAL=1`` forces the
99
- transform on, ``FA_CONSOLE_NO_VISUAL=1`` forces it off.
95
+ * The visual transform targets the classic console host (``conhost``) and
96
+ the VS Code integrated terminal — xterm.js has no reliable bidirectional
97
+ reordering, so logical Persian renders disconnected/backwards there.
98
+ Windows Terminal (``WT_SESSION``) shapes and reorders Arabic natively
99
+ and is left untouched. Escape hatches: ``FA_CONSOLE_FORCE_VISUAL=1``
100
+ forces the transform on, ``FA_CONSOLE_NO_VISUAL=1`` forces it off.
100
101
  * The live-typing editor mirrors built-in ``input()`` semantics
101
102
  (``KeyboardInterrupt`` on Ctrl+C, ``EOFError`` on Ctrl+Z) but provides
102
103
  no history or cursor movement; arrow keys are consumed and ignored.
@@ -137,7 +138,7 @@ from typing import Any, Iterator
137
138
 
138
139
  __author__ = "Alireza Hosseini"
139
140
  __email__ = "alireza.hosseini@hotmail.com"
140
- __version__ = "2.0.0"
141
+ __version__ = "2.0.2"
141
142
 
142
143
  __all__ = [
143
144
  "FaConsoleError",
@@ -479,11 +480,21 @@ def _reconfigure_stream(name: str) -> bool:
479
480
 
480
481
  def _modern_terminal() -> bool:
481
482
  """
482
- ``True`` for terminals that shape and reorder Arabic text natively
483
- (Windows Terminal, VS Code-style terminals). The visual transform
484
- stays off there to avoid double processing.
483
+ ``True`` for terminals that shape and reorder Arabic text natively and
484
+ reliably — Windows Terminal (``WT_SESSION``) and other ``TERM_PROGRAM``
485
+ hosts (mintty, etc.).
486
+
487
+ Note:
488
+ VS Code's integrated terminal (``TERM_PROGRAM=vscode``, powered by
489
+ xterm.js) deliberately does **not** count as modern: xterm.js lacks
490
+ reliable bidirectional reordering for RTL text, so logical Persian
491
+ appears disconnected/backwards there. The visual transform is
492
+ therefore applied inside VS Code as well.
485
493
  """
486
- return bool(os.environ.get("WT_SESSION") or os.environ.get("TERM_PROGRAM"))
494
+ if os.environ.get("WT_SESSION"):
495
+ return True
496
+ term_program = os.environ.get("TERM_PROGRAM")
497
+ return bool(term_program) and term_program != "vscode"
487
498
 
488
499
 
489
500
  # --------------------------------------------------------------------------- #
@@ -1071,6 +1082,7 @@ def get_console_info() -> dict[str, Any]:
1071
1082
  "stdout_isatty": _stream_isatty(sys.stdout),
1072
1083
  "console_codepage": _get_console_output_codepage(),
1073
1084
  "modern_terminal": _modern_terminal(),
1085
+ "term_program": os.environ.get("TERM_PROGRAM"),
1074
1086
  "visual_mode": _visual_mode,
1075
1087
  "bidi_backend": _transformer.backend_name if _visual_mode else "none",
1076
1088
  "force_visual_env": bool(os.environ.get(ENV_FORCE_VISUAL)),
@@ -4,7 +4,9 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fa-console"
7
- version = "2.0.0"
7
+ # Single source of truth: the version lives in fa_console.__version__ and is
8
+ # injected here at build time, so it can never drift between module and package.
9
+ dynamic = ["version"]
8
10
  description = "Correct Persian (Farsi) console input/output for Python on Windows: automatic UTF-8 setup plus visual letter shaping and bidi for the classic console."
9
11
  readme = "README.md"
10
12
  requires-python = ">=3.8"
@@ -56,3 +58,6 @@ Issues = "https://github.com/Padandish/fa-console/issues"
56
58
  [tool.setuptools]
57
59
  # Flat layout: publish the single module without restructuring the folder.
58
60
  py-modules = ["fa_console"]
61
+
62
+ [tool.setuptools.dynamic]
63
+ version = { attr = "fa_console.__version__" }
File without changes
File without changes