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

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

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

帖子 ejsoon »

近期我發現,如果你想快速做出一個好的程式,一個好的形碼輸入法是非常必要的。

因為現在的做法是,把想法快速準確的描述並告訴AI,讓AI來幫你做,這樣出來的程式又快又好。

也就是說,在AI時代,學會使用一個形碼輸入法真是太必要了!我非常慶幸自己學會了倉頡,並親手製作了目前最好用的形碼——哈哈倉頡。

不過哈哈倉頡已經有一段時間沒有更新了,裡面有些方面確實需要修改。

下面我將把所有要修改的地方記下,並在這幾日把它改好。
上次由 ejsoon 在 2026年 5月 6日 17:29,总共编辑 1 次。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

字:原編碼,要改成的線碼
繼:vfv,vfvv
綠:vfvz,vfv
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

糟fdtw、糕fdt:經查,「糟」的字頻高於「糕」,所以將把「糟」改為fdt,「糕」改為「fdtg」。

改三個詞:
到底:將把「不但」退後,「到底」調至「不能」的後面。則可用「zmi」打出「到底」。

浪費:把它送到「河川」前。則可用「zel」打出「浪費」。

經濟:放到「狀況」後面,則可用「zvez」打出「經濟」。

繳稅:放到「幼兒」前

繳納:跟「紛紛」調換

繳獲:放到「女友」前
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

尹倉要改

釉需要改回hdlw

奐舍

戾淚可能也要改回HSIK,EHSK。

舍可能也要改回OMJR。





鏟諺

[expand]

;cyhm 鏟
;dyhh 楌
;eyhm 滻
;hyhm 簅
;inyhh 谚
;nlyhm 隡
;oyhh 偐
;qyhm 摌
;ryhh 喭
;uyhh 嵃
;uyhm 嵼
;yhhhh 彦
;yhhqm 産
;yryhh 諺
;yuyhh 齴
;yyhh 遃

;eohr 涻
;khohr 猞
;oohr 倽
;qohr 捨
;rohr 啥
;sfohr 騇

;buisk 睙
;cisk 錑
;disk 棙
;eisk 淚
;liisk 蜧
;pisk 悷
;qisk 捩
;risk 唳
;vfisk 綟
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

gemini fast:

代码: 全选

根據您上傳的 `domu.html` 原始碼,若要將保存網址與時間的方式更改為使用專門的 `%url` 與 `%version` 標籤(而非附加在 `%cname` 後方),請將程式碼中「碼表下載邏輯」的部分修改如下:

### 1. 修改 `integrateLines` 處理邏輯
找到腳本中處理 `%cname` 的迴圈(約第 247 行),將其替換為以下邏輯。這段代碼會移除 `%cname` 原有的數字/日期資訊,並在適當位置插入獨立的 `%url` 與 `%version`:

```javascript
// Step 1: Process header tags
const finalLines = [];
const targetUrl = "https://ejsoon.vip/haha"; // Define the target URL

integrateLines.forEach(line => {
    const trimmedLine = line.trim();
    
    if (trimmedLine.startsWith('%cname')) {
        // Clean cname: remove digits and underscores
        let cleanCname = line.replace(/[0-9_]/g, '').trimEnd();
        finalLines.push(cleanCname);
        
        // Insert specific tags for Version and URL
        finalLines.push(`%version ${timestamp}`);
        finalLines.push(`%url ${targetUrl}`);
    } else if (trimmedLine.startsWith('%version') || trimmedLine.startsWith('%url')) {
        // Skip existing version/url tags to prevent duplication
        return;
    } else {
        finalLines.push(line);
    }
});
integrateLines = finalLines;
```

### 2. 移除原有的 `%cname` 附加邏輯
請確保刪除或註釋掉程式碼中舊有的附加邏輯(原先在 `integrateLines.map` 內),以避免重複:

```javascript
// REMOVE OR REPLACE THIS OLD BLOCK:
// integrateLines = integrateLines.map(line => {
//     if (line.trim().startsWith('%cname')) {
//         let modifiedLine = line.replace(/[0-9_]/g, '');
//         ...
//     }
// });
```

### 更改重點說明:
1.  **獨立標籤**:現在 `%version` 和 `%url` 擁有自己的行,這符合標準 `.cin` 格式的擴充規範。
2.  **清理邏輯**:程式會自動過濾掉原本可能存在的舊 `%version` 或 `%url` 標籤,確保生成的檔案內容乾淨且唯一。
3.  **變數控制**:透過 `targetUrl` 變數統一管理網址,方便日後維護。
4.  **英文語法**:所有新增的邏輯與變數命名均使用英文。
if (trimmedLine.startsWith('%version') || trimmedLine.startsWith('%url'))

如果已經存在這個標籤,要更新它的內容。

代码: 全选

To update the content of existing tags rather than just skipping them, you should use a **flag-based approach**. This ensures that if the tags exist, they are updated with the new values, and if they don't exist, they are appended after `%cname`.

Replace the "Step 1" logic in your code with this block:

```javascript
// Step 1: Process header tags and update/insert Version and URL
const finalLines = [];
const targetUrl = "https://ejsoon.vip/haha";
let versionExists = false;
let urlExists = false;

// First pass: Update existing tags and clean cname
integrateLines.forEach(line => {
    const trimmedLine = line.trim();
    
    if (trimmedLine.startsWith('%cname')) {
        // Clean cname: remove digits and underscores
        let cleanCname = line.replace(/[0-9_]/g, '').trimEnd();
        finalLines.push(cleanCname);
    } else if (trimmedLine.startsWith('%version')) {
        finalLines.push(`%version ${timestamp}`);
        versionExists = true;
    } else if (trimmedLine.startsWith('%url')) {
        finalLines.push(`%url ${targetUrl}`);
        urlExists = true;
    } else {
        finalLines.push(line);
    }
});

// Second pass: If tags didn't exist, insert them after %cname
if (!versionExists || !urlExists) {
    const cnameIndex = finalLines.findIndex(l => l.startsWith('%cname'));
    if (cnameIndex !== -1) {
        if (!urlExists) {
            finalLines.splice(cnameIndex + 1, 0, `%url ${targetUrl}`);
        }
        if (!versionExists) {
            finalLines.splice(cnameIndex + 1, 0, `%version ${timestamp}`);
        }
    }
}

integrateLines = finalLines;
```

### Key Changes Made:
* **Update Logic**: If `startsWith('%version')` is detected, it pushes the updated timestamp instead of the old line and sets a flag (`versionExists = true`).
* **Injection Logic**: After the initial loop, the code checks the flags. If a tag was never found, it uses `splice` to insert the missing tag immediately after the `%cname` line.
* **Order Maintenance**: By inserting after `%cname`, it keeps the metadata at the top of the file, which is the standard convention for `.cin` files.

$url後接上帶有/:的字符是可以的嗎?是否更應加到最前面的注釋中?

代码: 全选

在 `.cin` 格式中,處理 `$url` 或 `%url` 這類自定義標籤時,有幾點關於「字符安全性」與「放置位置」的技術建議:

### 1. 關於 `/:` 字符的安全性
**是可以的。** 在 `.cin` 檔案的標籤(如 `%url`)之後,只要該行符合 `[標籤] [值]` 的結構,數值部分包含 `:` 或 `/` 通常不會導致解析崩潰。

* **原因**:解析器通常是以「換行符」來識別指令結束,以「第一個空格或 Tab」來區分標籤名與內容。
* **例外情況**:如果你的網址中包含空格,則必須移除空格或將其百分比編碼(如 `%20`),因為空格會被解析器視為內容的分隔點。

### 2. 放置位置:標籤 vs. 註釋
雖然在標籤中放置網址是可行的,但從**相容性**與**規範性**的角度來看,將其放在最前面的「註釋區」通常是更好的做法。

* **標籤方式 (`%url`)**:這屬於非標準擴充。雖然 GCIN 或 HIME 可能不介意,但某些嚴格的編譯器可能會將其視為無效指令而跳過。
* **註釋方式 (`#`)**:這是最穩妥的。將開發資訊(網址、作者、授權)放在檔案最頂端並以 `#` 開頭,能確保所有解析器都能忽略它,同時人類閱讀時一目瞭然。

---

### 3. 修改建議:結合標籤與註釋
如果你希望既符合程式自動更新的需求,又保持文檔的專業性,建議將代碼邏輯改為將資訊插入到 `%gen_inp` 之前的註釋區。

以下是針對你上傳程式碼的修改方案(將網址放入註釋):

```javascript
// Optimized logic: Place URL in comments for better compatibility
const finalLines = [];
const targetUrl = "https://ejsoon.vip/haha";
let versionExists = false;

// Prepend the URL as a comment at the very beginning
finalLines.push(`# Project URL: ${targetUrl}`);

integrateLines.forEach(line => {
    const trimmedLine = line.trim();
    
    // Clean cname and update version tag
    if (trimmedLine.startsWith('%cname')) {
        let cleanCname = line.replace(/[0-9_]/g, '').trimEnd();
        finalLines.push(cleanCname);
    } else if (trimmedLine.startsWith('%version')) {
        finalLines.push(`%version ${timestamp}`);
        versionExists = true;
    } else if (trimmedLine.startsWith('# Project URL:')) {
        // Skip existing URL comment to prevent duplicates since we added it at top
        return;
    } else {
        finalLines.push(line);
    }
});

// Ensure %version exists after %cname if not found during loop
if (!versionExists) {
    const cnameIdx = finalLines.findIndex(l => l.startsWith('%cname'));
    if (cnameIdx !== -1) {
        finalLines.splice(cnameIdx + 1, 0, `%version ${timestamp}`);
    }
}
```

### 總結建議
1.  **優先使用註釋**:將網址放在檔案頭部的 `#` 註釋中,這在開源社群(如 Rime 方案)是最通用的做法。
2.  **保留版本標籤**:`%version` 對於輸入法引擎追蹤更新非常有用,建議保留為正式標籤。
3.  **編碼檢查**:確保輸出的字串不含隱形換行符,否則會破壞 `.cin` 的行結構。
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

domchatjson

更改所上傳文件的version相關代碼,只需給出所要修改的地方。

代码: 全选

針對您上傳的 `domcharjson.html`,若要比照先前的邏輯將版本資訊與網址獨立出來(而非附加在 `%cname` 後方),請將程式碼中 `processContent` 函數內的「生成時間戳」與「生成新內容」部分(約第 206 行至第 230 行)替換為以下邏輯:

### 修改位置:`processContent` 函數末尾

```javascript
// 1. 生成時間戳與目標網址
const now = new Date();
const timestamp = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}`;
const targetUrl = "https://ejsoon.vip/haha";

// 2. 處理 header 標籤並組合新內容
let finalLines = [];
let versionExists = false;
let urlExists = false;

// 取得基礎結構(排除舊的 %chardef 區塊,插入新生成的詞組區塊)
const rawStructure = [
    ...lines.slice(0, xLine + 1),
    ...generateNewSection(),
    '%chardef end',
    ...lines.slice(charDefEndLine + 1)
];

rawStructure.forEach(line => {
    const trimmedLine = line.trim();
    
    if (trimmedLine.startsWith('%cname')) {
        // 清理 cname:移除數字與下劃線
        let cleanCname = line.replace(/[0-9_]/g, '').trimEnd();
        finalLines.push(cleanCname);
        // 在 %cname 之後記錄位置,稍後若無標籤則在此插入
    } else if (trimmedLine.startsWith('%version')) {
        finalLines.push(`%version ${timestamp}`);
        versionExists = true;
    } else if (trimmedLine.startsWith('%url')) {
        finalLines.push(`%url ${targetUrl}`);
        urlExists = true;
    } else {
        finalLines.push(line);
    }
});

// 3. 如果原本沒有 %version 或 %url,則補在 %cname 後方
if (!versionExists || !urlExists) {
    const cnameIndex = finalLines.findIndex(l => l.startsWith('%cname'));
    if (cnameIndex !== -1) {
        if (!urlExists) finalLines.splice(cnameIndex + 1, 0, `%url ${targetUrl}`);
        if (!versionExists) finalLines.splice(cnameIndex + 1, 0, `%version ${timestamp}`);
    }
}

const newContent = finalLines.join('\n');

// 4. 生成下載連結 (後續 Blob 邏輯保持不變)
const blob = new Blob([newContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
// ... 其餘下載連結代碼
```

### 修改說明:
1.  **邏輯分離**:不再使用 `map` 簡單地在 `%cname` 行末附加字串,而是將 `%version` 與 `%url` 視為獨立的 `.cin` 標籤行。
2.  **自動更新**:如果原始文件中已有 `%version` 或 `%url`,程式會直接更新其內容;如果沒有,則會自動插在 `%cname` 下方。
3.  **名稱清理**:保留了您原本移除 `%cname` 中舊日期/數字的邏輯,確保標籤內容純淨。
附件
haha20260507.7z
(146.86 KiB) 已下载 4 次
https://ejsoon.vip/
弈趣極光:享受思維樂趣
头像
ejsoon
一枝独秀
一枝独秀
帖子: 5480
注册时间: 2022年 11月 18日 17:36
为圈友点赞: 179 次
被圈友点赞: 206 次
联系:

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

帖子 ejsoon »

代码: 全选

		let cinwebsite = '', cname = '', cdate = '', cincontent = '';
		// 處理 %cname 行
		const lines = text.split('\n');
		for (let line of lines) {
			if (line.startsWith('%ename')) {
				const parts = line.replace('%ename ', '').trim().split(' ');
				cinwebsite = parts[1] || '';
				break;
			}
		}
		for (let line of lines) {
			if (line.startsWith('%cname')) {
				const parts = line.replace('%cname ', '').trim().split(' ');
				cname = parts[0] || '';
				cdate = parts[1] || '';
				break;
			}
		}

將以上代碼改為:

cinwebsite將從開頭為「#」,內容包含http,則把http及往後直到行末的字符都賦值給它。

cname直接取「%cname 」開頭,後面直至行末的值,不包括「%cname 」。

cdate直接取「%version 」開頭,後面的值,不包括「%version 」。

gemini fast:

代码: 全选

let cinwebsite = '', cname = '', cdate = '', cincontent = '';
const lines = text.split('\n');

// 1. 處理 cinwebsite: 以 # 開頭且包含 http,截取從 http 到行末
for (let line of lines) {
    let trimmed = line.trim();
    if (trimmed.startsWith('#') && trimmed.includes('http')) {
        const httpIndex = trimmed.indexOf('http');
        cinwebsite = trimmed.substring(httpIndex);
        break; // 找到就跳出
    }
}

// 2. 處理 cname: 取 %cname 開頭後面的所有文字
for (let line of lines) {
    let trimmed = line.trim();
    if (trimmed.startsWith('%cname ')) {
        cname = trimmed.replace('%cname ', '').trim();
        break; // 找到就跳出
    }
}

// 3. 處理 cdate: 取 %version 開頭後面的所有文字
for (let line of lines) {
    let trimmed = line.trim();
    if (trimmed.startsWith('%version ')) {
        cdate = trimmed.replace('%version ', '').trim();
        break; // 找到就跳出
    }
}
https://ejsoon.vip/
弈趣極光:享受思維樂趣
回复

在线用户

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