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

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

帖子 ejsoon »

「婧婊」似乎應該調換位置。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

「縹」是常用字,如「縹渺、縹緲」。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

「糌」應改為fdho,現在是fdhy。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

把「垸」調至「埞」前。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

「秽」仍應放到後面,改成hdun。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

陨和预一樣也都沒改。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

發現「氳」是錯碼,應該為onwo,之前為onwk。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

倾應為opmo
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

躖應改為rmvi
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

躅應置前
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

改進:
當輸入一個單字時,如這個單字的編碼為abcd,則程式會列出「a,ab,abc,abcd」所對應的字。這時如果再輸入「abef」,則之前不要清除,而是加上「abe,abef」。只有點擊finish後才會清除。

「save to undostack」以及「更新比對」等相關受影響的代碼也要進行更改。

需要給出所有更改的地方和所要替換的代碼,不用給出全部代碼。所有的代碼和注釋都要使用英文。

代码: 全选

改進:
當輸入一個單字時,如這個單字的編碼為abcd,則程式會列出「a,ab,abc,abcd」所對應的字。這時如果再輸入「abef」,則之前不要清除,而是加上「abe,abef」。只有點擊finish後才會清除。

「save to undostack」以及「更新比對」等相關受影響的代碼也要進行更改。

需要給出所有更改的地方和所要替換的代碼,不用給出全部代碼。所有的代碼和注釋都要使用英文。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5813
注册时间: 2022年 11月 18日 17:36
联系:

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

帖子 ejsoon »

改進:
當輸入一個單字時,如這個單字的編碼為abcd,則程式會列出「a,ab,abc,abcd」所對應的字。這時如果再輸入「abef」,則之前不要清除,而是加上「abe,abef」。只有點擊finish(頁面上已有)後才會清除。

「save to undostack」以及「更新比對」等相關受影響的代碼也要進行更改。

需要給出所有更改的地方和所要替換的代碼,不用給出全部代碼。所有的代碼和注釋都要使用英文。

代码: 全选

改進:
當輸入一個單字時,如這個單字的編碼為abcd,則程式會列出「a,ab,abc,abcd」所對應的字。這時如果再輸入「abef」,則之前不要清除,而是加上「abe,abef」。只有點擊finish(頁面上已有)後才會清除。

「save to undostack」以及「更新比對」等相關受影響的代碼也要進行更改。

需要給出所有更改的地方和所要替換的代碼,不用給出全部代碼。所有的代碼和注釋都要使用英文。

gemini pro:

代码: 全选

Here are the required modifications to make the code sequences accumulate correctly without clearing the display until "Finish" is clicked. This also ensures that the undo/redo stack and diffing engine accurately track the cumulative interface state.

Please find the specific functions below and replace the corresponding blocks in your code.

### 1. Update `handleEditSubmit()`

This change stops `activeEditKeys` from resetting on every input. It also wraps `originalSnapshotState` in a condition so that the diffing baseline is preserved across cumulative edits, keeping your comparison highlights intact.

**Replace this block:**

```javascript
        if (isSingleWordMode) {
          activeEditKeys.clear(); // Only show sequences for this code
          for (let i = 1; i <= singleWordActiveCode.length; i++) {
            activeEditKeys.add(singleWordActiveCode.substring(0, i));
          }
          originalSnapshotState = getSystemState();
        } else {

```

**With this code:**

```javascript
        if (isSingleWordMode) {
          // Do not clear activeEditKeys to allow cumulative display
          for (let i = 1; i <= singleWordActiveCode.length; i++) {
            activeEditKeys.add(singleWordActiveCode.substring(0, i));
          }
          // Only initialize the baseline snapshot once per session to maintain diffs
          // across multiple subsequent inputs.
          if (!originalSnapshotState || originalSnapshotState.size === 0) {
            originalSnapshotState = getSystemState();
          }
        } else {

```

---

### 2. Update `saveStateForUndo()`

To ensure the undo system remembers which lines were expanded when an edit occurred, we need to save the current state of `activeEditKeys` into the history stack.

**Replace the entire function with:**

```javascript
      function saveStateForUndo(description = 'Manual Edit') {
        let currentLines = mcc0string.split('\n').filter(l => l.trim() !== '');
        let charDefMapCopy = new Map();
        for (let [k, v] of charDefCodeMap.entries()) {
          charDefMapCopy.set(k, [...v]);
        }
        undoStack.push({
          lines: currentLines,
          filecontent: filecontent,
          charDefCodeMap: charDefMapCopy,
          activeKeys: new Set(activeEditKeys), // Save cumulative keys state
          desc: description
        });
        redoStack = []; // Clear redo stack whenever a new action occurs
        renderActionLogs(); // Update visual logs
      }

```

---

### 3. Update `handleUndo()`

When undoing an action, the UI must also restore the `activeEditKeys` that were visually present at that point in time.

**Replace this block:**

```javascript
        let lastActionDesc = undoStack[undoStack.length - 1].desc;
        redoStack.push({
          lines: currentLines,
          filecontent: filecontent,
          charDefCodeMap: charDefMapCopy,
          desc: `Undo: ${lastActionDesc}`
        });

        let prevState = undoStack.pop();
        let oldState = getSystemState();

```

**With this code:**

```javascript
        let lastActionDesc = undoStack[undoStack.length - 1].desc;
        redoStack.push({
          lines: currentLines,
          filecontent: filecontent,
          charDefCodeMap: charDefMapCopy,
          activeKeys: new Set(activeEditKeys), // Save active keys for redo
          desc: `Undo: ${lastActionDesc}`
        });

        let prevState = undoStack.pop();
        if (prevState.activeKeys) activeEditKeys = new Set(prevState.activeKeys); // Restore keys
        let oldState = getSystemState();

```

---

### 4. Update `handleRedo()`

Similar to undo, redoing an action should accurately push and pull the `activeEditKeys` state from the stack.

**Replace this block:**

```javascript
        let nextState = redoStack.pop();
        undoStack.push({
          lines: currentLines,
          filecontent: filecontent,
          charDefCodeMap: charDefMapCopy,
          desc: nextState.desc
        });

        let oldState = getSystemState();

```

**With this code:**

```javascript
        let nextState = redoStack.pop();
        undoStack.push({
          lines: currentLines,
          filecontent: filecontent,
          charDefCodeMap: charDefMapCopy,
          activeKeys: new Set(activeEditKeys), // Save active keys for undo
          desc: nextState.desc
        });

        if (nextState.activeKeys) activeEditKeys = new Set(nextState.activeKeys); // Restore keys
        let oldState = getSystemState();

```

---

### 5. Update `jumpToLog()`

This ensures that jumping back to a specific timeline point correctly cascades the active UI keys down the redo stack and restores the target layout.

**Replace this block:**

```javascript
        // Transfer chronological items into the redo stack from the trailing end down to the split boundary
        for (let i = undoStack.length - 1; i > index; i--) {
          redoStack.push({
            lines: i === undoStack.length - 1 ? currentLines : undoStack[i + 1].lines,
            filecontent: i === undoStack.length - 1 ? filecontent : undoStack[i + 1].filecontent,
            charDefCodeMap: i === undoStack.length - 1 ? charDefMapCopy : undoStack[i + 1].charDefCodeMap,
            desc: undoStack[i].desc
          });
        }

        // Keep the stack history slice up to and including the targeted executed action index
        undoStack = undoStack.slice(0, index + 1);
        let oldState = getSystemState();

```

**With this code:**

```javascript
        // Transfer chronological items into the redo stack from the trailing end down to the split boundary
        for (let i = undoStack.length - 1; i > index; i--) {
          redoStack.push({
            lines: i === undoStack.length - 1 ? currentLines : undoStack[i + 1].lines,
            filecontent: i === undoStack.length - 1 ? filecontent : undoStack[i + 1].filecontent,
            charDefCodeMap: i === undoStack.length - 1 ? charDefMapCopy : undoStack[i + 1].charDefCodeMap,
            activeKeys: i === undoStack.length - 1 ? new Set(activeEditKeys) : new Set(undoStack[i + 1].activeKeys),
            desc: undoStack[i].desc
          });
        }

        // Keep the stack history slice up to and including the targeted executed action index
        undoStack = undoStack.slice(0, index + 1);
        if (targetState && targetState.activeKeys) activeEditKeys = new Set(targetState.activeKeys); // Restore keys
        let oldState = getSystemState();

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

在线用户

正浏览此版面之用户: 没有注册用户 和 6 访客