From 1fac18a05cc40b2e5e45bece6a7c909ffadd9a9d Mon Sep 17 00:00:00 2001 From: xulihang Date: Tue, 23 Apr 2024 20:43:51 +0800 Subject: [PATCH] add a menu item to language check the current segment --- BasicCAT/BasicCAT.b4j | 14 ++++++++++++++ BasicCAT/Files/main.bjl | Bin 7520 -> 7633 bytes BasicCAT/Project.bas | 12 ++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/BasicCAT/BasicCAT.b4j b/BasicCAT/BasicCAT.b4j index 4e96105..a2d905c 100644 --- a/BasicCAT/BasicCAT.b4j +++ b/BasicCAT/BasicCAT.b4j @@ -676,6 +676,8 @@ Sub MenuBar1_Action editSource Case "Mark the current segment as neglected/not neglected" changeNeglectedStatus + Case "Perform language check for the current segment" + languageCheckCurrentSegment Case "Clear segments" clearSegments Case "Project _settings" @@ -1260,6 +1262,18 @@ Sub changeNeglectedStatus End If End Sub +Private Sub languageCheckCurrentSegment + Try + checkLVClear + Dim p As Pane + p=editorLV.Items.Get(currentProject.lastEntry) + Dim targetTa As RichTextArea=p.GetNode(1).Tag + currentProject.languagecheck(targetTa,currentProject.lastEntry) + Catch + Log(LastException) + End Try +End Sub + Sub addFolderMi_Action If currentProject.IsInitialized=False Then fx.Msgbox(MainForm,"Please first open a project.","") diff --git a/BasicCAT/Files/main.bjl b/BasicCAT/Files/main.bjl index e2812dd06c9f3cd1d3cb6ab1c88875f9d1bb8bc0..78b42a858a30cc09672be024a003ad819d437beb 100644 GIT binary patch delta 113 zcmaE0bentry Then - languagecheck(TextArea1,lastEntry) + languagecheckIfEnabled(TextArea1,lastEntry) End If previousEntry=entry End If End Sub -Sub languagecheck(ta As RichTextArea,entry As Int) +Sub languagecheckIfEnabled(ta As RichTextArea,entry As Int) If Main.getCheckLVSize<=1 Then If Main.preferencesMap.ContainsKey("languagetoolEnabled") Then If Main.preferencesMap.Get("languagetoolEnabled")=True Then - wait for (LanguageTool.check(ta.Text,projectFile.Get("target"))) complete (matches As List) - showReplacements(matches,entry) + languagecheck(ta,entry) End If End If End If End Sub +public Sub languagecheck(ta As RichTextArea,entry As Int) + wait for (LanguageTool.check(ta.Text,projectFile.Get("target"))) complete (matches As List) + showReplacements(matches,entry) +End Sub + Sub showReplacements(matches As List,entry As Int) If matches.Size=0 Then Main.noErrors