工欲善其事,必先利其器:準備更新哈哈倉頡

分享和討論倉頡輸入法相關的資訊和内容
版面规则
公正客觀講理,杜絶廢話連篇
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

現在按這個rime配置,我實現了用;'選二三重,但是我如果同時也想用數字鍵2和3選重,要如何改?

代码: 全选

在 Rime (鼠鬚管/小狼毫) 配置中,`alternative_select_keys` 只能為每個候選位置指定單一按鍵。如果您希望**同時**支援 `;`、`'` 和數字鍵 `2`、`3` 來選取第二、三重,最標準且穩定的做法是利用 **`key_binder`(按鍵綁定)** 功能。

請按照以下三個步驟修改您的 `haha.schema.yaml` 檔案:

### 1. 在 `engine/processors` 中啟用 `key_binder`

原本的配置中缺少了按鍵編譯器,需要將 `- key_binder` 加進去(建議放在靠前的位置,以便優先攔截按鍵):

```yaml
engine:
  processors:
    - ascii_composer
    - key_binder        # 新增這一行
    - speller
    - selector
    - punctuator
    - express_editor

```

---

### 2. 修改 `menu` 區塊

將原本的 `alternative_select_keys` 改回標準的數字選鍵 `select_keys`。這樣一來,選單預設就會支援 `2` 和 `3` 鍵,且候選字標籤會顯示為數字:

```yaml
menu:
  page_size: 9
  select_keys: "123456789"  # 改為標準數字選鍵

```

---

### 3. 在檔案末尾添加 `key_binder` 設定

新增以下區塊。這段程式碼的意思是:當畫面上**有候選字選單時(`when: has_menu`)**,按下分號 `;` 會自動映射為數字 `2`,按下單引號 `'` 會自動映射為數字 `3`;而當沒有候選選單時,它們依然會維持原本的標點符號功能。

```yaml
key_binder:
  bindings:
    - { accept: semicolon, send: 2, when: has_menu }
    - { accept: apostrophe, send: 3, when: has_menu }

```

---

> **提示:** 修改完成並儲存檔案後,切換到該輸入法並點擊 Rime 的 **「重新部署」(Deploy)**,新設定就會立即生效。此時不論您按 `;`、`'` 還是數字鍵 `2`、`3`,都能順利選取對應的候選字。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

代码: 全选

在.lime格式的導出中,文件頭更改為:

@format@|lime-text-v2
@version@|日期加時間
@cname@|哈哈倉頡
@selkey@|123456789
@endkey@|abcdefghijklmnopqrstuvwxyz
@spacestyle@|0
%chardef begin
code|word|score|basescore
aa|測|0|123
ab|試|0|456
%chardef end


碼表內容寫在
%chardef begin
至
%chardef end
之中,其中第四欄使用之前的倒序數字。

如遇以下符號則轉碼:

\\ = literal backslash
\| = literal pipe when `|` is the delimiter
\@ = literal at-sign
\% = literal percent

只需給出要修改的地方,不需要注釋,不要有空行。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

gemini thinking:

代码: 全选

const limeFilename = `lime_${fileVersion}.txt`;
const d = new Date();
const dateTimeStr = d.getFullYear() + String(d.getMonth() + 1).padStart(2, '0') + String(d.getDate()).padStart(2, '0') + String(d.getHours()).padStart(2, '0') + String(d.getMinutes()).padStart(2, '0') + String(d.getSeconds()).padStart(2, '0');
const escapeLime = (str) => str.replace(/\\/g, '\\\\').replace(/\|/g, '\\|').replace(/@/g, '\\@').replace(/%/g, '\\%');
const limeHeader = `@format@|lime-text-v2\n@version@|${dateTimeStr}\n@cname@|哈哈倉頡\n@selkey@|123456789\n@endkey@|abcdefghijklmnopqrstuvwxyz\n@spacestyle@|0\n%chardef begin\ncode|word|score|basescore`;
const limeBody = tableLines.map((line, index) => {
const [code, char] = line.split('\t');
return `${escapeLime(code)}|${escapeLime(char)}|0|${totalLines - index}`;
}).join('\n');
const limeContent = `${limeHeader}\n${limeBody}\n%chardef end`;
createDownloadLink(limeFilename, limeContent);
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

haha_20260523_162540.lime2

試試看這個行不行。
附件
haha_20260523_162540.lime2.7z
(161.71 KiB) 已下载 8 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

domchar5751.html

在results-three-col內的三個textarea-header的最右邊處加上一個「轉textarea的svg按鈕」,當點擊時,其下方的result-scroll-list將隱藏,並在原位出現一個寬高相同的textarea,內容就是這個result-list。

需要給出所有要修改的地方和所要替換的代碼,不需給出全部代碼。
附件
domchar5751.html.7z
(14.5 KiB) 已下载 3 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

Close應該改為Finish,當執行Finish後,Reset Edit Changes應只能退回到最後一次Finish的狀態。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5764
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 207 次
联系:

Re: 工欲善其事,必先利其器:準備更新哈哈倉頡

帖子 ejsoon »

gemini pro:

代码: 全选

這是一個非常實用且能提升工作效率的改進。我已經為你準備好對應的修改代碼。我們將分幾個部分進行替換,無需更動全部代碼,只需按照下方的指示覆蓋指定的區塊即可。

以下是需要修改的 5 個地方:

### 1. 修改 HTML:重構三欄顯示區與按鈕名稱

在 HTML 的 `<div class="results-three-col">` 區塊,我們加入 SVG 按鈕和對應的 Textarea。同時將 `btnCloseEdit` 按鈕名稱從 Close 改為 Finish。

**找到以下代碼:**

```html
          <div class="results-three-col">
            <div class="result-col">
              <div class="textarea-header">Duplication Results (<span id="dupResultCount">0</span>)</div>
              <ul id="collapseMultipleText" class="result-scroll-list"></ul>
            </div>
            <div class="result-col">
              <div class="textarea-header">Deduplication Results (<span id="dedupResultCount">0</span>)</div>
              <ul id="gzhahaText" class="result-scroll-list"></ul>
            </div>
            <div class="result-col">
              <div class="textarea-header">Out of Bounds (<span id="outOfBoundsCount">0</span>)</div>
              <ul id="outOfBoundsText" class="result-scroll-list"></ul>
            </div>
          </div>

```

和

```html
            <button id="btnCloseEdit" class="edit-action-btn" onclick="handleEditCloseOnly()">Close</button>

```

**替換為:**

```html
          <div class="results-three-col">
            <div class="result-col">
              <div class="textarea-header" style="display: flex; justify-content: space-between; align-items: center;">
                <span>Duplication Results (<span id="dupResultCount">0</span>)</span>
                <svg onclick="toggleTextarea('collapseMultipleText')" style="cursor:pointer; width:20px; height:20px; fill:#666; transition: fill 0.2s;" onmouseover="this.style.fill='#2196f3'" onmouseout="this.style.fill='#666'" viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
              </div>
              <ul id="collapseMultipleText" class="result-scroll-list"></ul>
              <textarea id="collapseMultipleText_textarea" class="result-textarea" style="display:none; flex: 1; margin-top: 5px; box-sizing: border-box;"></textarea>
            </div>
            <div class="result-col">
              <div class="textarea-header" style="display: flex; justify-content: space-between; align-items: center;">
                <span>Deduplication Results (<span id="dedupResultCount">0</span>)</span>
                <svg onclick="toggleTextarea('gzhahaText')" style="cursor:pointer; width:20px; height:20px; fill:#666; transition: fill 0.2s;" onmouseover="this.style.fill='#2196f3'" onmouseout="this.style.fill='#666'" viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
              </div>
              <ul id="gzhahaText" class="result-scroll-list"></ul>
              <textarea id="gzhahaText_textarea" class="result-textarea" style="display:none; flex: 1; margin-top: 5px; box-sizing: border-box;"></textarea>
            </div>
            <div class="result-col">
              <div class="textarea-header" style="display: flex; justify-content: space-between; align-items: center;">
                <span>Out of Bounds (<span id="outOfBoundsCount">0</span>)</span>
                <svg onclick="toggleTextarea('outOfBoundsText')" style="cursor:pointer; width:20px; height:20px; fill:#666; transition: fill 0.2s;" onmouseover="this.style.fill='#2196f3'" onmouseout="this.style.fill='#666'" viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/></svg>
              </div>
              <ul id="outOfBoundsText" class="result-scroll-list"></ul>
              <textarea id="outOfBoundsText_textarea" class="result-textarea" style="display:none; flex: 1; margin-top: 5px; box-sizing: border-box;"></textarea>
            </div>
          </div>

```

和

```html
            <button id="btnCloseEdit" class="edit-action-btn" onclick="handleEditCloseOnly()">Finish</button>

```

---

### 2. 添加 SVG 切換顯示的 JavaScript 邏輯

請將這段處理 `ul` 列表和 `textarea` 切換的函式加在 `<script>` 的最底部(或 `switchTab` 函式下方)。

**新增代碼:**

```javascript
      function toggleTextarea(id) {
        const list = document.getElementById(id);
        const ta = document.getElementById(id + '_textarea');
        if (list.style.display !== 'none') {
          list.style.display = 'none';
          ta.style.display = 'block';
        } else {
          list.style.display = 'block';
          ta.style.display = 'none';
        }
      }

```

---

### 3. 將資料同步賦值給 Textarea

在 `runDomu1LogicAndGetIntegratedText` 函式中,當程式渲染 list 的同時,也把原始文本放入 textarea 中。

**找到以下代碼:**

```javascript
        document.getElementById('collapseMultipleText').innerHTML = createClickableList(collapseLines);
        document.getElementById('dupResultCount').textContent = collapseLines.length;

        document.getElementById('gzhahaText').innerHTML = createClickableList(gzhahaLines);
        document.getElementById('dedupResultCount').textContent = gzhahaLines.length;

        document.getElementById('outOfBoundsText').innerHTML = createClickableList(outOfBoundsLines);
        document.getElementById('outOfBoundsCount').textContent = outOfBoundsLines.length;

```

**替換為:**

```javascript
        document.getElementById('collapseMultipleText').innerHTML = createClickableList(collapseLines);
        document.getElementById('collapseMultipleText_textarea').value = collapseLines.join('\n');
        document.getElementById('dupResultCount').textContent = collapseLines.length;

        document.getElementById('gzhahaText').innerHTML = createClickableList(gzhahaLines);
        document.getElementById('gzhahaText_textarea').value = gzhahaLines.join('\n');
        document.getElementById('dedupResultCount').textContent = gzhahaLines.length;

        document.getElementById('outOfBoundsText').innerHTML = createClickableList(outOfBoundsLines);
        document.getElementById('outOfBoundsText_textarea').value = outOfBoundsLines.join('\n');
        document.getElementById('outOfBoundsCount').textContent = outOfBoundsLines.length;

```

---

### 4. 修改 Finish (Close) 邏輯,保存為最新的撤銷狀態基準點

在 `handleEditCloseOnly` 中,不再清除快照(`originalSnapshotState.clear()`),而是將當下的狀態重新記錄為最新基準點。

**找到以下代碼:**

```javascript
      // Closes the editing interface and returns to the input box viewport
      function handleEditCloseOnly() {
        document.getElementById('inputArea').style.display = 'block';
        document.getElementById('editArea').style.display = 'none';
        document.getElementById('codeInput').value = '';
        currentEditCode = '';
        currentTargetWord = '';
        selectedEditItem = null;
        justMovedItem = null;
        activeEditKeys.clear();
        changedWords.clear();
        pendingAction = null;
        originalSnapshotState.clear();
        undoStack = [];
        redoStack = [];
        renderActionLogs(); // Visually empty out the log UI on close
        updateActionButtonsUI();
      }

```

**替換為:**

```javascript
      // Finishes the editing session and establishes current state as the new baseline
      function handleEditCloseOnly() {
        document.getElementById('inputArea').style.display = 'block';
        document.getElementById('editArea').style.display = 'none';
        document.getElementById('codeInput').value = '';
        
        // 將當前的編輯結果保存為下一次 Reset 的新基準點
        originalSnapshotState = getSystemState();
        
        currentEditCode = '';
        currentTargetWord = '';
        selectedEditItem = null;
        justMovedItem = null;
        activeEditKeys.clear();
        changedWords.clear();
        pendingAction = null;
        undoStack = [];
        redoStack = [];
        renderActionLogs(); // Visually empty out the log UI on close
        updateActionButtonsUI();
      }

```
https://ejsoon.vip/
弈趣極光:享受思維樂趣
回复
  • 相似主题
    回复总数
    阅读次数
    最新帖子

在线用户

正浏览此版面之用户: Bing [Bot] 和 8 访客