Skip to content

Commit f6259ee

Browse files
committed
saveText() 方法中的 catch (Exception ex) 例外情形要處理。應該是由於在分段/行時切到了surrogate的字 剛才直播才發現,有機緣再來做了。感恩感恩 南無阿彌陀佛
1 parent f4e9fed commit f6259ee

File tree

6 files changed

+41
-24
lines changed

6 files changed

+41
-24
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Text for Ctext 是為了有效加速[《中國哲學書電子化計劃》](https
88

99
> 尤其由[中研院史語所《漢籍電子文獻資料庫》](http://hanchi.ihp.sinica.edu.tw/ihp/hanji.htm)輸入《十三經注疏》、[《維基文庫》](https://zh.wikisource.org/zh-hant/)輸入《四部叢刊》本、[《國學大師》](http://www.guoxuedashi.net/)輸入《四庫全書》本諸書圖文對照時,輔助加速,避免人工之失誤。感恩感恩 南無阿彌陀佛
1010
11+
>>> 《四庫全書》《四部叢刊》已排版文本亦可於日人 [Kanripo](https://www.kanripo.org/) 網站取得。感恩感恩 讚歎讚歎 南無阿彌陀佛 20240921
12+
1113
>> 昨天邊寫程式、測試,邊完成了[《四部叢刊》《南華真經》(《莊子》)](https://ctext.org/wiki.pl?if=gb&chapter=941297#lib77891.114)[第一份文件](https://ctext.org/wiki.pl?if=gb&chapter=941297&action=history)輸入的工作;真是感覺像飛了起來,和之前用手、眼合作判斷分行切割的速度,懸若天壤、判若兩人。感恩感恩 讚歎讚歎 南無阿彌陀佛
1214
20211217在不斷修改增潤的過程中,也將把[此部《莊子》](https://ctext.org/library.pl?if=gb&res=77451)[維基文本](https://ctext.org/wiki.pl?if=gb&res=393223)建置完畢了。感恩感恩 讚歎讚歎 南無阿彌陀佛 20211218:1951 [建置完畢](https://ctext.org/wiki.pl?if=gb&res=393223) 感恩感恩 南無阿彌陀佛
1315

TextForCtextPortable.zip

3.7 KB
Binary file not shown.

WindowsFormsApp1/CnText.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1257,13 +1257,17 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
12571257
//因為在子函式方法中,若沒有找到時會將標點符號清除再與原未標點之文本作比對,若原文本已略有標點,則會干擾比對結果,不如兩造一律均清除,則簡單有效 20240808
12581258
if (adjustedPos != -1)
12591259
{
1260+
12601261
//punctuatedText = punctuatedText.Insert(adjustedPos, newLine);
12611262
//offset += newLine.Length;
1262-
//以下改在迴圈後再處理--仍在這裡試看看:成功了!20240920
1263+
//以下改在迴圈後再處理--仍在這裡試看看:成功了!20240920
12631264
punctuatedText = punctuatedText.Insert(
12641265
punctuationMarks.Contains(punctuatedText[adjustedPos]) ?
12651266
++adjustedPos : adjustedPos
1266-
, newLine + indentStr);
1267+
, newLine + //若分段符號後起首是「􏿽」,如 : 􏿽人之多事,私欲使然也。無欲則無事矣。<p>
1268+
// 􏿽欲者,無涯之物也。原其端則一𫝹,要其極則無
1269+
// 則非縮排
1270+
((indentCount > 0 && punctuatedText[adjustedPos] == "􏿽"[0])?string.Empty:indentStr));
12671271
offset += newLine.Length + indentCount;
12681272

12691273
}

WindowsFormsApp1/Form1.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -10736,6 +10736,9 @@ internal void saveText()
1073610736
//File.WriteAllText(f, str1, Encoding.UTF8);
1073710737
//throw;
1073810738
Console.WriteLine(ex.HResult + ":" + ex.Message);
10739+
10740+
Debugger.Break();//這裡待除錯!!20240921 應該是由於在分段/行時切到了surrogate的字
10741+
1073910742
Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(ex.HResult + ex.Message);
1074010743
return;
1074110744
}
@@ -11958,7 +11961,8 @@ private void textBox1_TextChanged(object sender, EventArgs e)
1195811961
{//在手動輸入模式下
1195911962
if (mk != Keys.None)
1196011963
{//可能按下Shift+Delete 剪下textBox1的內容時
11961-
hideToNICo();
11964+
if (mk == Keys.ShiftKey)//20240920 Copilot大菩薩:全域鍵盤掛鉤在 C# Windows.Forms 中的使用:
11965+
hideToNICo();//https://sl.bing.net/f5zjhC1h9DU
1196211966
//,通常是要準備貼上的,所以就要將目前在用的瀏覽器置前,確保它取得焦點,否則有時系統焦點會或交給工作列
1196311967
if (browsrOPMode == BrowserOPMode.appActivateByName)
1196411968
{

WordVBA/Keywords.bas

+14-10
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ Property Get
2626
"無妄", VBA.ChrW(26080) & VBA.ChrW(-10171) & VBA.ChrW(-8522), VBA.ChrW(26080) & "妄", _
2727
"無咎", VBA.ChrW(26080) & "咎", "天咎", "允升", _
2828
"隨時之義", "庖有魚", "包有魚", "精義入神", "豶豕", "童牛", "承之羞", "雷在天上", "錫馬", "蕃庶", "晝日", "三接", "懲忿", "窒欲", "懲窒", "敬以直內", "義以方外", "迷後得主", "利西南", "品物咸章", "天下大行", "益動而", "日進無疆", "日進" & VBA.ChrW(26080) & "疆", "頻巽", "頻" & VBA.ChrW(14514), "豚魚", "頻復", "閑邪", "存誠", "乾乾", "悔吝", "憧憧", "類萬物", "柔順利貞", VBA.ChrW(-10163) & VBA.ChrW(-9167) & "順利貞", "比之匪人", "履貞", "貞厲", "履道坦坦", "貞吉", "直方", "木上有水", "勞民勸相", "索而得", _
29-
"無悶", ChrW(26080) & "悶", "悔亡", "悔" & VBA.ChrW(20158), "悔" & VBA.ChrW(20838), "時義", "健順", "內健而外順", "內健外順", "外順而內健", "外順內健", "易簡", "易" & VBA.ChrW(-10153) & VBA.ChrW(-9007), "敦復", "開物成務", "窮神知化", "研幾極深", "極深研幾", "見善則遷", "有過則改", "遷善改過", "夕惕", "惕若", "一陰一陽", "我有好爵", "言有序", "有聖人之道四", "長子帥師", "弟子輿尸", "日用而不知", "之道鮮", "原始反終", "寂然不動", "感而遂通", "朋從", "朋盍", "容民畜眾", "容民畜" & VBA.ChrW(-30650), _
30-
"伏羲")
29+
"無悶", ChrW(26080) & "悶", "悔亡", "悔" & VBA.ChrW(20158), "悔" & VBA.ChrW(20838), "時義", "健順", "內健而外順", "內健外順", "外順而內健", "外順內健", "易簡", "易" & VBA.ChrW(-10153) & VBA.ChrW(-9007), "敦復", "開物成務", "窮神知化", "研幾極深", "極深研幾", "見善則遷", "有過則改", "遷善改過", "夕惕", "惕若", "一陰一陽", "我有好爵", "言有序", "有聖人之道四", "長子帥師", "弟子輿尸", "日用而不知", "之道鮮", "原始反終", "寂然不動", "感而遂通", "朋從", "朋盍", "容民畜眾", "容民畜" & VBA.ChrW(-30650), "養正", "養賢", "知臨", "臨大君", "默而成之", VBA.ChrW(-24871) & "而成之", "不言而信", "存乎德行", "通天下之志", "履正", "繼之者善", "仁者見之", "知者見之", "智者見之", _
30+
_
31+
"伏羲", "伏" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "庖" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "庖羲", "宓羲", "宓" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "宓犧", "伏犧", "庖犧")
3132

3233
End Property
3334
Rem 某關鍵字的前面不能是 20240914
@@ -38,9 +39,9 @@ Property Get
3839
' 添加資料到字典 creedit_with_Copilot大菩薩:https://sl.bing.net/goDF239cQVw
3940
dict.Add "易", Array("尤", "容", "未", "不", "極", "甚", "貿", "交", "物", "變", "或可", "鄙", "博", "辟", "平", "慢", "俗", "坦", "難", "脫", "流", "樂", "革", "更", "簡", "白居", "居", "淺", "輕", "險", "相", "難行", "世", "易", "所", _
4041
"移", "平仄相", "遂", "每歲一", "錢", "光庭、賈", "光庭賈", "為人和", "辟", "驕", "一氣一", "資和", _
41-
"新陳相", "捷最", "崔伯", "劉", "有不善未嘗不知", "事難慮", "事久則慮", "勢固", "立門戶也", "立門" & ChrW(25143) & "也", _
42-
"聽之者", "壞真從", "壞" & ChrW(30494) & "從", "厚和", "誠不為", "可", "人欲", "市", "輒", ChrW(-28903), "遽", "過於和", "平心", "大樂必", _
43-
"知其至")
42+
"新陳相", "捷最", "崔伯", "劉", "有不善未嘗不知", "事難慮", "事久則慮", "勢固", "立門戶也", "立門" & VBA.ChrW(25143) & "也", _
43+
"聽之者", "壞真從", "壞" & VBA.ChrW(30494) & "從", "厚和", "誠不為", "可", "人欲", "市", "輒", VBA.ChrW(-28903), "遽", "過於和", "平心", "大樂必", _
44+
"知其至", "立節行、", "立節行")
4445
dict.Add "乾", Array("白", "豆", "面自", "擰", "餅", "未", "晾", "肉", "蘿蔔", "葡萄", "龍眼", "口", "枯", "烘", "晒", "曬", "筍", "外強中")
4546
dict.Add "乾坤", Array("搆盡", "于此盜")
4647
dict.Add "豫", Array("防患於", "暇", "厎", "音", "底", "不", "劉", "猶", "逸", VBA.ChrW(-10143) & VBA.ChrW(-8996), "道")
@@ -67,8 +68,9 @@ Property Get
6768
dict.Add "噬嗑", Array("令")
6869
dict.Add "既濟", Array("沈", "沉")
6970
dict.Add "初九", Array("月")
70-
dict.Add "九二", Array("卷四", "卷", "卷二", "一一")
71-
dict.Add "九三", Array("卷", "卷一")
71+
dict.Add "九二", Array("卷四", "卷", "卷二", "一一", "一五")
72+
dict.Add "九三", Array("卷", "卷一", "一五")
73+
dict.Add "九五", Array("卷", "卷一", "一五")
7274
dict.Add "初六", Array("月")
7375
dict.Add "六二", Array("卷", "卷一", "卷二")
7476
dict.Add "六三", Array("卷")
@@ -86,6 +88,7 @@ Property Get
8688
dict.Add "易簡", Array("蘇")
8789
dict.Add "易" & VBA.ChrW(-10153) & VBA.ChrW(-9007), Array("蘇")
8890
dict.Add "索而得", Array("豈窮")
91+
dict.Add "養正", Array("劉")
8992

9093
Set 易學KeywordsToMark_ExamPrecededAvoid = dict
9194

@@ -107,8 +110,8 @@ Property Get
107110
dict.Add "乾坤", Array("陷吉人")
108111
dict.Add "豫", Array("章", "讓", "王", "瞻", "則立", "州", "暇", "知", "劇", "備", VBA.ChrW(20675), "防", "聞", "樟", _
109112
"先要", "豫為言之", "豫" & VBA.ChrW(29234) & "言之")
110-
dict.Add "剝", Array("落", "春" & VBA.ChrW(-31631), "春蔥", "", "", "", "", "", "", "去腸", "人面", "婦人衣", "而取之")
111-
dict.Add VBA.ChrW(21093), Array("落", "春" & VBA.ChrW(-31631), "春蔥", "", "", "", "", "", "", "去腸", "人面", "婦人衣", "而取之")
113+
dict.Add "剝", Array("落", "削", "", "", "", "", "去腸", "人面", "婦人衣", "而取之", "春" & VBA.ChrW(-31631), "春蔥", "")
114+
dict.Add VBA.ChrW(21093), Array("落", "削", "", "", "", "", "去腸", "人面", "婦人衣", "而取之", "春" & VBA.ChrW(-31631), "春蔥", "")
112115
dict.Add "蹇", Array("諤", "驢", "材望", "毅然", "已莫")
113116
dict.Add "渙", Array("然", "散", "遂踰")
114117
dict.Add VBA.ChrW(28067), Array("然", "散", "遂踰")
@@ -154,7 +157,7 @@ Property Get
154157
"疾易作", "病易除", "人易從", "易放而難操", "錢差易 ", "言易墜", "所以易放", "者易直", "是易言也", "須易之", "之易以仰測", "蓴絲之易", "皆易黃屋", "皆易" & ChrW(-24892) & "屋", "時易以新", _
155158
"則易使", "侮易承業", "成易具", "綿布易之", "布相易云", "浴易服", _
156159
"因易名曰", "不易長", "和易近人", "大樂必易", "以之易業", "以之易用", "不欲易也", _
157-
"則易入於", _
160+
"則易入於", "皆易與之", _
158161
"非易事", _
159162
"豈易說")
160163
dict.Add "卦", Array("八卦山", "八卦殿")
@@ -180,6 +183,7 @@ Property Get
180183
dict.Add "初九", Array("虞初九百")
181184
dict.Add "九二", Array("一九二0")
182185
dict.Add "九三", Array("廿九三十")
186+
dict.Add "六二", Array("一六二四")
183187
dict.Add "上六", Array("以上六事", "已上六事")
184188
dict.Add "用六", Array("威用六極")
185189
dict.Add "存誠", Array("心存誠敬")

WordVBA/中國哲學書電子化計劃.bas

+14-11
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ Dim d As Document, rng As Range, rngLast As Range, s As Long, e As Long
10061006
Set d = ActiveDocument
10071007
Set rng = d.Range: Set rngLast = rng
10081008
With rng.Find
1009-
.Font.Color = 10092543
1010-
.Font.Size = 10
1009+
.font.Color = 10092543
1010+
.font.Size = 10
10111011
.Forward = True
10121012
Do
10131013
.Execute , , , , , , , wdFindStop
@@ -1031,16 +1031,17 @@ End Sub
10311031

10321032
Rem 回傳網址
10331033
Function Search(searchWhatsUrl As String) As String
1034-
Dim d As Document
1034+
Dim d As Document, encode As String
10351035
Set d = ActiveDocument
10361036
If d.path <> "" Then If d.Saved = False Then d.Save
10371037
If Selection.Type = wdSelectionNormal Then
10381038
Selection.Copy
10391039
End If
1040+
encode = code.UrlEncode(Selection.text)
10401041
'Shell "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe https://ctext.org/wiki.pl?if=gb&res=384378&searchu=" & Selection.text
10411042
'Shell Normal.SystemSetup.getChrome & searchWhatsUrl & Selection.Text
1042-
Shell TextForCtextWordVBA.Network.GetDefaultBrowserEXE & searchWhatsUrl & Selection.text
1043-
Search = searchWhatsUrl & Selection.text
1043+
Shell TextForCtextWordVBA.Network.GetDefaultBrowserEXE & searchWhatsUrl & encode
1044+
Search = searchWhatsUrl & encode
10441045
End Function
10451046

10461047
Sub search史記三家注()
@@ -1049,7 +1050,9 @@ End Sub
10491050

10501051
Sub search周易正義_阮元十三經注疏()
10511052
'Ctrl + Alt + =
1052-
ActiveDocument.Hyperlinks.Add Selection.Range, Search(" https://ctext.org/wiki.pl?if=gb&res=315747&searchu=")
1053+
Dim url As String
1054+
url = 中國哲學書電子化計劃.Search(" https://ctext.org/wiki.pl?if=gb&res=315747&searchu=")
1055+
ActiveDocument.Hyperlinks.Add Selection.Range, url
10531056
End Sub
10541057

10551058

@@ -1483,10 +1486,10 @@ Do While rng.Find.Execute("[[]", , , , , , True, wdFindContinue)
14831486
Loop
14841487
Set rng = rng.Document.Range
14851488
rng.Find.Execute "^p^p", , , , , , , wdFindContinue, , "^p", wdReplaceAll
1486-
rng.Find.Font.Color = 16711935
1489+
rng.Find.font.Color = 16711935
14871490
Do While rng.Find.Execute("", , , False, , , True, wdFindStop)
14881491
Set noteRng = rng
1489-
Do While noteRng.Next.Font.Color = 16711935
1492+
Do While noteRng.Next.font.Color = 16711935
14901493
noteRng.SetRange noteRng.start, noteRng.Next.End
14911494
Loop
14921495
noteRng.text = "{{" & Replace(noteRng, "/", "") & "}}"
@@ -1604,14 +1607,14 @@ Sub
16041607
End With
16051608
For Each e In ay
16061609
With d.Range.Find
1607-
.Font.Color = e
1610+
.font.Color = e
16081611
.Execute "", , , , , , True, wdFindContinue, , "", wdReplaceAll
16091612
End With
16101613
Next e
16111614
Set slRng = d.Range
16121615
With slRng.Find
16131616
.ClearFormatting
1614-
.Font.Color = 34816
1617+
.font.Color = 34816
16151618
End With
16161619
Do While slRng.Find.Execute(, , , , , , True, wdFindStop)
16171620
If InStr(VBA.Chr(13) & VBA.Chr(11) & VBA.Chr(7) & VBA.Chr(8) & VBA.Chr(9) & VBA.Chr(10), slRng) = 0 Then
@@ -1797,7 +1800,7 @@ Sub checkEditingOfPreviousVersion()
17971800
fontColor:
17981801

17991802
rng.Find.ClearFormatting
1800-
rng.Find.Font.Color = 8912896 '{{{}}}語法下的文字
1803+
rng.Find.font.Color = 8912896 '{{{}}}語法下的文字
18011804
rng.Find.Replacement.ClearFormatting
18021805
With rng.Find
18031806
.text = ""

0 commit comments

Comments
 (0)