Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Src/Common/Controls/XMLViews/FilterBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,12 @@ protected void MakeCombo(FilterSortItem item)
combo.Items.Add(new FilterComboItem(MakeLabel(XMLViewsStrings.ksNonBlanks), new NonBlankMatcher(), item));
break;
}
string multipara = XmlUtils.GetOptionalAttributeValue(item.Spec, "multipara", "false");
if (multipara == "true")
{
combo.Items.Add(new FilterComboItem(MakeLabel(XMLViewsStrings.ksMoreThanOneLine), new MoreThanOneLineMatcher(), item));
combo.Items.Add(new FilterComboItem(MakeLabel(XMLViewsStrings.ksExactlyOneLine), new ExactlyOneLineMatcher(), item));
}

// Enhance JohnT: figure whether the column has vernacular or analysis data...
int ws = 0;
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/Controls/XMLViews/LayoutFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public ITsString Key(IManyOnePathSortItem item, bool fForSorting)
}
else
{
collector = new TsStringCollectorEnv(null, m_sda, hvo);
collector = new TsStringCollectorEnv(null, m_sda, hvo, true);
}

// This will check to see if the VC is either null or disposed. The disposed check is neccesary because
Expand Down
54 changes: 39 additions & 15 deletions Src/Common/Controls/XMLViews/XMLViewsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Src/Common/Controls/XMLViews/XMLViewsStrings.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -330,6 +330,12 @@ Change the writing system of one of these columns or remove the duplicated colum
<data name="ksNonBlanks" xml:space="preserve">
<value>Non-blanks</value>
</data>
<data name="ksMoreThanOneLine" xml:space="preserve">
<value>More than one line</value>
</data>
<data name="ksExactlyOneLine" xml:space="preserve">
<value>Exactly one line</value>
</data>
<data name="ksNone" xml:space="preserve">
<value>(none)</value>
</data>
Expand Down
60 changes: 60 additions & 0 deletions Src/Common/Filters/RecordFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,7 @@ public override bool Matches(ITsString arg)
}
return false;
}

/// <summary>
/// True if it is the same class and member vars match.
/// </summary>
Expand All @@ -1352,6 +1353,65 @@ public override bool SameMatcher(IMatcher other)
}
}

/// <summary>
/// Matches entries with more than one line.
/// </summary>
public class MoreThanOneLineMatcher : BaseMatcher
{
/// ------------------------------------------------------------------------------------
/// <summary>
/// Contains a new line.
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public override bool Matches(ITsString arg)
{
if (arg == null || arg.Length == 0)
return false;
return arg.Text.Contains("\r");
}

/// <summary>
/// True if it is the same class and member vars match.
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public override bool SameMatcher(IMatcher other)
{
return other is MoreThanOneLineMatcher;
}
}

/// <summary>
/// Matches entries with exactly one line.
/// </summary>
public class ExactlyOneLineMatcher : BaseMatcher
{
/// ------------------------------------------------------------------------------------
/// <summary>
/// Does not contain a new line and is not empty.
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public override bool Matches(ITsString arg)
{
if (arg == null || arg.Length == 0)
return false;
return !arg.Text.Contains("\r");
}
/// <summary>
/// True if it is the same class and member vars match.
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
public override bool SameMatcher(IMatcher other)
{
return other is ExactlyOneLineMatcher;
}
}

/// <summary>
/// Matches if the embedded matcher fails.
/// </summary>
Expand Down
15 changes: 14 additions & 1 deletion Src/Common/RootSite/CollectorEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,7 @@ public class TsStringCollectorEnv : CollectorEnv
private ITsIncStrBldr m_builder;
private bool m_fNewParagraph = false;
private int m_cParaOpened = 0;
private bool m_addEOL = false;

/// ------------------------------------------------------------------------------------
/// <summary>
Expand All @@ -2902,15 +2903,17 @@ public class TsStringCollectorEnv : CollectorEnv
/// <param name="sda">Date access to get prop values etc.</param>
/// <param name="hvoRoot">The root object to display, if m_baseEnv is null.
/// If baseEnv is not null, hvoRoot is ignored.</param>
/// <param name="addEOL">Add an EOL between lines.</param>
/// ------------------------------------------------------------------------------------
public TsStringCollectorEnv(IVwEnv baseEnv, ISilDataAccess sda, int hvoRoot):
public TsStringCollectorEnv(IVwEnv baseEnv, ISilDataAccess sda, int hvoRoot, bool addEOL = false) :
base(baseEnv, sda, hvoRoot)
{
m_builder = TsStringUtils.MakeIncStrBldr();
// In case we add some raw strings, typically numbers, satisfy the constraints of string
// builders by giving it SOME writing system.
m_builder.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault,
sda.WritingSystemFactory.UserWs);
this.m_addEOL = addEOL;
}

/// ------------------------------------------------------------------------------------
Expand All @@ -2921,6 +2924,11 @@ public TsStringCollectorEnv(IVwEnv baseEnv, ISilDataAccess sda, int hvoRoot):
/// ------------------------------------------------------------------------------------
public override void AddTsString(ITsString tss)
{
if (m_addEOL && m_builder.Text != null)
{
// Allow MoreThanOneLineMatcher and ExactlyOneLineMatcher to distinguish lines.
m_builder.Append("\r");
}
AppendSpaceForFirstWordInNewParagraph(tss.Text);
m_builder.AppendTsString(tss);
}
Expand All @@ -2933,6 +2941,11 @@ public override void AddTsString(ITsString tss)
/// ------------------------------------------------------------------------------------
internal protected override void AddResultString(string s)
{
if (m_addEOL && m_builder.Text != null)
{
// Allow MoreThanOneLineMatcher and ExactlyOneLineMatcher to distinguish lines.
m_builder.Append("\r");
}
AppendSpaceForFirstWordInNewParagraph(s);
m_builder.Append(s);
}
Expand Down
Loading