Skip to content

Commit

Permalink
saveText() 方法中的 catch (Exception ex) 例外情形要處理。應該是由於在分段/行時切到了surrogate…
Browse files Browse the repository at this point in the history
…的字 剛才直播才發現,有機緣再來做了。感恩感恩 南無阿彌陀佛
  • Loading branch information
oscarsun72 committed Sep 21, 2024
1 parent f4e9fed commit f6259ee
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Text for Ctext 是為了有效加速[《中國哲學書電子化計劃》](https

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

Expand Down
Binary file modified TextForCtextPortable.zip
Binary file not shown.
8 changes: 6 additions & 2 deletions WindowsFormsApp1/CnText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,13 +1257,17 @@ int FindAdjustedPosition(string text, int pos, string before, string after)
//因為在子函式方法中,若沒有找到時會將標點符號清除再與原未標點之文本作比對,若原文本已略有標點,則會干擾比對結果,不如兩造一律均清除,則簡單有效 20240808
if (adjustedPos != -1)
{

//punctuatedText = punctuatedText.Insert(adjustedPos, newLine);
//offset += newLine.Length;
//以下改在迴圈後再處理--仍在這裡試看看:成功了!20240920
//以下改在迴圈後再處理--仍在這裡試看看:成功了!20240920
punctuatedText = punctuatedText.Insert(
punctuationMarks.Contains(punctuatedText[adjustedPos]) ?
++adjustedPos : adjustedPos
, newLine + indentStr);
, newLine + //若分段符號後起首是「􏿽」,如 : 􏿽人之多事,私欲使然也。無欲則無事矣。<p>
// 􏿽欲者,無涯之物也。原其端則一𫝹,要其極則無
// 則非縮排
((indentCount > 0 && punctuatedText[adjustedPos] == "􏿽"[0])?string.Empty:indentStr));
offset += newLine.Length + indentCount;

}
Expand Down
6 changes: 5 additions & 1 deletion WindowsFormsApp1/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10736,6 +10736,9 @@ internal void saveText()
//File.WriteAllText(f, str1, Encoding.UTF8);
//throw;
Console.WriteLine(ex.HResult + ":" + ex.Message);

Debugger.Break();//這裡待除錯!!20240921 應該是由於在分段/行時切到了surrogate的字

Form1.MessageBoxShowOKExclamationDefaultDesktopOnly(ex.HResult + ex.Message);
return;
}
Expand Down Expand Up @@ -11958,7 +11961,8 @@ private void textBox1_TextChanged(object sender, EventArgs e)
{//在手動輸入模式下
if (mk != Keys.None)
{//可能按下Shift+Delete 剪下textBox1的內容時
hideToNICo();
if (mk == Keys.ShiftKey)//20240920 Copilot大菩薩:全域鍵盤掛鉤在 C# Windows.Forms 中的使用:
hideToNICo();//https://sl.bing.net/f5zjhC1h9DU
//,通常是要準備貼上的,所以就要將目前在用的瀏覽器置前,確保它取得焦點,否則有時系統焦點會或交給工作列
if (browsrOPMode == BrowserOPMode.appActivateByName)
{
Expand Down
24 changes: 14 additions & 10 deletions WordVBA/Keywords.bas
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ Property Get
"無妄", VBA.ChrW(26080) & VBA.ChrW(-10171) & VBA.ChrW(-8522), VBA.ChrW(26080) & "妄", _
"無咎", VBA.ChrW(26080) & "咎", "天咎", "允升", _
"隨時之義", "庖有魚", "包有魚", "精義入神", "豶豕", "童牛", "承之羞", "雷在天上", "錫馬", "蕃庶", "晝日", "三接", "懲忿", "窒欲", "懲窒", "敬以直內", "義以方外", "迷後得主", "利西南", "品物咸章", "天下大行", "益動而", "日進無疆", "日進" & VBA.ChrW(26080) & "疆", "頻巽", "頻" & VBA.ChrW(14514), "豚魚", "頻復", "閑邪", "存誠", "乾乾", "悔吝", "憧憧", "類萬物", "柔順利貞", VBA.ChrW(-10163) & VBA.ChrW(-9167) & "順利貞", "比之匪人", "履貞", "貞厲", "履道坦坦", "貞吉", "直方", "木上有水", "勞民勸相", "索而得", _
"無悶", ChrW(26080) & "悶", "悔亡", "悔" & VBA.ChrW(20158), "悔" & VBA.ChrW(20838), "時義", "健順", "內健而外順", "內健外順", "外順而內健", "外順內健", "易簡", "易" & VBA.ChrW(-10153) & VBA.ChrW(-9007), "敦復", "開物成務", "窮神知化", "研幾極深", "極深研幾", "見善則遷", "有過則改", "遷善改過", "夕惕", "惕若", "一陰一陽", "我有好爵", "言有序", "有聖人之道四", "長子帥師", "弟子輿尸", "日用而不知", "之道鮮", "原始反終", "寂然不動", "感而遂通", "朋從", "朋盍", "容民畜眾", "容民畜" & VBA.ChrW(-30650), _
"伏羲")
"無悶", ChrW(26080) & "悶", "悔亡", "悔" & VBA.ChrW(20158), "悔" & VBA.ChrW(20838), "時義", "健順", "內健而外順", "內健外順", "外順而內健", "外順內健", "易簡", "易" & VBA.ChrW(-10153) & VBA.ChrW(-9007), "敦復", "開物成務", "窮神知化", "研幾極深", "極深研幾", "見善則遷", "有過則改", "遷善改過", "夕惕", "惕若", "一陰一陽", "我有好爵", "言有序", "有聖人之道四", "長子帥師", "弟子輿尸", "日用而不知", "之道鮮", "原始反終", "寂然不動", "感而遂通", "朋從", "朋盍", "容民畜眾", "容民畜" & VBA.ChrW(-30650), "養正", "養賢", "知臨", "臨大君", "默而成之", VBA.ChrW(-24871) & "而成之", "不言而信", "存乎德行", "通天下之志", "履正", "繼之者善", "仁者見之", "知者見之", "智者見之", _
_
"伏羲", "伏" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "庖" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "庖羲", "宓羲", "宓" & VBA.ChrW(-10152) & VBA.ChrW(-8255), "宓犧", "伏犧", "庖犧")

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

Set 易學KeywordsToMark_ExamPrecededAvoid = dict

Expand All @@ -107,8 +110,8 @@ Property Get
dict.Add "乾坤", Array("陷吉人")
dict.Add "豫", Array("章", "讓", "王", "瞻", "則立", "州", "暇", "知", "劇", "備", VBA.ChrW(20675), "防", "聞", "樟", _
"先要", "豫為言之", "豫" & VBA.ChrW(29234) & "言之")
dict.Add "剝", Array("落", "春" & VBA.ChrW(-31631), "春蔥", "", "", "", "", "", "", "去腸", "人面", "婦人衣", "而取之")
dict.Add VBA.ChrW(21093), Array("落", "春" & VBA.ChrW(-31631), "春蔥", "", "", "", "", "", "", "去腸", "人面", "婦人衣", "而取之")
dict.Add "剝", Array("落", "削", "", "", "", "", "去腸", "人面", "婦人衣", "而取之", "春" & VBA.ChrW(-31631), "春蔥", "")
dict.Add VBA.ChrW(21093), Array("落", "削", "", "", "", "", "去腸", "人面", "婦人衣", "而取之", "春" & VBA.ChrW(-31631), "春蔥", "")
dict.Add "蹇", Array("諤", "驢", "材望", "毅然", "已莫")
dict.Add "渙", Array("然", "散", "遂踰")
dict.Add VBA.ChrW(28067), Array("然", "散", "遂踰")
Expand Down Expand Up @@ -154,7 +157,7 @@ Property Get
"疾易作", "病易除", "人易從", "易放而難操", "錢差易 ", "言易墜", "所以易放", "者易直", "是易言也", "須易之", "之易以仰測", "蓴絲之易", "皆易黃屋", "皆易" & ChrW(-24892) & "屋", "時易以新", _
"則易使", "侮易承業", "成易具", "綿布易之", "布相易云", "浴易服", _
"因易名曰", "不易長", "和易近人", "大樂必易", "以之易業", "以之易用", "不欲易也", _
"則易入於", _
"則易入於", "皆易與之", _
"非易事", _
"豈易說")
dict.Add "卦", Array("八卦山", "八卦殿")
Expand All @@ -180,6 +183,7 @@ Property Get
dict.Add "初九", Array("虞初九百")
dict.Add "九二", Array("一九二0")
dict.Add "九三", Array("廿九三十")
dict.Add "六二", Array("一六二四")
dict.Add "上六", Array("以上六事", "已上六事")
dict.Add "用六", Array("威用六極")
dict.Add "存誠", Array("心存誠敬")
Expand Down
25 changes: 14 additions & 11 deletions WordVBA/中國哲學書電子化計劃.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1006,8 +1006,8 @@ Dim d As Document, rng As Range, rngLast As Range, s As Long, e As Long
Set d = ActiveDocument
Set rng = d.Range: Set rngLast = rng
With rng.Find
.Font.Color = 10092543
.Font.Size = 10
.font.Color = 10092543
.font.Size = 10
.Forward = True
Do
.Execute , , , , , , , wdFindStop
Expand All @@ -1031,16 +1031,17 @@ End Sub

Rem 回傳網址
Function Search(searchWhatsUrl As String) As String
Dim d As Document
Dim d As Document, encode As String
Set d = ActiveDocument
If d.path <> "" Then If d.Saved = False Then d.Save
If Selection.Type = wdSelectionNormal Then
Selection.Copy
End If
encode = code.UrlEncode(Selection.text)
'Shell "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe https://ctext.org/wiki.pl?if=gb&res=384378&searchu=" & Selection.text
'Shell Normal.SystemSetup.getChrome & searchWhatsUrl & Selection.Text
Shell TextForCtextWordVBA.Network.GetDefaultBrowserEXE & searchWhatsUrl & Selection.text
Search = searchWhatsUrl & Selection.text
Shell TextForCtextWordVBA.Network.GetDefaultBrowserEXE & searchWhatsUrl & encode
Search = searchWhatsUrl & encode
End Function

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

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


Expand Down Expand Up @@ -1483,10 +1486,10 @@ Do While rng.Find.Execute("[[]", , , , , , True, wdFindContinue)
Loop
Set rng = rng.Document.Range
rng.Find.Execute "^p^p", , , , , , , wdFindContinue, , "^p", wdReplaceAll
rng.Find.Font.Color = 16711935
rng.Find.font.Color = 16711935
Do While rng.Find.Execute("", , , False, , , True, wdFindStop)
Set noteRng = rng
Do While noteRng.Next.Font.Color = 16711935
Do While noteRng.Next.font.Color = 16711935
noteRng.SetRange noteRng.start, noteRng.Next.End
Loop
noteRng.text = "{{" & Replace(noteRng, "/", "") & "}}"
Expand Down Expand Up @@ -1604,14 +1607,14 @@ Sub
End With
For Each e In ay
With d.Range.Find
.Font.Color = e
.font.Color = e
.Execute "", , , , , , True, wdFindContinue, , "", wdReplaceAll
End With
Next e
Set slRng = d.Range
With slRng.Find
.ClearFormatting
.Font.Color = 34816
.font.Color = 34816
End With
Do While slRng.Find.Execute(, , , , , , True, wdFindStop)
If InStr(VBA.Chr(13) & VBA.Chr(11) & VBA.Chr(7) & VBA.Chr(8) & VBA.Chr(9) & VBA.Chr(10), slRng) = 0 Then
Expand Down Expand Up @@ -1797,7 +1800,7 @@ Sub checkEditingOfPreviousVersion()
fontColor:

rng.Find.ClearFormatting
rng.Find.Font.Color = 8912896 '{{{}}}語法下的文字
rng.Find.font.Color = 8912896 '{{{}}}語法下的文字
rng.Find.Replacement.ClearFormatting
With rng.Find
.text = ""
Expand Down

0 comments on commit f6259ee

Please sign in to comment.