Skip to content

Commit

Permalink
Merge branch 'release/9.1' into LT-21911
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOliver28 authored Oct 7, 2024
2 parents c666d79 + d09b8b7 commit e6dc1f4
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Src/Common/Controls/Widgets/FwComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,8 @@ protected void ShowDropDownBox()
}
else
{
//m_comboListBox.FormWidth = this.Size.Width;
sz.Width = Width;
// If the programmer set an explicit width for the list box, that width is stored in DropDownWidth.
sz.Width = DropDownWidth;
}

if (sz != m_dropDownBox.Form.Size)
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/Controls/Widgets/PopupTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ protected override Size DefaultSize
{
get
{
return new Size(300, 600);
return new Size(300, 400);
// Previously, used (120, 200) for the default size.
// Width set to 120 lets the popuptree dropdown match the width of the box that it drops down from,
// but this doesn't allow enough space to view trees that contain several layers.
Expand Down
4 changes: 2 additions & 2 deletions Src/LexText/LexTextControls/MSAGroupBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ private void InitializeComponent()
//
this.m_fwcbAffixTypes.AdjustStringHeight = true;
this.m_fwcbAffixTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.m_fwcbAffixTypes.DropDownWidth = 140;
this.m_fwcbAffixTypes.DroppedDown = false;
resources.ApplyResources(this.m_fwcbAffixTypes, "m_fwcbAffixTypes");
this.m_fwcbAffixTypes.Name = "m_fwcbAffixTypes";
Expand All @@ -642,7 +641,8 @@ private void InitializeComponent()
// m_tcMainPOS
//
this.m_tcMainPOS.AdjustStringHeight = true;
this.m_tcMainPOS.DropDownWidth = 140;
// Setting width to match the default width used by popuptree
this.m_tcMainPOS.DropDownWidth = 300;
this.m_tcMainPOS.DroppedDown = false;
resources.ApplyResources(this.m_tcMainPOS, "m_tcMainPOS");
this.m_tcMainPOS.Name = "m_tcMainPOS";
Expand Down
37 changes: 31 additions & 6 deletions Src/LexText/ParserCore/FwXmlTraceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
using SIL.Machine.Morphology.HermitCrab.MorphologicalRules;
using SIL.Machine.Morphology.HermitCrab.PhonologicalRules;
using SIL.Machine.FeatureModel;
using SIL.Machine.Annotations;
using System.Collections.Generic;
using System.Text;

namespace SIL.FieldWorks.WordWorks.Parser
{
Expand Down Expand Up @@ -129,16 +132,18 @@ public void PhonologicalRuleApplied(IPhonologicalRule rule, int subruleIndex, Wo
{
((XElement) output.CurrentTrace).Add(new XElement("PhonologicalRuleSynthesisTrace",
CreateHCRuleElement("PhonologicalRule", rule),
CreateWordElement("Input", input, false),
CreateWordElement("Output", output, false)));
// Show bracketed to make debugging phonological rules easier (fixes LT-18682).
CreateWordElement("Input", input, false, true),
CreateWordElement("Output", output, false, true)));
}

public void PhonologicalRuleNotApplied(IPhonologicalRule rule, int subruleIndex, Word input, FailureReason reason, object failureObj)
{
var pruleTrace = new XElement("PhonologicalRuleSynthesisTrace",
CreateHCRuleElement("PhonologicalRule", rule),
CreateWordElement("Input", input, false),
CreateWordElement("Output", input, false));
// Show bracketed to make debugging phonological rules easier (fixes LT-18682).
CreateWordElement("Input", input, false, true),
CreateWordElement("Output", input, false, true));

var rewriteRule = rule as RewriteRule;
if (rewriteRule != null)
Expand Down Expand Up @@ -386,16 +391,36 @@ private static XElement CreateInflFeaturesElement(string name, FeatureStruct fs)
return new XElement(name, fs.Head().ToString().Replace(",", ""));
}

private static XElement CreateWordElement(string name, Word word, bool analysis)
private static XElement CreateWordElement(string name, Word word, bool analysis, bool bracketed = false)
{
string wordStr;
if (word == null)
wordStr = "*None*";
else
wordStr = analysis ? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true) : word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true);
wordStr = analysis
? word.Shape.ToRegexString(word.Stratum.CharacterDefinitionTable, true)
: bracketed ? ToBracketedString(word.Shape, word.Stratum.CharacterDefinitionTable)
: word.Shape.ToString(word.Stratum.CharacterDefinitionTable, true);
return new XElement(name, wordStr);
}

private static string ToBracketedString(IEnumerable<ShapeNode> nodes, CharacterDefinitionTable table)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (ShapeNode node in nodes)
{
string text = table.GetMatchingStrReps(node).FirstOrDefault();
if (text != null)
{
if (text.Length > 1)
text = "(" + text + ")";
stringBuilder.Append(text);
}
}

return stringBuilder.ToString();
}

private XElement CreateMorphemeElement(Morpheme morpheme)
{
var msaID = (int?) morpheme.Properties[HCParser.MsaID] ?? 0;
Expand Down
26 changes: 18 additions & 8 deletions Src/views/VwSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5315,6 +5315,7 @@ void VwTextSelection::MakeSubString(ITsString * ptss, int ichMin, int ichLim, IT
int cch;
CheckHr(ptss->GetBldr(&qtsb));
CheckHr(ptss->get_Length(&cch));

if (ichLim < cch)
CheckHr(qtsb->Replace(ichLim, cch, NULL, NULL));
if (ichMin)
Expand Down Expand Up @@ -5342,16 +5343,25 @@ void VwTextSelection::MakeSubString(ITsString * ptss, int ichMin, int ichLim, IT

if (wsNew <= 0)
{
// Still don't have a writing system, so use the WS of the last run that the
// selection is located in.
int cRun;
CheckHr(m_qtsbProp->get_RunCount(&cRun));
Assert(cRun > 0);
CheckHr(m_qtsbProp->get_Properties(cRun - 1, &qttp));
CheckHr(qttp->GetIntPropValues(ktptWs, &var, &wsNew));
if(m_qtsbProp)
{
// Still don't have a writing system, so use the WS of the last run that the
// selection is located in.
int cRun;
CheckHr(m_qtsbProp->get_RunCount(&cRun));
Assert(cRun > 0);
CheckHr(m_qtsbProp->get_Properties(cRun - 1, &qttp));
CheckHr(qttp->GetIntPropValues(ktptWs, &var, &wsNew));
}
}

Assert(wsNew > 0);
if(wsNew <= 0)
{
// After every effort no suitable source for a ws was found
// This is noteworty, but instead of failing we'll just leave the builder without a new ws
Assert(wsNew > 0);
return;
}
// update the builder with the new writing system
CheckHr(qtsb->get_Properties(0, &qttp));
ITsPropsBldrPtr qtpb;
Expand Down

0 comments on commit e6dc1f4

Please sign in to comment.