chemql-python 1.6.9__tar.gz → 1.6.11__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.
Files changed (49) hide show
  1. {chemql_python-1.6.9/src/chemql_python.egg-info → chemql_python-1.6.11}/PKG-INFO +42 -10
  2. chemql_python-1.6.9/PKG-INFO → chemql_python-1.6.11/README.md +41 -23
  3. {chemql_python-1.6.9 → chemql_python-1.6.11}/pyproject.toml +3 -2
  4. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/__init__.py +21 -1
  5. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/codecql.py +38 -13
  6. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/codecql_gui_core.py +0 -4
  7. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/codecqlx.py +189 -61
  8. chemql_python-1.6.11/src/chemql/logo64-macos.png +0 -0
  9. chemql_python-1.6.9/README.md → chemql_python-1.6.11/src/chemql_python.egg-info/PKG-INFO +55 -9
  10. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql_python.egg-info/SOURCES.txt +3 -0
  11. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_codecql.py +30 -7
  12. chemql_python-1.6.11/tests/test_codecqlx_fonts.py +27 -0
  13. chemql_python-1.6.11/tests/test_codecqlx_icon.py +15 -0
  14. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_public_api.py +6 -0
  15. {chemql_python-1.6.9 → chemql_python-1.6.11}/LICENSE +0 -0
  16. {chemql_python-1.6.9 → chemql_python-1.6.11}/setup.cfg +0 -0
  17. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/__main__.py +0 -0
  18. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/build.py +0 -0
  19. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/colors.json +0 -0
  20. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/BondEnergies.json +0 -0
  21. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/MoleculeBonds.json +0 -0
  22. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/Molecules.json +0 -0
  23. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/PeriodicTableJSON.json +0 -0
  24. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/Reactions.json +0 -0
  25. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  26. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  27. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/highlighting.json +0 -0
  28. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/highlighting.py +0 -0
  29. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/html/periodic_table.html +0 -0
  30. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/logo64.png +0 -0
  31. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/README.md +0 -0
  32. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/collections.cql +0 -0
  33. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/datetime.cql +0 -0
  34. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/decimal.cql +0 -0
  35. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/fractions.cql +0 -0
  36. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/json.cql +0 -0
  37. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/math/statistics.cql +0 -0
  38. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/math.cql +0 -0
  39. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/pathlib.cql +0 -0
  40. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/random.cql +0 -0
  41. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql/stdlib/text.cql +0 -0
  42. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  43. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql_python.egg-info/entry_points.txt +0 -0
  44. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql_python.egg-info/requires.txt +0 -0
  45. {chemql_python-1.6.9 → chemql_python-1.6.11}/src/chemql_python.egg-info/top_level.txt +0 -0
  46. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_external_molecule_lookup.py +0 -0
  47. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_reactions.py +0 -0
  48. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_stdlib.py +0 -0
  49. {chemql_python-1.6.9 → chemql_python-1.6.11}/tests/test_structured_types.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.6.9
3
+ Version: 1.6.11
4
4
  Summary: A chemistry-focused query language and REPL
5
5
  Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
- Requires-Python: >=3.10
6
+ Requires-Python: >=3.12
7
7
  Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Requires-Dist: prompt_toolkit>=3.0
@@ -20,9 +20,9 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
20
20
 
21
21
  - **Distribution name:** `chemql-python`
22
22
  - **Import / CLI name:** `chemql`
23
- - **Language version:** `1.6.9` (per `chemql.__version__`)
24
- - **Editor version:** `codecql 0.1.1`
25
- - **GUI Editor version:** `CodecQLX 1.0.0`
23
+ - **Language version:** `1.6.11` (per `chemql.__version__`)
24
+ - **Editor version:** `codecql 0.1.2`
25
+ - **GUI Editor version:** `CodecQLX 1.1.1`
26
26
  - **Python import / CLI name:** `chemql`
27
27
  - **Author:** Mohammad Rakibul Islam
28
28
  - **Minimum Python:** **3.12+** (verified with `vermin`)
@@ -44,6 +44,15 @@ Verify:
44
44
  chemql --version
45
45
  ```
46
46
 
47
+ If the `chemql` command is unavailable or fails to start, use
48
+ `python -m chemql` with the same arguments instead:
49
+
50
+ ```bash
51
+ python -m chemql --version
52
+ python -m chemql -c 'search elements symbol = "Fe" return name symbol number'
53
+ python -m chemql -f script.cql
54
+ ```
55
+
47
56
  Python **3.12+** is required. The project's minimum version is checked with [`vermin`](https://github.com/netromdk/vermin).
48
57
 
49
58
  ---
@@ -467,7 +476,7 @@ ls
467
476
 
468
477
  | | |
469
478
  |---|---|
470
- | Version | 0.1.1 |
479
+ | Version | 0.1.2 |
471
480
  | Ships with | `chemql-python` |
472
481
  | Files | `.cql` (ChemQL), `.py`, `cqlpackage.json` / `cqlpackage.toml`, and any plain-text file |
473
482
 
@@ -481,7 +490,9 @@ chemql edit --local-highlighting # edit ./highlighting.json (created as {}
481
490
  chemql edit --version
482
491
  ```
483
492
 
484
- If your installation also registers a `codecql` console script, `codecql FILE` accepts the same options.
493
+ If the `codecql` command is unavailable or fails to start, run
494
+ `python -m chemql.codecql FILE` instead. It accepts the same options as
495
+ `chemql edit`, including the highlighting configuration options.
485
496
 
486
497
  Opening a path that does not exist starts an empty buffer; it is created on the first save.
487
498
 
@@ -505,12 +516,16 @@ Opening a path that does not exist starts an empty buffer; it is created on the
505
516
  | `Ctrl` + `↑` `↓` | Scroll the view without moving the text |
506
517
  | `Backspace`, `Delete` | Delete a character, or the selection |
507
518
  | `Ctrl+Backspace` / `Alt+Backspace` | Delete the word to the left |
519
+ | `Command+Backspace` (macOS, when sent as CSI-u) | Delete to the start of the line |
508
520
  | `Ctrl+Delete` / `Alt+Delete` | Delete the word to the right |
509
521
  | `Ctrl+C` / `Ctrl+Insert` | Copy the selection (editor + system clipboard when available). It does **not** quit |
510
522
  | `Ctrl+X` | Cut the selection |
511
523
  | `Ctrl+V` / `Shift+Insert` | Paste the editor's clipboard |
512
524
 
513
- Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so multi-line pastes arrive as a single insertion.
525
+ Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so
526
+ multi-line pastes arrive as a single insertion. The terminal must forward macOS Command-key
527
+ combinations using the CSI-u keyboard protocol; otherwise it may consume or remap them before
528
+ CodecQL receives them.
514
529
 
515
530
  **Auto-indent.** After a line that opens a block (`func`, `define NAME{}`, `struct`, `record`, `enum`, `namespace`, `if`, `elif`, `else`, `for`, `while`) or ends in a `\` continuation, the next line is indented with a tab. Pressing Enter after `endnamespace` removes one level of indentation. Other `end...` keywords do not dedent automatically.
516
531
 
@@ -818,7 +833,6 @@ Each entry needs an `ansi256` number from 0 to 255, and an optional `channel` of
818
833
  - Auto-dedent applies only after `endnamespace`.
819
834
  - One file per session: there are no tabs or split editors.
820
835
  - Tabs are drawn four columns wide.
821
- - CodecQL's Windows Backspace / Ctrl+Backspace are intentionally inverted relative to POSIX.
822
836
 
823
837
  ## CodecQLX — the desktop editor
824
838
 
@@ -834,6 +848,14 @@ python -m chemql.codecqlx FILE_OR_FOLDER ...
834
848
  codecqlx --version
835
849
  ```
836
850
 
851
+ If the `codecqlx` command is unavailable or fails to start, use
852
+ `python -m chemql.codecqlx` with the same arguments:
853
+
854
+ ```bash
855
+ python -m chemql.codecqlx FILE_OR_FOLDER ...
856
+ python -m chemql.codecqlx --version
857
+ ```
858
+
837
859
  Paths are optional. A new empty file is opened when no path is supplied;
838
860
  files and folders passed on the command line are opened in the editor. The
839
861
  `codecqlx` command is installed with `chemql-python`.
@@ -847,7 +869,8 @@ the `chemql` package cannot be imported.
847
869
 
848
870
  - Syntax highlighting and context-aware autocomplete for `.cql` files
849
871
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
850
- - File tree sidebar with multiple editor tabs
872
+ - File tree sidebar, recent files, and multiple editor tabs
873
+ - Side-by-side editor panes for working with different files
851
874
  - Query Console that executes ChemQL in-process and displays table or card results
852
875
  - Interactive Periodic Table lookup
853
876
  - Balance Equation panel
@@ -855,7 +878,16 @@ the `chemql` package cannot be imported.
855
878
  - Dark and light themes, font settings, autocomplete/minimap toggles, and
856
879
  per-token color preferences
857
880
 
881
+ When enabled, CodecQLX prefers an installed programming font with ligature
882
+ support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
883
+ monospace font. Install a ligature font on your system; the native Tk text
884
+ renderer and font must support shaping for ligature glyphs to appear. A custom
885
+ font family selected in **Preferences > General** is kept as-is.
886
+
858
887
  Use **View** to toggle the file tree, Chemistry panel, and bottom panels.
888
+ Enable **View > Split Editor**, then choose **File > Open File in Other Pane**
889
+ to work with a second file side by side. Close all tabs in the second pane
890
+ before turning split view off.
859
891
  CodecQLX stores its preferences in `.codecql_gui/settings.json` under the
860
892
  user profile (`%APPDATA%` on Windows).
861
893
 
@@ -1,17 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: chemql-python
3
- Version: 1.6.9
4
- Summary: A chemistry-focused query language and REPL
5
- Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: prompt_toolkit>=3.0
10
- Requires-Dist: rich>=13.7
11
- Provides-Extra: test
12
- Requires-Dist: pytest>=8.0; extra == "test"
13
- Dynamic: license-file
14
-
15
1
  # ChemQL & CodecQL
16
2
 
17
3
  > A Python-embedded query language and terminal toolchain for chemistry data — with a purpose-built editor, package manager, and standard library.
@@ -20,9 +6,9 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
20
6
 
21
7
  - **Distribution name:** `chemql-python`
22
8
  - **Import / CLI name:** `chemql`
23
- - **Language version:** `1.6.9` (per `chemql.__version__`)
24
- - **Editor version:** `codecql 0.1.1`
25
- - **GUI Editor version:** `CodecQLX 1.0.0`
9
+ - **Language version:** `1.6.11` (per `chemql.__version__`)
10
+ - **Editor version:** `codecql 0.1.2`
11
+ - **GUI Editor version:** `CodecQLX 1.1.1`
26
12
  - **Python import / CLI name:** `chemql`
27
13
  - **Author:** Mohammad Rakibul Islam
28
14
  - **Minimum Python:** **3.12+** (verified with `vermin`)
@@ -44,6 +30,15 @@ Verify:
44
30
  chemql --version
45
31
  ```
46
32
 
33
+ If the `chemql` command is unavailable or fails to start, use
34
+ `python -m chemql` with the same arguments instead:
35
+
36
+ ```bash
37
+ python -m chemql --version
38
+ python -m chemql -c 'search elements symbol = "Fe" return name symbol number'
39
+ python -m chemql -f script.cql
40
+ ```
41
+
47
42
  Python **3.12+** is required. The project's minimum version is checked with [`vermin`](https://github.com/netromdk/vermin).
48
43
 
49
44
  ---
@@ -467,7 +462,7 @@ ls
467
462
 
468
463
  | | |
469
464
  |---|---|
470
- | Version | 0.1.1 |
465
+ | Version | 0.1.2 |
471
466
  | Ships with | `chemql-python` |
472
467
  | Files | `.cql` (ChemQL), `.py`, `cqlpackage.json` / `cqlpackage.toml`, and any plain-text file |
473
468
 
@@ -481,7 +476,9 @@ chemql edit --local-highlighting # edit ./highlighting.json (created as {}
481
476
  chemql edit --version
482
477
  ```
483
478
 
484
- If your installation also registers a `codecql` console script, `codecql FILE` accepts the same options.
479
+ If the `codecql` command is unavailable or fails to start, run
480
+ `python -m chemql.codecql FILE` instead. It accepts the same options as
481
+ `chemql edit`, including the highlighting configuration options.
485
482
 
486
483
  Opening a path that does not exist starts an empty buffer; it is created on the first save.
487
484
 
@@ -505,12 +502,16 @@ Opening a path that does not exist starts an empty buffer; it is created on the
505
502
  | `Ctrl` + `↑` `↓` | Scroll the view without moving the text |
506
503
  | `Backspace`, `Delete` | Delete a character, or the selection |
507
504
  | `Ctrl+Backspace` / `Alt+Backspace` | Delete the word to the left |
505
+ | `Command+Backspace` (macOS, when sent as CSI-u) | Delete to the start of the line |
508
506
  | `Ctrl+Delete` / `Alt+Delete` | Delete the word to the right |
509
507
  | `Ctrl+C` / `Ctrl+Insert` | Copy the selection (editor + system clipboard when available). It does **not** quit |
510
508
  | `Ctrl+X` | Cut the selection |
511
509
  | `Ctrl+V` / `Shift+Insert` | Paste the editor's clipboard |
512
510
 
513
- Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so multi-line pastes arrive as a single insertion.
511
+ Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so
512
+ multi-line pastes arrive as a single insertion. The terminal must forward macOS Command-key
513
+ combinations using the CSI-u keyboard protocol; otherwise it may consume or remap them before
514
+ CodecQL receives them.
514
515
 
515
516
  **Auto-indent.** After a line that opens a block (`func`, `define NAME{}`, `struct`, `record`, `enum`, `namespace`, `if`, `elif`, `else`, `for`, `while`) or ends in a `\` continuation, the next line is indented with a tab. Pressing Enter after `endnamespace` removes one level of indentation. Other `end...` keywords do not dedent automatically.
516
517
 
@@ -818,7 +819,6 @@ Each entry needs an `ansi256` number from 0 to 255, and an optional `channel` of
818
819
  - Auto-dedent applies only after `endnamespace`.
819
820
  - One file per session: there are no tabs or split editors.
820
821
  - Tabs are drawn four columns wide.
821
- - CodecQL's Windows Backspace / Ctrl+Backspace are intentionally inverted relative to POSIX.
822
822
 
823
823
  ## CodecQLX — the desktop editor
824
824
 
@@ -834,6 +834,14 @@ python -m chemql.codecqlx FILE_OR_FOLDER ...
834
834
  codecqlx --version
835
835
  ```
836
836
 
837
+ If the `codecqlx` command is unavailable or fails to start, use
838
+ `python -m chemql.codecqlx` with the same arguments:
839
+
840
+ ```bash
841
+ python -m chemql.codecqlx FILE_OR_FOLDER ...
842
+ python -m chemql.codecqlx --version
843
+ ```
844
+
837
845
  Paths are optional. A new empty file is opened when no path is supplied;
838
846
  files and folders passed on the command line are opened in the editor. The
839
847
  `codecqlx` command is installed with `chemql-python`.
@@ -847,7 +855,8 @@ the `chemql` package cannot be imported.
847
855
 
848
856
  - Syntax highlighting and context-aware autocomplete for `.cql` files
849
857
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
850
- - File tree sidebar with multiple editor tabs
858
+ - File tree sidebar, recent files, and multiple editor tabs
859
+ - Side-by-side editor panes for working with different files
851
860
  - Query Console that executes ChemQL in-process and displays table or card results
852
861
  - Interactive Periodic Table lookup
853
862
  - Balance Equation panel
@@ -855,7 +864,16 @@ the `chemql` package cannot be imported.
855
864
  - Dark and light themes, font settings, autocomplete/minimap toggles, and
856
865
  per-token color preferences
857
866
 
867
+ When enabled, CodecQLX prefers an installed programming font with ligature
868
+ support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
869
+ monospace font. Install a ligature font on your system; the native Tk text
870
+ renderer and font must support shaping for ligature glyphs to appear. A custom
871
+ font family selected in **Preferences > General** is kept as-is.
872
+
858
873
  Use **View** to toggle the file tree, Chemistry panel, and bottom panels.
874
+ Enable **View > Split Editor**, then choose **File > Open File in Other Pane**
875
+ to work with a second file side by side. Close all tabs in the second pane
876
+ before turning split view off.
859
877
  CodecQLX stores its preferences in `.codecql_gui/settings.json` under the
860
878
  user profile (`%APPDATA%` on Windows).
861
879
 
@@ -940,4 +958,4 @@ Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017
940
958
 
941
959
  For the command reference that matches your installed build, type `help`
942
960
  inside ChemQL. Use `list all` to inspect fields available in your
943
- bundled datasets.
961
+ bundled datasets.
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "1.6.9"
7
+ version = "1.6.11"
8
8
  authors = [
9
9
  { name = "Mohammad Rakibul Islam", email = "rakibulofficial1017@gmail.com" }
10
10
  ]
11
11
  description = "A chemistry-focused query language and REPL"
12
12
  readme = "README.md"
13
- requires-python = ">=3.10"
13
+ requires-python = ">=3.12"
14
14
  dependencies = [
15
15
  "prompt_toolkit>=3.0",
16
16
  "rich>=13.7",
@@ -34,6 +34,7 @@ where = ["src"]
34
34
  chemql = [
35
35
  "colors.json",
36
36
  "logo64.png",
37
+ "logo64-macos.png",
37
38
  "highlighting.json",
38
39
  "data/*.json",
39
40
  "data/THIRD_PARTY_LICENSES/*.txt",
@@ -69,7 +69,7 @@ __all__ = [
69
69
  "__version__"
70
70
  ]
71
71
 
72
- __version__ = "1.6.9"
72
+ __version__ = "1.6.11"
73
73
 
74
74
  # Persistent preprocessor/function state for the current ChemQL session.
75
75
  DEFINITIONS = {}
@@ -3985,8 +3985,28 @@ def interpolate_query(text):
3985
3985
  """Evaluate [Python] expressions inside a query."""
3986
3986
  result = []
3987
3987
  i = 0
3988
+ quote = None
3989
+ escaped = False
3988
3990
 
3989
3991
  while i < len(text):
3992
+ if quote is not None:
3993
+ char = text[i]
3994
+ result.append(char)
3995
+ if escaped:
3996
+ escaped = False
3997
+ elif char == "\\":
3998
+ escaped = True
3999
+ elif char == quote:
4000
+ quote = None
4001
+ i += 1
4002
+ continue
4003
+
4004
+ if text[i] in ("'", '"'):
4005
+ quote = text[i]
4006
+ result.append(text[i])
4007
+ i += 1
4008
+ continue
4009
+
3990
4010
  if text[i] == "[":
3991
4011
  end = find_matching(text, i, "[", "]")
3992
4012
  code = text[i + 1:end]
@@ -11,7 +11,7 @@ import subprocess
11
11
  import time
12
12
  from .highlighting import HighlightProfiles
13
13
 
14
- VERSION = "0.1.1"
14
+ VERSION = "0.1.2"
15
15
 
16
16
 
17
17
  def _write_system_clipboard(text):
@@ -134,6 +134,8 @@ def _decode_escape_sequence(sequence):
134
134
  modifiers.append("alt")
135
135
  if modifier_bits & 1:
136
136
  modifiers.append("shift")
137
+ if modifier_bits & 8:
138
+ modifiers.append("super")
137
139
 
138
140
  arrow_keys = {
139
141
  b"A": "arrow_up", b"B": "arrow_down",
@@ -175,6 +177,15 @@ def _decode_escape_sequence(sequence):
175
177
  return "\x1b"
176
178
 
177
179
 
180
+ def _decode_backspace_byte(key_byte, erase_char):
181
+ """Distinguish plain Backspace from Ctrl+Backspace using the tty erase key."""
182
+ if isinstance(erase_char, int):
183
+ erase_char = bytes((erase_char,))
184
+ if erase_char not in (b"\x08", b"\x7f"):
185
+ erase_char = b"\x7f"
186
+ return "backspace" if key_byte == erase_char else "ctrl+backspace"
187
+
188
+
178
189
  def _parse_search_query(query):
179
190
  flags = ""
180
191
  pattern = query
@@ -295,6 +306,9 @@ else:
295
306
  return "alt+" + char
296
307
  return "\x1b"
297
308
  return "\x1b"
309
+ if first in (b"\x08", b"\x7f"):
310
+ erase_char = old_settings[6][termios.VERASE]
311
+ return _decode_backspace_byte(first, erase_char)
298
312
  if not first:
299
313
  return ""
300
314
  char_length = (
@@ -1126,18 +1140,18 @@ class Editor:
1126
1140
  self._scroll_view(-1 if base_key == "arrow_up" else 1)
1127
1141
  else:
1128
1142
  self._move_cursor(base_key, shift=shift, wordwise=wordwise)
1129
- elif key in ("\x08", "ctrl+backspace", "alt+backspace"):
1130
- if os.name == "nt":
1131
- if not self._delete_selection(): # For some reason on windows it is the opposit
1132
- self._backspace() # I have no idea why just stick to it
1133
- else:
1134
- self._delete_word("left")
1135
- elif key in ("\x7f", "backspace"):
1136
- if os.name == "nt":
1137
- self._delete_word("left") # same here
1138
- else:
1139
- if not self._delete_selection():
1140
- self._backspace()
1143
+ elif os.name == "nt" and key in ("\x08", "ctrl+backspace", "alt+backspace"):
1144
+ if not self._delete_selection():
1145
+ self._backspace()
1146
+ elif os.name == "nt" and key == "\x7f":
1147
+ self._delete_word("left")
1148
+ elif key in ("backspace", "\x08", "\x7f"):
1149
+ if not self._delete_selection():
1150
+ self._backspace()
1151
+ elif key in ("ctrl+backspace", "alt+backspace"):
1152
+ self._delete_word("left")
1153
+ elif key in ("super+backspace", "cmd+backspace", "command+backspace"):
1154
+ self._delete_to_line_start()
1141
1155
  elif key in ("ctrl+delete", "alt+delete"):
1142
1156
  self._delete_word("right")
1143
1157
  elif key in ("delete", "\x1b[3~"):
@@ -1604,6 +1618,17 @@ class Editor:
1604
1618
  self.dirty = True
1605
1619
  self._refresh_search_matches()
1606
1620
 
1621
+ def _delete_to_line_start(self):
1622
+ if self._delete_selection():
1623
+ return
1624
+ if self.cursor_x == 0:
1625
+ return
1626
+ self._record_history()
1627
+ self.lines[self.cursor_y] = self.lines[self.cursor_y][self.cursor_x:]
1628
+ self.cursor_x = 0
1629
+ self.dirty = True
1630
+ self._refresh_search_matches()
1631
+
1607
1632
  def _move_cursor(self, direction, shift=False, wordwise=False):
1608
1633
  if shift and self.selection_anchor is None:
1609
1634
  self.selection_anchor = (self.cursor_x, self.cursor_y)
@@ -562,10 +562,6 @@ class DiagnosticsEngine:
562
562
  # colors.json, which the CLI editor owns and which this app must not alter)
563
563
  # --------------------------------------------------------------------------
564
564
 
565
- DEFAULT_LIGATURES = {
566
- "<->": "\u21cc", "->": "\u2192", ">=": "\u2265", "<=": "\u2264", "!=": "\u2260",
567
- }
568
-
569
565
  DARK_THEME = {
570
566
  "background": "#1e1e1e", "foreground": "#d4d4d4", "gutter": "#858585",
571
567
  "gutter_bg": "#252526", "selection": "#264f78", "current_line": "#2a2d2e",
@@ -20,8 +20,9 @@ structurally cannot do:
20
20
  of hand-editing JSON.
21
21
  - An overview ruler (a mini error/warning map down the scrollbar) and
22
22
  bookmarks for fast navigation in long files.
23
+ - Recent files and side-by-side panes for working across multiple files.
23
24
 
24
- Run with: python codecql_gui.py [file_or_folder ...]
25
+ Run with: python -m chemql.codecqlx [file_or_folder ...]
25
26
  Needs only the standard library; chemql-specific panels disable
26
27
  themselves gracefully if the `chemql` package isn't installed.
27
28
  """
@@ -40,17 +41,32 @@ from typing import Optional
40
41
  from . import codecql_gui_core as core
41
42
 
42
43
  APP_TITLE = "CodecQLX"
43
- APP_ICON = (Path(__file__).resolve().parent / "logo64.png")
44
+
45
+
46
+ def _app_icon_path(platform: str) -> Path:
47
+ filename = "logo64-macos.png" if platform == "darwin" else "logo64.png"
48
+ return Path(__file__).resolve().parent / filename
49
+
50
+
51
+ APP_ICON = _app_icon_path(sys.platform)
44
52
  FONT_MONO_FALLBACKS = ["Consolas", "Menlo", "DejaVu Sans Mono", "Courier New", "monospace"]
53
+ FONT_LIGATURE_FAMILIES = (
54
+ "Fira Code", "JetBrains Mono", "Cascadia Code", "Iosevka",
55
+ "Victor Mono", "Monaspace Neon",
56
+ )
57
+ DEFAULT_FONT_FAMILIES = {"Consolas", "Menlo", "DejaVu Sans Mono"}
45
58
 
46
59
 
47
- def _pick_font_family(preferred: str) -> str:
60
+ def _pick_font_family(preferred: str, ligatures_enabled: bool = True) -> str:
48
61
  try:
49
62
  import tkinter.font as tkfont
50
63
  available = set(tkfont.families())
51
64
  except Exception:
52
65
  return preferred
53
- for candidate in [preferred, *FONT_MONO_FALLBACKS]:
66
+ candidates = [preferred, *FONT_MONO_FALLBACKS]
67
+ if ligatures_enabled and preferred in DEFAULT_FONT_FAMILIES:
68
+ candidates = [*FONT_LIGATURE_FAMILIES, *candidates]
69
+ for candidate in dict.fromkeys(candidates):
54
70
  if candidate in available:
55
71
  return candidate
56
72
  return preferred
@@ -296,6 +312,11 @@ class EditorTab(ttk.Frame):
296
312
  self.text.bind("<Button-4>", self._on_mousewheel) # Linux scroll up
297
313
  self.text.bind("<Button-5>", self._on_mousewheel) # Linux scroll down
298
314
  self.text.bind("<Control-MouseWheel>", self._on_ctrl_mousewheel)
315
+ self.text.bind(
316
+ "<FocusIn>",
317
+ lambda _event: self.app.set_active_notebook(self.master),
318
+ add="+",
319
+ )
299
320
  self.gutter.bind("<Button-1>", self._on_gutter_click)
300
321
  self.ruler.bind("<Button-1>", self._on_ruler_click)
301
322
  self.gutter.bind("<Configure>", lambda _e: self._redraw_gutter())
@@ -459,13 +480,11 @@ class EditorTab(ttk.Frame):
459
480
  for tag in self._all_syntax_tags():
460
481
  self.text.tag_remove(tag, "1.0", "end")
461
482
  lines = self.get_lines()
462
- ligatures = self.app.active_ligatures()
463
483
  for line_index, line in enumerate(lines, start=1):
464
484
  for token in self.app.tokenizer.tokenize_line(line):
465
485
  start = f"{line_index}.{token.start}"
466
486
  end = f"{line_index}.{token.end}"
467
487
  self.text.tag_add(token.tag, start, end)
468
- self._apply_ligature_display(ligatures)
469
488
  self._redraw_gutter()
470
489
  self._redraw_ruler()
471
490
 
@@ -477,14 +496,6 @@ class EditorTab(ttk.Frame):
477
496
  for token in self.app.tokenizer.tokenize_line(line):
478
497
  self.text.tag_add(token.tag, f"{line_no}.{token.start}", f"{line_no}.{token.end}")
479
498
 
480
- def _apply_ligature_display(self, ligatures: dict[str, str]) -> None:
481
- """Visual-only: Tkinter can't substitute display glyphs without
482
- changing the buffer, so ligatures are shown as a highlighted span
483
- with a tooltip-free hint via the 'operator' tag's own color; a true
484
- glyph swap would require editing the stored text, which must never
485
- happen (see settings: ligatures only affect color emphasis here)."""
486
- return # intentionally a no-op placeholder; see docstring
487
-
488
499
  # -- gutter / overview ruler --------------------------------------------
489
500
 
490
501
  def _visible_line_range(self) -> tuple[int, int]:
@@ -611,6 +622,12 @@ class EditorTab(ttk.Frame):
611
622
  target = filedialog.asksaveasfilename(defaultextension=".cql", filetypes=[("ChemQL", "*.cql"), ("All files", "*.*")])
612
623
  if not target:
613
624
  return False
625
+ if any(
626
+ tab is not self and tab.path and os.path.abspath(tab.path) == os.path.abspath(target)
627
+ for tab in self.app._iter_tabs()
628
+ ):
629
+ messagebox.showerror(APP_TITLE, "That file is already open in another tab.")
630
+ return False
614
631
  try:
615
632
  Path(target).write_text(self.text.get("1.0", "end-1c"), encoding="utf-8")
616
633
  except OSError as error:
@@ -619,6 +636,7 @@ class EditorTab(ttk.Frame):
619
636
  self.path = target
620
637
  self.mark_clean()
621
638
  self.app.settings.remember_file(target)
639
+ self.app.refresh_recent_files()
622
640
  self._schedule_diagnostics()
623
641
  return True
624
642
 
@@ -938,7 +956,7 @@ class PreferencesDialog(tk.Toplevel):
938
956
  ttk.Spinbox(general, from_=8, to=32, textvariable=self.font_size_var, width=5).grid(row=2, column=1, sticky="w")
939
957
 
940
958
  self.ligatures_var = tk.BooleanVar(value=settings.data.get("ligatures_enabled", True))
941
- ttk.Checkbutton(general, text="Highlight comparison operators (>=, <=, ...) distinctly",
959
+ ttk.Checkbutton(general, text="Prefer a programming font with ligatures when available",
942
960
  variable=self.ligatures_var).grid(row=3, column=0, columnspan=3, sticky="w", padx=6, pady=(10, 2))
943
961
  self.autocomplete_var = tk.BooleanVar(value=settings.data.get("autocomplete_enabled", True))
944
962
  ttk.Checkbutton(general, text="Autocomplete suggestions", variable=self.autocomplete_var).grid(
@@ -1106,7 +1124,13 @@ class App(tk.Tk):
1106
1124
  self.suggestion_engine = core.default_suggestion_engine()
1107
1125
  self.tokenizer = core.tokenizer_for(self.suggestion_engine, ".cql")
1108
1126
  self.bridge = core.ChemQLBridge()
1109
- self.editor_font = (_pick_font_family(self.settings.data["font_family"]), self.settings.data["font_size"])
1127
+ self.editor_font = (
1128
+ _pick_font_family(
1129
+ self.settings.data["font_family"],
1130
+ self.settings.data.get("ligatures_enabled", True),
1131
+ ),
1132
+ self.settings.data["font_size"],
1133
+ )
1110
1134
 
1111
1135
  self._run_proc = None
1112
1136
  self._run_queue: "queue.Queue[tuple[str, str]]" = queue.Queue()
@@ -1121,7 +1145,7 @@ class App(tk.Tk):
1121
1145
  self.open_folder(path)
1122
1146
  elif os.path.isfile(path):
1123
1147
  self.open_file(path)
1124
- if not self.notebook.tabs():
1148
+ if not self._iter_tabs():
1125
1149
  self.new_file()
1126
1150
 
1127
1151
  self.protocol("WM_DELETE_WINDOW", self.on_close)
@@ -1136,7 +1160,11 @@ class App(tk.Tk):
1136
1160
  file_menu = tk.Menu(menubar, tearoff=False)
1137
1161
  file_menu.add_command(label="New File", command=self.new_file, accelerator="Ctrl+N")
1138
1162
  file_menu.add_command(label="Open File...", command=self.open_file_dialog, accelerator="Ctrl+O")
1163
+ file_menu.add_command(label="Open File in Other Pane...", command=self.open_file_in_other_pane)
1139
1164
  file_menu.add_command(label="Open Folder...", command=self.open_folder_dialog, accelerator="Ctrl+Shift+O")
1165
+ self.recent_files_menu = tk.Menu(file_menu, tearoff=False)
1166
+ self.recent_files_menu.configure(postcommand=self.refresh_recent_files)
1167
+ file_menu.add_cascade(label="Recent Files", menu=self.recent_files_menu)
1140
1168
  file_menu.add_separator()
1141
1169
  file_menu.add_command(label="Save", command=self.save_current, accelerator="Ctrl+S")
1142
1170
  file_menu.add_command(label="Save As...", command=self.save_current_as, accelerator="Ctrl+Shift+S")
@@ -1165,9 +1193,11 @@ class App(tk.Tk):
1165
1193
  self.show_sidebar_var = tk.BooleanVar(value=True)
1166
1194
  self.show_right_var = tk.BooleanVar(value=True)
1167
1195
  self.show_bottom_var = tk.BooleanVar(value=True)
1196
+ self.split_editor_var = tk.BooleanVar(value=False)
1168
1197
  view_menu.add_checkbutton(label="File Tree", variable=self.show_sidebar_var, command=self._toggle_sidebar)
1169
1198
  view_menu.add_checkbutton(label="Chemistry Panel", variable=self.show_right_var, command=self._toggle_right_panel)
1170
1199
  view_menu.add_checkbutton(label="Bottom Panel", variable=self.show_bottom_var, command=self._toggle_bottom_panel)
1200
+ view_menu.add_checkbutton(label="Split Editor", variable=self.split_editor_var, command=self._toggle_split_editor)
1171
1201
  view_menu.add_separator()
1172
1202
  view_menu.add_command(label="Zoom In", command=lambda: self.zoom(1), accelerator="Ctrl+=")
1173
1203
  view_menu.add_command(label="Zoom Out", command=lambda: self.zoom(-1), accelerator="Ctrl+-")
@@ -1197,9 +1227,14 @@ class App(tk.Tk):
1197
1227
  self.center_pane = ttk.PanedWindow(center, orient="vertical")
1198
1228
  self.center_pane.pack(fill="both", expand=True)
1199
1229
 
1200
- self.notebook = ttk.Notebook(self.center_pane)
1201
- self.notebook.bind("<<NotebookTabChanged>>", lambda _e: self.update_status_bar())
1202
- self.center_pane.add(self.notebook, weight=4)
1230
+ self.editor_pane = ttk.PanedWindow(self.center_pane, orient="horizontal")
1231
+ self.center_pane.add(self.editor_pane, weight=4)
1232
+ self.notebook = ttk.Notebook(self.editor_pane)
1233
+ self.secondary_notebook = ttk.Notebook(self.editor_pane)
1234
+ self._active_notebook = self.notebook
1235
+ self._bind_editor_notebook(self.notebook)
1236
+ self._bind_editor_notebook(self.secondary_notebook)
1237
+ self.editor_pane.add(self.notebook, weight=1)
1203
1238
 
1204
1239
  self.bottom_notebook = ttk.Notebook(self.center_pane)
1205
1240
  self.center_pane.add(self.bottom_notebook, weight=1)
@@ -1248,29 +1283,94 @@ class App(tk.Tk):
1248
1283
 
1249
1284
  # -- tab management -----------------------------------------------------
1250
1285
 
1286
+ def _bind_editor_notebook(self, notebook: ttk.Notebook) -> None:
1287
+ notebook.bind(
1288
+ "<<NotebookTabChanged>>",
1289
+ lambda _event, pane=notebook: self.set_active_notebook(pane),
1290
+ )
1291
+ notebook.bind(
1292
+ "<Button-1>",
1293
+ lambda _event, pane=notebook: self.set_active_notebook(pane),
1294
+ add="+",
1295
+ )
1296
+
1297
+ def set_active_notebook(self, notebook: ttk.Notebook) -> None:
1298
+ self._active_notebook = notebook
1299
+ self.update_status_bar()
1300
+ self.refresh_problems_panel()
1301
+
1302
+ def _iter_tabs(self):
1303
+ for notebook in (self.notebook, self.secondary_notebook):
1304
+ for tab_id in notebook.tabs():
1305
+ yield notebook.nametowidget(tab_id)
1306
+
1251
1307
  def current_tab(self) -> Optional[EditorTab]:
1252
- tabs = self.notebook.tabs()
1253
- if not tabs:
1254
- return None
1255
- selected = self.notebook.select()
1256
- return self.notebook.nametowidget(selected) if selected else None
1257
-
1258
- def new_file(self) -> None:
1259
- tab = EditorTab(self.notebook, self, None)
1260
- self.notebook.add(tab, text=tab.display_name)
1261
- self.notebook.select(tab)
1262
-
1263
- def open_file(self, path: str) -> None:
1308
+ for notebook in (self._active_notebook, self.notebook, self.secondary_notebook):
1309
+ selected = notebook.select()
1310
+ if selected:
1311
+ return notebook.nametowidget(selected)
1312
+ return None
1313
+
1314
+ def new_file(self, in_other_pane: bool = False) -> None:
1315
+ notebook = self.secondary_notebook if in_other_pane else self._active_notebook
1316
+ if in_other_pane:
1317
+ self.split_editor_var.set(True)
1318
+ self._toggle_split_editor()
1319
+ tab = EditorTab(notebook, self, None)
1320
+ notebook.add(tab, text=tab.display_name)
1321
+ notebook.select(tab)
1322
+ self.set_active_notebook(notebook)
1323
+
1324
+ def open_file(self, path: str, in_other_pane: bool = False) -> None:
1264
1325
  path = os.path.abspath(path)
1265
- for tab_id in self.notebook.tabs():
1266
- tab = self.notebook.nametowidget(tab_id)
1267
- if tab.path and os.path.abspath(tab.path) == path:
1268
- self.notebook.select(tab)
1269
- return
1270
- tab = EditorTab(self.notebook, self, path)
1271
- self.notebook.add(tab, text=tab.display_name)
1272
- self.notebook.select(tab)
1326
+ for notebook in (self.notebook, self.secondary_notebook):
1327
+ for tab_id in notebook.tabs():
1328
+ tab = notebook.nametowidget(tab_id)
1329
+ if tab.path and os.path.abspath(tab.path) == path:
1330
+ notebook.select(tab)
1331
+ self.set_active_notebook(notebook)
1332
+ return
1333
+ notebook = self.secondary_notebook if in_other_pane else self._active_notebook
1334
+ if in_other_pane:
1335
+ self.split_editor_var.set(True)
1336
+ self._toggle_split_editor()
1337
+ tab = EditorTab(notebook, self, path)
1338
+ notebook.add(tab, text=tab.display_name)
1339
+ notebook.select(tab)
1340
+ self.set_active_notebook(notebook)
1273
1341
  self.settings.remember_file(path)
1342
+ self.refresh_recent_files()
1343
+
1344
+ def open_file_in_other_pane(self) -> None:
1345
+ path = filedialog.askopenfilename(filetypes=[("ChemQL", "*.cql"), ("All files", "*.*")])
1346
+ if path:
1347
+ self.open_file(path, in_other_pane=True)
1348
+
1349
+ def open_recent_file(self, path: str) -> None:
1350
+ if not os.path.isfile(path):
1351
+ recent_files = self.settings.data.get("recent_files", [])
1352
+ if not isinstance(recent_files, list):
1353
+ recent_files = []
1354
+ self.settings.data["recent_files"] = [item for item in recent_files if item != path]
1355
+ self.settings.save()
1356
+ self.refresh_recent_files()
1357
+ messagebox.showerror(APP_TITLE, f"Recent file no longer exists:\n{path}")
1358
+ return
1359
+ self.open_file(path)
1360
+
1361
+ def refresh_recent_files(self) -> None:
1362
+ menu = self.recent_files_menu
1363
+ menu.delete(0, "end")
1364
+ recent_files = self.settings.data.get("recent_files", [])
1365
+ if not isinstance(recent_files, list):
1366
+ recent_files = []
1367
+ valid_files = [path for path in recent_files if isinstance(path, str)]
1368
+ if not valid_files:
1369
+ menu.add_command(label="No recent files", state="disabled")
1370
+ return
1371
+ for path in valid_files[:12]:
1372
+ label = f"{Path(path).name} - {Path(path).parent}"
1373
+ menu.add_command(label=label, command=lambda item=path: self.open_recent_file(item))
1274
1374
 
1275
1375
  def open_file_dialog(self) -> None:
1276
1376
  path = filedialog.askopenfilename(filetypes=[("ChemQL", "*.cql"), ("All files", "*.*")])
@@ -1292,20 +1392,28 @@ class App(tk.Tk):
1292
1392
  tab = self.current_tab()
1293
1393
  if tab is None:
1294
1394
  return
1395
+ notebook = tab.master
1295
1396
  if tab.dirty:
1296
1397
  answer = messagebox.askyesnocancel(APP_TITLE, f"Save changes to {tab.display_name.lstrip('* ')}?")
1297
1398
  if answer is None:
1298
1399
  return
1299
1400
  if answer and not tab.save():
1300
1401
  return
1301
- self.notebook.forget(tab)
1302
- if not self.notebook.tabs():
1402
+ notebook.forget(tab)
1403
+ if notebook is self.secondary_notebook and not notebook.tabs():
1404
+ self.split_editor_var.set(False)
1405
+ self._toggle_split_editor()
1406
+ self.set_active_notebook(self.notebook)
1407
+ if not self.notebook.tabs():
1408
+ self.new_file()
1409
+ elif notebook is self.notebook and not notebook.tabs() and not self.secondary_notebook.tabs():
1303
1410
  self.new_file()
1304
1411
 
1305
1412
  def refresh_tab_titles(self) -> None:
1306
- for tab_id in self.notebook.tabs():
1307
- tab = self.notebook.nametowidget(tab_id)
1308
- self.notebook.tab(tab_id, text=tab.display_name)
1413
+ for notebook in (self.notebook, self.secondary_notebook):
1414
+ for tab_id in notebook.tabs():
1415
+ tab = notebook.nametowidget(tab_id)
1416
+ notebook.tab(tab_id, text=tab.display_name)
1309
1417
 
1310
1418
  def save_current(self) -> None:
1311
1419
  tab = self.current_tab()
@@ -1328,30 +1436,35 @@ class App(tk.Tk):
1328
1436
  tab.save(as_path=new_path)
1329
1437
 
1330
1438
  def on_close(self) -> None:
1331
- for tab_id in self.notebook.tabs():
1332
- tab = self.notebook.nametowidget(tab_id)
1333
- if tab.dirty:
1334
- self.notebook.select(tab)
1335
- answer = messagebox.askyesnocancel(APP_TITLE, f"Save changes to {tab.display_name.lstrip('* ')}?")
1336
- if answer is None:
1337
- return
1338
- if answer and not tab.save():
1339
- return
1439
+ for notebook in (self.notebook, self.secondary_notebook):
1440
+ for tab_id in notebook.tabs():
1441
+ tab = notebook.nametowidget(tab_id)
1442
+ if tab.dirty:
1443
+ notebook.select(tab)
1444
+ self.set_active_notebook(notebook)
1445
+ answer = messagebox.askyesnocancel(APP_TITLE, f"Save changes to {tab.display_name.lstrip('* ')}?")
1446
+ if answer is None:
1447
+ return
1448
+ if answer and not tab.save():
1449
+ return
1340
1450
  self.settings.save()
1341
1451
  self.destroy()
1342
1452
 
1453
+
1343
1454
  # -- theming -----------------------------------------------------------
1344
1455
 
1345
1456
  def apply_theme(self) -> None:
1346
- self.editor_font = (_pick_font_family(self.settings.data["font_family"]), self.settings.data["font_size"])
1347
- for tab_id in self.notebook.tabs():
1348
- tab = self.notebook.nametowidget(tab_id)
1457
+ self.editor_font = (
1458
+ _pick_font_family(
1459
+ self.settings.data["font_family"],
1460
+ self.settings.data.get("ligatures_enabled", True),
1461
+ ),
1462
+ self.settings.data["font_size"],
1463
+ )
1464
+ for tab in self._iter_tabs():
1349
1465
  tab._configure_tags()
1350
1466
  tab.rehighlight_all()
1351
1467
 
1352
- def active_ligatures(self) -> dict[str, str]:
1353
- return core.DEFAULT_LIGATURES if self.settings.data.get("ligatures_enabled", True) else {}
1354
-
1355
1468
  def zoom(self, delta: int, reset: bool = False) -> None:
1356
1469
  size = 13 if reset else max(8, min(32, self.settings.data["font_size"] + delta))
1357
1470
  self.settings.data["font_size"] = size
@@ -1386,6 +1499,21 @@ class App(tk.Tk):
1386
1499
  if str(self.bottom_notebook) in panes:
1387
1500
  self.center_pane.forget(self.bottom_notebook)
1388
1501
 
1502
+ def _toggle_split_editor(self) -> None:
1503
+ panes = self.editor_pane.panes()
1504
+ if self.split_editor_var.get():
1505
+ if str(self.secondary_notebook) not in panes:
1506
+ self.editor_pane.add(self.secondary_notebook, weight=1)
1507
+ elif self.secondary_notebook.tabs():
1508
+ self.split_editor_var.set(True)
1509
+ messagebox.showinfo(
1510
+ APP_TITLE,
1511
+ "Close the tabs in the other pane before turning split view off.",
1512
+ )
1513
+ elif str(self.secondary_notebook) in panes:
1514
+ self.editor_pane.forget(self.secondary_notebook)
1515
+ self.set_active_notebook(self.notebook)
1516
+
1389
1517
  # -- status bar / problems ----------------------------------------------
1390
1518
 
1391
1519
  def update_status_bar(self) -> None:
@@ -1531,7 +1659,7 @@ def main() -> None:
1531
1659
  import ctypes
1532
1660
  ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('chemql.codecqlx.1.0.0')
1533
1661
  if len(sys.argv) > 1 and sys.argv[1] in ("--version", "-v"):
1534
- print("CodecQLX 1.0.0")
1662
+ print("CodecQLX 1.1.1")
1535
1663
  else:
1536
1664
  app = App(sys.argv[1:])
1537
1665
  app.mainloop()
@@ -1,3 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: chemql-python
3
+ Version: 1.6.11
4
+ Summary: A chemistry-focused query language and REPL
5
+ Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: prompt_toolkit>=3.0
10
+ Requires-Dist: rich>=13.7
11
+ Provides-Extra: test
12
+ Requires-Dist: pytest>=8.0; extra == "test"
13
+ Dynamic: license-file
14
+
1
15
  # ChemQL & CodecQL
2
16
 
3
17
  > A Python-embedded query language and terminal toolchain for chemistry data — with a purpose-built editor, package manager, and standard library.
@@ -6,9 +20,9 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
6
20
 
7
21
  - **Distribution name:** `chemql-python`
8
22
  - **Import / CLI name:** `chemql`
9
- - **Language version:** `1.6.9` (per `chemql.__version__`)
10
- - **Editor version:** `codecql 0.1.1`
11
- - **GUI Editor version:** `CodecQLX 1.0.0`
23
+ - **Language version:** `1.6.11` (per `chemql.__version__`)
24
+ - **Editor version:** `codecql 0.1.2`
25
+ - **GUI Editor version:** `CodecQLX 1.1.1`
12
26
  - **Python import / CLI name:** `chemql`
13
27
  - **Author:** Mohammad Rakibul Islam
14
28
  - **Minimum Python:** **3.12+** (verified with `vermin`)
@@ -30,6 +44,15 @@ Verify:
30
44
  chemql --version
31
45
  ```
32
46
 
47
+ If the `chemql` command is unavailable or fails to start, use
48
+ `python -m chemql` with the same arguments instead:
49
+
50
+ ```bash
51
+ python -m chemql --version
52
+ python -m chemql -c 'search elements symbol = "Fe" return name symbol number'
53
+ python -m chemql -f script.cql
54
+ ```
55
+
33
56
  Python **3.12+** is required. The project's minimum version is checked with [`vermin`](https://github.com/netromdk/vermin).
34
57
 
35
58
  ---
@@ -453,7 +476,7 @@ ls
453
476
 
454
477
  | | |
455
478
  |---|---|
456
- | Version | 0.1.1 |
479
+ | Version | 0.1.2 |
457
480
  | Ships with | `chemql-python` |
458
481
  | Files | `.cql` (ChemQL), `.py`, `cqlpackage.json` / `cqlpackage.toml`, and any plain-text file |
459
482
 
@@ -467,7 +490,9 @@ chemql edit --local-highlighting # edit ./highlighting.json (created as {}
467
490
  chemql edit --version
468
491
  ```
469
492
 
470
- If your installation also registers a `codecql` console script, `codecql FILE` accepts the same options.
493
+ If the `codecql` command is unavailable or fails to start, run
494
+ `python -m chemql.codecql FILE` instead. It accepts the same options as
495
+ `chemql edit`, including the highlighting configuration options.
471
496
 
472
497
  Opening a path that does not exist starts an empty buffer; it is created on the first save.
473
498
 
@@ -491,12 +516,16 @@ Opening a path that does not exist starts an empty buffer; it is created on the
491
516
  | `Ctrl` + `↑` `↓` | Scroll the view without moving the text |
492
517
  | `Backspace`, `Delete` | Delete a character, or the selection |
493
518
  | `Ctrl+Backspace` / `Alt+Backspace` | Delete the word to the left |
519
+ | `Command+Backspace` (macOS, when sent as CSI-u) | Delete to the start of the line |
494
520
  | `Ctrl+Delete` / `Alt+Delete` | Delete the word to the right |
495
521
  | `Ctrl+C` / `Ctrl+Insert` | Copy the selection (editor + system clipboard when available). It does **not** quit |
496
522
  | `Ctrl+X` | Cut the selection |
497
523
  | `Ctrl+V` / `Shift+Insert` | Paste the editor's clipboard |
498
524
 
499
- Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so multi-line pastes arrive as a single insertion.
525
+ Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so
526
+ multi-line pastes arrive as a single insertion. The terminal must forward macOS Command-key
527
+ combinations using the CSI-u keyboard protocol; otherwise it may consume or remap them before
528
+ CodecQL receives them.
500
529
 
501
530
  **Auto-indent.** After a line that opens a block (`func`, `define NAME{}`, `struct`, `record`, `enum`, `namespace`, `if`, `elif`, `else`, `for`, `while`) or ends in a `\` continuation, the next line is indented with a tab. Pressing Enter after `endnamespace` removes one level of indentation. Other `end...` keywords do not dedent automatically.
502
531
 
@@ -804,7 +833,6 @@ Each entry needs an `ansi256` number from 0 to 255, and an optional `channel` of
804
833
  - Auto-dedent applies only after `endnamespace`.
805
834
  - One file per session: there are no tabs or split editors.
806
835
  - Tabs are drawn four columns wide.
807
- - CodecQL's Windows Backspace / Ctrl+Backspace are intentionally inverted relative to POSIX.
808
836
 
809
837
  ## CodecQLX — the desktop editor
810
838
 
@@ -820,6 +848,14 @@ python -m chemql.codecqlx FILE_OR_FOLDER ...
820
848
  codecqlx --version
821
849
  ```
822
850
 
851
+ If the `codecqlx` command is unavailable or fails to start, use
852
+ `python -m chemql.codecqlx` with the same arguments:
853
+
854
+ ```bash
855
+ python -m chemql.codecqlx FILE_OR_FOLDER ...
856
+ python -m chemql.codecqlx --version
857
+ ```
858
+
823
859
  Paths are optional. A new empty file is opened when no path is supplied;
824
860
  files and folders passed on the command line are opened in the editor. The
825
861
  `codecqlx` command is installed with `chemql-python`.
@@ -833,7 +869,8 @@ the `chemql` package cannot be imported.
833
869
 
834
870
  - Syntax highlighting and context-aware autocomplete for `.cql` files
835
871
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
836
- - File tree sidebar with multiple editor tabs
872
+ - File tree sidebar, recent files, and multiple editor tabs
873
+ - Side-by-side editor panes for working with different files
837
874
  - Query Console that executes ChemQL in-process and displays table or card results
838
875
  - Interactive Periodic Table lookup
839
876
  - Balance Equation panel
@@ -841,7 +878,16 @@ the `chemql` package cannot be imported.
841
878
  - Dark and light themes, font settings, autocomplete/minimap toggles, and
842
879
  per-token color preferences
843
880
 
881
+ When enabled, CodecQLX prefers an installed programming font with ligature
882
+ support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
883
+ monospace font. Install a ligature font on your system; the native Tk text
884
+ renderer and font must support shaping for ligature glyphs to appear. A custom
885
+ font family selected in **Preferences > General** is kept as-is.
886
+
844
887
  Use **View** to toggle the file tree, Chemistry panel, and bottom panels.
888
+ Enable **View > Split Editor**, then choose **File > Open File in Other Pane**
889
+ to work with a second file side by side. Close all tabs in the second pane
890
+ before turning split view off.
845
891
  CodecQLX stores its preferences in `.codecql_gui/settings.json` under the
846
892
  user profile (`%APPDATA%` on Windows).
847
893
 
@@ -926,4 +972,4 @@ Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017
926
972
 
927
973
  For the command reference that matches your installed build, type `help`
928
974
  inside ChemQL. Use `list all` to inspect fields available in your
929
- bundled datasets.
975
+ bundled datasets.
@@ -10,6 +10,7 @@ src/chemql/codecqlx.py
10
10
  src/chemql/colors.json
11
11
  src/chemql/highlighting.json
12
12
  src/chemql/highlighting.py
13
+ src/chemql/logo64-macos.png
13
14
  src/chemql/logo64.png
14
15
  src/chemql/data/BondEnergies.json
15
16
  src/chemql/data/MoleculeBonds.json
@@ -37,6 +38,8 @@ src/chemql_python.egg-info/entry_points.txt
37
38
  src/chemql_python.egg-info/requires.txt
38
39
  src/chemql_python.egg-info/top_level.txt
39
40
  tests/test_codecql.py
41
+ tests/test_codecqlx_fonts.py
42
+ tests/test_codecqlx_icon.py
40
43
  tests/test_external_molecule_lookup.py
41
44
  tests/test_public_api.py
42
45
  tests/test_reactions.py
@@ -103,11 +103,31 @@ def test_ctrl_scroll_clamps_at_document_ends(monkeypatch):
103
103
  assert editor.cursor_y == 25
104
104
 
105
105
 
106
- def test_ctrl_backspace_and_delete_remove_words():
106
+ def test_backspace_variants_have_distinct_delete_behavior():
107
107
  editor = codecql.Editor(None)
108
108
  editor.lines = ["one two"]
109
- editor.cursor_x = 0
109
+ editor.cursor_x = len(editor.lines[0])
110
+
111
+ editor.handle_key("backspace")
112
+ assert editor.lines == ["one tw"]
113
+
114
+ editor.lines = ["one two"]
115
+ editor.cursor_x = len(editor.lines[0])
116
+ editor.handle_key("ctrl+backspace")
117
+ assert editor.lines == ["one "]
118
+
119
+ editor.lines = ["one two"]
120
+ editor.cursor_x = len(editor.lines[0])
121
+ editor.handle_key("alt+backspace")
122
+ assert editor.lines == ["one "]
110
123
 
124
+ editor.lines = ["one two"]
125
+ editor.cursor_x = 4
126
+ editor.handle_key("super+backspace")
127
+ assert editor.lines == ["two"]
128
+
129
+ editor.lines = ["one two"]
130
+ editor.cursor_x = 0
111
131
  editor.handle_key("ctrl+delete")
112
132
 
113
133
  assert editor.lines == ["two"]
@@ -117,16 +137,19 @@ def test_ctrl_backspace_and_delete_remove_words():
117
137
 
118
138
  assert editor.lines == ["two"]
119
139
 
120
- editor.cursor_x = len(editor.lines[0])
121
- editor.handle_key("\x08")
122
-
123
- assert editor.lines == [""]
124
-
125
140
 
126
141
  def test_ctrl_delete_terminal_sequences_are_decoded():
127
142
  assert codecql._decode_escape_sequence(b"[3;5~") == "ctrl+delete"
128
143
  assert codecql._decode_escape_sequence(b"[27;5;127~") == "ctrl+backspace"
129
144
  assert codecql._decode_escape_sequence(b"[127;5u") == "ctrl+backspace"
145
+ assert codecql._decode_escape_sequence(b"[127;9u") == "super+backspace"
146
+
147
+
148
+ def test_backspace_byte_uses_terminal_erase_setting():
149
+ assert codecql._decode_backspace_byte(b"\x08", b"\x08") == "backspace"
150
+ assert codecql._decode_backspace_byte(b"\x7f", b"\x08") == "ctrl+backspace"
151
+ assert codecql._decode_backspace_byte(b"\x08", b"\x7f") == "ctrl+backspace"
152
+ assert codecql._decode_backspace_byte(b"\x7f", b"\x7f") == "backspace"
130
153
 
131
154
 
132
155
  def test_search_query_flags_select_regex_case_and_whole_word():
@@ -0,0 +1,27 @@
1
+ from tkinter import font
2
+
3
+ from chemql import codecqlx
4
+
5
+
6
+ def test_default_font_prefers_ligature_font_when_enabled(monkeypatch):
7
+ monkeypatch.setattr(font, "families", lambda: ("Menlo", "Fira Code"))
8
+
9
+ assert codecqlx._pick_font_family("Menlo", ligatures_enabled=True) == "Fira Code"
10
+
11
+
12
+ def test_default_font_is_kept_when_ligatures_are_disabled(monkeypatch):
13
+ monkeypatch.setattr(font, "families", lambda: ("Menlo", "Fira Code"))
14
+
15
+ assert codecqlx._pick_font_family("Menlo", ligatures_enabled=False) == "Menlo"
16
+
17
+
18
+ def test_custom_font_preference_is_not_overridden(monkeypatch):
19
+ monkeypatch.setattr(font, "families", lambda: ("Custom Mono", "Fira Code"))
20
+
21
+ assert codecqlx._pick_font_family("Custom Mono", ligatures_enabled=True) == "Custom Mono"
22
+
23
+
24
+ def test_missing_ligature_font_falls_back_to_default(monkeypatch):
25
+ monkeypatch.setattr(font, "families", lambda: ("Menlo", "Courier New"))
26
+
27
+ assert codecqlx._pick_font_family("Menlo", ligatures_enabled=True) == "Menlo"
@@ -0,0 +1,15 @@
1
+ from chemql import codecqlx
2
+
3
+
4
+ def test_macos_icon_uses_opaque_png():
5
+ icon = codecqlx._app_icon_path("darwin")
6
+ png = icon.read_bytes()
7
+
8
+ assert icon.name == "logo64-macos.png"
9
+ assert png[:8] == b"\x89PNG\r\n\x1a\n"
10
+ assert png[25] == 2
11
+
12
+
13
+ def test_other_platforms_keep_original_icon():
14
+ assert codecqlx._app_icon_path("linux").name == "logo64.png"
15
+ assert codecqlx._app_icon_path("win32").name == "logo64.png"
@@ -19,6 +19,12 @@ def test_adjacent_function_calls_compose_as_an_expression():
19
19
  assert chemql.process_inline("int{1}+int{1}") == 2
20
20
 
21
21
 
22
+ def test_python_call_can_print_a_string_containing_an_opening_bracket(capsys):
23
+ chemql.process_inline('print("[")')
24
+
25
+ assert capsys.readouterr().out == "[\n"
26
+
27
+
22
28
  def test_function_positional_parameters_interpolate_in_strings(monkeypatch):
23
29
  monkeypatch.delitem(chemql.FUNCTIONS, "greet", raising=False)
24
30
  monkeypatch.delitem(chemql.python_globals, "greet", raising=False)
File without changes
File without changes