Skip to content

Commit a721949

Browse files
committed
20251119195047
1 parent 466e51f commit a721949

File tree

1 file changed

+116
-95
lines changed

1 file changed

+116
-95
lines changed

README.md

Lines changed: 116 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,46 @@
77
<img width="407" alt="{2793AAE1-85B1-4A0C-9D16-D1161511C907}" src="https://github.com/user-attachments/assets/7798a69e-956c-4fdd-9f79-72f56b82332a" />
88

99
## Table of Contents
10+
1011
- [Flexible Text Copy Adapter (FTCA)](#flexible-text-copy-adapter-ftca)
1112
- [Table of Contents](#table-of-contents)
12-
- [What is it?](#what-is-it)
13-
- [Who is it for?](#who-is-it-for)
14-
- [What problem does this program solve?](#what-problem-does-this-program-solve)
15-
- [How does it work?](#how-does-it-work)
16-
- [How to get started?](#how-to-get-started)
17-
- [URL Parameters](#url-parameters)
18-
- [How to use in GoldenDict (Single-line text)?](#how-to-use-in-goldendict-single-line-text)
13+
- [Overview](#overview)
14+
- [What is it?](#what-is-it)
15+
- [Who is it for?](#who-is-it-for)
16+
- [What problem does this program solve?](#what-problem-does-this-program-solve)
17+
- [How does it work?](#how-does-it-work)
18+
- [What are the advantages?](#what-are-the-advantages)
19+
- [What inspired it?](#what-inspired-it)
20+
- [Getting Started](#getting-started)
21+
- [What are the system environment prerequisites?](#what-are-the-system-environment-prerequisites)
22+
- [How to get started?](#how-to-get-started)
23+
- [How to check functionality?](#how-to-check-functionality)
24+
- [Configuration \& Usage](#configuration--usage)
25+
- [URL Parameters](#url-parameters)
26+
- [How to configure in the Lute v3 web interface?](#how-to-configure-in-the-lute-v3-web-interface)
27+
- [How to use in GoldenDict (Single-line text)?](#how-to-use-in-goldendict-single-line-text)
1928
- [Setup:](#setup)
20-
- [How to use with multi-line text in GoldenDict?](#how-to-use-with-multi-line-text-in-goldendict)
29+
- [How to use with multi-line text in GoldenDict?](#how-to-use-with-multi-line-text-in-goldendict)
2130
- [Setup:](#setup-1)
22-
- [What are the advantages?](#what-are-the-advantages)
23-
- [What inspired it?](#what-inspired-it)
24-
- [How to use Dark Mode or Dark Theme?](#how-to-use-dark-mode-or-dark-theme)
25-
- [What are the technical features?](#what-are-the-technical-features)
26-
- [What are the system environment prerequisites?](#what-are-the-system-environment-prerequisites)
27-
- [In what environment was it tested?](#in-what-environment-was-it-tested)
28-
- [How to configure in the Lute v3 web interface?](#how-to-configure-in-the-lute-v3-web-interface)
29-
- [How to allow Clipboard Read Access (Chrome)?](#how-to-allow-clipboard-read-access-chrome)
30-
- [How to check functionality?](#how-to-check-functionality)
31-
- [What about the security of my buffer data?](#what-about-the-security-of-my-buffer-data)
32-
- [Why doesn't it work?](#why-doesnt-it-work)
33-
- [Kardenwort Ecosystem](#kardenwort-ecosystem)
34-
- [License](#license)
35-
- [Author's Disclaimer](#authors-disclaimer)
36-
- [Stars](#stars)
37-
38-
## What is it?
31+
- [How to allow Clipboard Read Access (Chrome)?](#how-to-allow-clipboard-read-access-chrome)
32+
- [How to use Dark Mode or Dark Theme?](#how-to-use-dark-mode-or-dark-theme)
33+
- [Technical Details](#technical-details)
34+
- [What are the technical features?](#what-are-the-technical-features)
35+
- [In what environment was it tested?](#in-what-environment-was-it-tested)
36+
- [What about the security of my buffer data?](#what-about-the-security-of-my-buffer-data)
37+
- [Troubleshooting](#troubleshooting)
38+
- [Why doesn't it work?](#why-doesnt-it-work)
39+
- [Legal \& Misc](#legal--misc)
40+
- [Kardenwort Ecosystem](#kardenwort-ecosystem)
41+
- [License](#license)
42+
- [Author's Disclaimer](#authors-disclaimer)
43+
- [Stars](#stars)
44+
45+
---
46+
47+
## Overview
48+
49+
### What is it?
3950
This is a small utility that serves as an adapter, allowing to establish communication between a class of programs for assistance in reading in a foreign language and a local dictionary or translator, through the system clipboard.
4051

4152
In my case, it helps to easily connect local programs Lute (LWT) and GoldenDict for the ability to work locally, without an internet connection and automatically translate and view selected words from the Lute reading program in the GoldenDict-ng dictionary program.
@@ -48,7 +59,7 @@ In my case, it helps to easily connect local programs Lute (LWT) and GoldenDict
4859

4960
[Back to Top](#table-of-contents)
5061

51-
## Who is it for?
62+
### Who is it for?
5263
In general:
5364
- Studying languages and mastering convenient tools for working with large texts.
5465

@@ -58,19 +69,42 @@ In technical terms:
5869

5970
[Back to Top](#table-of-contents)
6071

61-
## What problem does this program solve?
72+
### What problem does this program solve?
6273
A utility for solving the problem of translating individual words in [Lute v3](https://github.com/LuteOrg/lute-v3).
6374

6475
[Issue #593 — Revision of the logic of copying a word and substring of text from the main panel](https://github.com/LuteOrg/lute-v3/issues/593)
6576

6677
[Back to Top](#table-of-contents)
6778

68-
## How does it work?
79+
### How does it work?
6980
https://github.com/user-attachments/assets/4ae740ae-c729-4405-b80a-7b225c7641b1
7081

7182
[Back to Top](#table-of-contents)
7283

73-
## How to get started?
84+
### What are the advantages?
85+
- **Versatility**. Can be integrated into [Lute](https://github.com/LuteOrg/lute-v3) and similar programs where interaction with dictionaries is done through HTTP requests.
86+
- **Offline operation**. Allows for an offline workflow between reading software and a local dictionary like GoldenDict-ng.
87+
- **Multi-line text preservation**. Reliably handles text with line breaks from applications like GoldenDict, which is not possible with direct command-line calls.
88+
- **Minimalism**. Minimal software dependencies.
89+
- **Cross-platform compatibility**. Works wherever a Python interpreter and a browser can run.
90+
- **Easy integration**. Can be easily included in an existing set of tools.
91+
92+
[Back to Top](#table-of-contents)
93+
94+
### What inspired it?
95+
I accidentally discovered that when making a request like `https://m.dict.cc/deutsch-russisch/test.html`, the input field on the page loads with the search term already selected (as if by Ctrl+A). This JavaScript-powered feature allows for immediate copying to the clipboard, which inspired the core functionality of FTCA.
96+
97+
[Back to Top](#table-of-contents)
98+
99+
## Getting Started
100+
101+
### What are the system environment prerequisites?
102+
- Python 3.x.
103+
- Chrome or a browser that supports the Modern Clipboard API.
104+
105+
[Back to Top](#table-of-contents)
106+
107+
### How to get started?
74108
- Download. You can perform a clone or visit the Releases page. The project consists of three main files: `ftca.py` (the server), `index.html` (the web page), and `launcher.py` (a helper script for multi-line support in GoldenDict).
75109

76110
- Check that the Python interpreter is installed on your system.
@@ -88,7 +122,27 @@ See the "URL Parameters" and "How to check functionality?" sections below for ex
88122

89123
[Back to Top](#table-of-contents)
90124

91-
## URL Parameters
125+
### How to check functionality?
126+
Run the `ftca.py` server.
127+
128+
Open one of the links below in your browser.
129+
130+
- **Option 1 (Simple text, default size)**
131+
http://127.0.0.1:5010/?s=test%20test
132+
133+
- **Option 2 (With clipboard copy)**
134+
http://127.0.0.1:5010/?clipboard=true&s=test
135+
136+
- **Option 3 (With custom height)**
137+
http://127.0.0.1:5010/?s=This%20is%20a%20test%20in%20a%20taller%20box&rows=10
138+
139+
The page should load with your text in the input field, fully selected. If `clipboard=true` is used and permission is granted, the text will also be automatically copied to your clipboard. For multi-line tests, use the GoldenDict setup described above.
140+
141+
[Back to Top](#table-of-contents)
142+
143+
## Configuration & Usage
144+
145+
### URL Parameters
92146
The utility's behavior is controlled by parameters in the URL:
93147

94148
- **`s`**: The text content to display in the text area. The text should be standard URL-encoded.
@@ -107,7 +161,19 @@ The utility's behavior is controlled by parameters in the URL:
107161

108162
[Back to Top](#table-of-contents)
109163

110-
## How to use in GoldenDict (Single-line text)?
164+
### How to configure in the Lute v3 web interface?
165+
Settings — Languages — [Your Language] — Edit
166+
Dictionaries — Add dictionary
167+
- **Type**: Terms
168+
- **Open in**: Pop-up window
169+
- **URI**: `http://127.0.0.1:5010/?clipboard=true&rows=8&s=[LUTE]`
170+
- **Is active?**: `true`
171+
172+
*(Note: You can adjust the `rows=8` value to your preferred initial height.)*
173+
174+
[Back to Top](#table-of-contents)
175+
176+
### How to use in GoldenDict (Single-line text)?
111177
This utility can be used not only with Lute but also within GoldenDict as a "Program" dictionary. This allows you to send the current search term to a new browser tab for easier editing or further processing.
112178

113179
This is ideal for single words or short phrases without line breaks.
@@ -127,7 +193,7 @@ Command Line: "C:\Program Files\Google\Chrome\Application\chrome.exe" http://127
127193

128194
[Back to Top](#table-of-contents)
129195

130-
## How to use with multi-line text in GoldenDict?
196+
### How to use with multi-line text in GoldenDict?
131197
When passing long text with line breaks from GoldenDict, the standard command-line method will fail and merge everything into a single line.
132198

133199
To preserve line breaks, we must use the included `launcher.py` helper script. It safely encodes the text using Base64 before launching the browser. Additionally, it automatically sets the text area height to **20 rows** (`rows=20`) for better viewing of multi-line content.
@@ -154,40 +220,28 @@ cmd /c "C:\Users\User\AppData\Local\Programs\Python\Python312\python.exe" "D:\My
154220

155221
[Back to Top](#table-of-contents)
156222

157-
## What are the advantages?
158-
- **Versatility**. Can be integrated into [Lute](https://github.com/LuteOrg/lute-v3) and similar programs where interaction with dictionaries is done through HTTP requests.
159-
- **Offline operation**. Allows for an offline workflow between reading software and a local dictionary like GoldenDict-ng.
160-
- **Multi-line text preservation**. Reliably handles text with line breaks from applications like GoldenDict, which is not possible with direct command-line calls.
161-
- **Minimalism**. Minimal software dependencies.
162-
- **Cross-platform compatibility**. Works wherever a Python interpreter and a browser can run.
163-
- **Easy integration**. Can be easily included in an existing set of tools.
164-
165-
[Back to Top](#table-of-contents)
223+
### How to allow Clipboard Read Access (Chrome)?
224+
The script uses the Modern Clipboard API, which requires you to grant the page permission to interact with the clipboard.
166225

167-
## What inspired it?
168-
I accidentally discovered that when making a request like `https://m.dict.cc/deutsch-russisch/test.html`, the input field on the page loads with the search term already selected (as if by Ctrl+A). This JavaScript-powered feature allows for immediate copying to the clipboard, which inspired the core functionality of FTCA.
226+
<img width="407" alt="{2793AAE1-85B1-4A0C-9D16-D1161511C907}" src="https://github.com/user-attachments/assets/8b0186e3-1476-46c3-afa5-f80ebb59581a" />
169227

170228
[Back to Top](#table-of-contents)
171229

172-
## How to use Dark Mode or Dark Theme?
230+
### How to use Dark Mode or Dark Theme?
173231
If you use a browser extension like [Dark Reader](https://github.com/darkreader/darkreader), you can enable it for the FTCA page. Simply open a link like `http://127.0.0.1:5010/?s=test` and activate the plugin for this site.
174232

175233
<img width="960" alt="image" src="https://github.com/user-attachments/assets/c4aabcf3-aead-41b9-bfa4-5582591a4a48" />
176234

177235
[Back to Top](#table-of-contents)
178236

179-
## What are the technical features?
180-
The utility runs a lightweight, dependency-free HTTP server using Python's standard library. It serves a single HTML/JS page that acts as the adapter. For multi-line text, a helper script uses Base64 encoding to ensure data integrity during transmission via the command line.
181-
182-
[Back to Top](#table-of-contents)
237+
## Technical Details
183238

184-
## What are the system environment prerequisites?
185-
- Python 3.x.
186-
- Chrome or a browser that supports the Modern Clipboard API.
239+
### What are the technical features?
240+
The utility runs a lightweight, dependency-free HTTP server using Python's standard library. It serves a single HTML/JS page that acts as the adapter. For multi-line text, a helper script uses Base64 encoding to ensure data integrity during transmission via the command line.
187241

188242
[Back to Top](#table-of-contents)
189243

190-
## In what environment was it tested?
244+
### In what environment was it tested?
191245
- Windows 11.
192246
- Python 3.12.7.
193247
- Chrome Version 122.0.6261.95 (Official Build) (64-bit).
@@ -196,70 +250,37 @@ The utility runs a lightweight, dependency-free HTTP server using Python's stand
196250

197251
[Back to Top](#table-of-contents)
198252

199-
## How to configure in the Lute v3 web interface?
200-
Settings — Languages — [Your Language] — Edit
201-
Dictionaries — Add dictionary
202-
- **Type**: Terms
203-
- **Open in**: Pop-up window
204-
- **URI**: `http://127.0.0.1:5010/?clipboard=true&rows=8&s=[LUTE]`
205-
- **Is active?**: `true`
206-
207-
*(Note: You can adjust the `rows=8` value to your preferred initial height.)*
208-
209-
[Back to Top](#table-of-contents)
210-
211-
## How to allow Clipboard Read Access (Chrome)?
212-
The script uses the Modern Clipboard API, which requires you to grant the page permission to interact with the clipboard.
213-
214-
<img width="407" alt="{2793AAE1-85B1-4A0C-9D16-D1161511C907}" src="https://github.com/user-attachments/assets/8b0186e3-1476-46c3-afa5-f80ebb59581a" />
215-
216-
[Back to Top](#table-of-contents)
217-
218-
## How to check functionality?
219-
Run the `ftca.py` server.
220-
221-
Open one of the links below in your browser.
222-
223-
- **Option 1 (Simple text, default size)**
224-
http://127.0.0.1:5010/?s=test%20test
225-
226-
- **Option 2 (With clipboard copy)**
227-
http://127.0.0.1:5010/?clipboard=true&s=test
228-
229-
- **Option 3 (With custom height)**
230-
http://127.0.0.1:5010/?s=This%20is%20a%20test%20in%20a%20taller%20box&rows=10
231-
232-
The page should load with your text in the input field, fully selected. If `clipboard=true` is used and permission is granted, the text will also be automatically copied to your clipboard. For multi-line tests, use the GoldenDict setup described above.
233-
234-
[Back to Top](#table-of-contents)
235-
236-
## What about the security of my buffer data?
253+
### What about the security of my buffer data?
237254
This utility does not transmit your data to the internet. It operates locally on your PC, transmitting data between applications via the loopback network interface (`127.0.0.1`). While it doesn't store data on disk, it is processed in RAM. Assess your own risks when working with sensitive information. It is strongly recommended not to expose this server to any address other than the loopback address.
238255

239256
[Back to Top](#table-of-contents)
240257

241-
## Why doesn't it work?
258+
## Troubleshooting
259+
260+
### Why doesn't it work?
242261
- Ensure no other application is using port `5010`.
243262
- Make sure you have only one instance of the `ftca.py` script running. Check your system's process manager for `python` processes related to `ftca`.
244263
- If using the multi-line method, double-check that the paths to `python.exe` and `launcher.py` in your GoldenDict command are correct and enclosed in double quotes.
245264

246265
[Back to Top](#table-of-contents)
247266

248-
## Kardenwort Ecosystem
267+
## Legal & Misc
268+
269+
### Kardenwort Ecosystem
249270

250271
This project is part of the **[Kardenwort](https://github.com/kardenwort)** environment, designed to create a focused and efficient learning ecosystem.
251272

252273
[Back to Top](#table-of-contents)
253274

254-
## License
275+
### License
255276
MIT License.
256277

257278
[Back to Top](#table-of-contents)
258279

259-
## Author's Disclaimer
280+
### Author's Disclaimer
260281
The software is provided "as is" without any warranties. The author is not responsible for any damages or issues arising from the use of this software. Users are advised to use it at their own risk.
261282

262283
[Back to Top](#table-of-contents)
263284

264-
## Stars
285+
### Stars
265286
If you find this utility helpful, please consider starring the repository to support the developer's efforts.

0 commit comments

Comments
 (0)