Skip to content

Commit

Permalink
add a menu item to language check the current segment
Browse files Browse the repository at this point in the history
  • Loading branch information
xulihang committed Apr 23, 2024
1 parent 336cc81 commit 1fac18a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
14 changes: 14 additions & 0 deletions BasicCAT/BasicCAT.b4j
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.","")
Expand Down
Binary file modified BasicCAT/Files/main.bjl
Binary file not shown.
12 changes: 8 additions & 4 deletions BasicCAT/Project.bas
Original file line number Diff line number Diff line change
Expand Up @@ -1747,23 +1747,27 @@ Sub targetTextArea_FocusChanged (HasFocus As Boolean)
Else
Log("loseFocus")
If previousEntry<>entry 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
Expand Down

0 comments on commit 1fac18a

Please sign in to comment.