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
10 changes: 2 additions & 8 deletions src/SolidGui/AppWritingSystems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ namespace SolidGui
{
public class AppWritingSystems
{
private static IWritingSystemRepository _sWritingSystemsRepository;
private static Lazy<IWritingSystemRepository> _sWritingSystemsRepository = new(() => GlobalWritingSystemRepository.Initialize());

public static IWritingSystemRepository WritingSystems
{
get
{
return _sWritingSystemsRepository ?? (_sWritingSystemsRepository = GlobalWritingSystemRepository.Initialize());
}
}
public static IWritingSystemRepository WritingSystems => _sWritingSystemsRepository.Value;
}
}
8 changes: 4 additions & 4 deletions src/SolidGui/DataShapesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SolidGui
{
public partial class DataShapesDialog : Form
{
private FindReplaceDialog _searchDialog;
private FindReplaceDialog? _searchDialog;

public DataShapesDialog(FindReplaceDialog searchDialog, MainWindowPM mwp)
{
Expand All @@ -34,9 +34,9 @@ public DataShapesDialog(FindReplaceDialog searchDialog, MainWindowPM mwp)
_mainWindowPm = mwp;
}

private MainWindowPM _mainWindowPm;
private MainWindowPM? _mainWindowPm;

private IEnumerable<SfmDictionary.DataShape> _shapes;
private IEnumerable<SfmDictionary.DataShape>? _shapes;

private void _closeButton_Click(object sender, EventArgs e)
{
Expand Down Expand Up @@ -166,7 +166,7 @@ except that dollars ($1$2) would need to be backslashes (\1\2).
if any of the fields have hard-wrapped data.";

RegexItem r = RegexItem.GetCustomRegex(sbFind.ToString(), sbReplace.ToString(), help, true);
_searchDialog.LaunchSearch(r);
_searchDialog?.LaunchSearch(r);

}

Expand Down
3 changes: 2 additions & 1 deletion src/SolidGui/DataValuesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public DataValuesDialog(MainWindowPM mwp)
_mainWindowPm = mwp;
}

private MainWindowPM _mainWindowPm;
private MainWindowPM? _mainWindowPm;

private void _runButton_Click(object sender, EventArgs e)
{
Expand All @@ -30,6 +30,7 @@ private void _runButton_Click(object sender, EventArgs e)
private void Run()
{
if (String.IsNullOrEmpty(_markersTextBox.Text.Trim())) return;
if (_mainWindowPm == null) return;

int max = (int)maxNumericUpDown.Value;

Expand Down
2 changes: 1 addition & 1 deletion src/SolidGui/Engine/SfmField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public SfmField()
public string Trailing // (for trailing white space); added -JMC 2013-09
{
get { return String.IsNullOrEmpty(_trailing) ? DefaultTrailing : _trailing; }
set { _trailing = value.Contains("\n") ? value : null; }
set { _trailing = value.Contains("\n") ? value : ""; }
}

// Set both the value and the trailing-space value using a single string
Expand Down
1 change: 1 addition & 0 deletions src/SolidGui/Engine/SolidReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static bool IsDataWarning (EntryType et)
public SolidReport()
{
Entries = new List<ReportEntry>();
FilePath = "";
}

public static SolidReport MakeCopy(SolidReport report)
Expand Down
3 changes: 2 additions & 1 deletion src/SolidGui/Engine/SolidSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public SolidSettings(List<SolidMarkerSetting> ms)
_markerSettings = ms;
_newlyAdded = new List<SolidMarkerSetting>();
FileStatusReport = new SettingsFileReport();
FilePath = "";
}

public SolidSettings()
Expand Down Expand Up @@ -307,7 +308,7 @@ public static SolidSettings CreateSolidFileFromTemplate(string templateFilePath,
{
ErrorReport.NotifyUserOfProblem(
"There was a problem opening that settings file. The error was\r\n" + e.Message);
return null;
return new SolidSettings(); // Don't want to return null, so return default settings
}

return OpenSolidFile(outputFilePath);
Expand Down
47 changes: 22 additions & 25 deletions src/SolidGui/MainWindowPM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,21 @@ public class MainWindowPM :IDisposable
private static Regex _cleanUpNewlinesNonLinux;
*/


public MainWindowPM()
{
Initialize(new SfmDictionary()); // , new SolidSettings());
}

public override string ToString()
static MainWindowPM()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6}",
_workingDictionary, _markerSettingsModel, _recordFilters, _warningFilterChooserModel,
_navigatorModel, _sfmEditorModel, GetHashCode());
}

private static String TempDictionaryPath()
{
return Path.Combine(Path.GetTempPath(), "TempDictionary.db");
RegexOptions options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Multiline;
_cleanUpIndents = new Regex(@"^[ \t]+\\", options); //any line-initial spaces or tabs
_cleanUpClosers = new Regex(@" ?\\\w+\* ?", options); //any closing tag, and possibly one space buffer around it
_cleanUpInferred = new Regex(@"^[ \t]*\\\+.*(\r|\r?\n)", options); //any inferred marker (\+mrkr) and its value and newline (any leading whitespace)
_cleanUpSeparators = new Regex(@"\t", options); // one tab
_cleanUpNewlines = new Regex(@"(\r?\n|\r)", options); // one newline (\r\n or \n or \r)
}

public void Initialize(SfmDictionary dict) // , SolidSettings settings)
public MainWindowPM()
{
_recordFilters = new RecordFilterSet();
_workingDictionary = dict;
// Settings = settings;
_workingDictionary = new SfmDictionary();
// Settings = new SolidSettings();
_markerSettingsModel = new MarkerSettingsPM(this);
_warningFilterChooserModel = new FilterChooserPM();
_navigatorModel = new RecordNavigatorPM(this);
Expand All @@ -95,13 +87,18 @@ public void Initialize(SfmDictionary dict) // , SolidSettings settings)
// and the choosers should listen to the nav so they can clear themselves as needed
NavigatorModel.NavFilterChanged += WarningFilterChooserModel.OnNavFilterChanged;
NavigatorModel.NavFilterChanged += MarkerSettingsModel.OnNavFilterChanged;
}

RegexOptions options = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.Multiline;
_cleanUpIndents = new Regex(@"^[ \t]+\\", options); //any line-initial spaces or tabs
_cleanUpClosers = new Regex(@" ?\\\w+\* ?", options); //any closing tag, and possibly one space buffer around it
_cleanUpInferred = new Regex(@"^[ \t]*\\\+.*(\r|\r?\n)", options); //any inferred marker (\+mrkr) and its value and newline (any leading whitespace)
_cleanUpSeparators = new Regex(@"\t", options); // one tab
_cleanUpNewlines = new Regex(@"(\r?\n|\r)", options); // one newline (\r\n or \n or \r)
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6}",
_workingDictionary, _markerSettingsModel, _recordFilters, _warningFilterChooserModel,
_navigatorModel, _sfmEditorModel, GetHashCode());
}

private static String TempDictionaryPath()
{
return Path.Combine(Path.GetTempPath(), "TempDictionary.db");
}

public MarkerSettingsPM MarkerSettingsModel
Expand Down Expand Up @@ -336,7 +333,7 @@ public bool ShouldAskForTemplateBeforeOpening(string filePath)
// Check also that the setting file is valid. If it's not allow true to be returned to pop up
// the template chooser.
// See http://projects.palaso.org/issues/show/180
SolidSettings solidSettings = null;
SolidSettings? solidSettings = null;
try
{
solidSettings = LoadSettingsFromExistingFile(solidFilePath); // A dry run. If it succeeds, we'll reload later. -JMC
Expand Down
2 changes: 1 addition & 1 deletion src/SolidGui/Processes/ProcessStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private static void AddClosers(SfmLexEntry lexEntry)
*/


private static SfmFieldModel _appendTo;
private static SfmFieldModel? _appendTo;

// Recursive
private static void AddClosers(SfmFieldModel node)
Expand Down
14 changes: 7 additions & 7 deletions src/SolidGui/QuickFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void PropagateField(string markerOfFieldToPropagate, string markerOfFiel
{
foreach (Record record in _dictionary.Records)
{
SfmFieldModel fieldToCopy = null;
SfmFieldModel? fieldToCopy = null;
for (int i = 0; i < record.Fields.Count; i++)
{
SfmFieldModel field = record.Fields[i];
Expand Down Expand Up @@ -244,13 +244,13 @@ private void AddNewEntries(List<RecordAddition> additions, StringBuilder log)
SolidSettings nullSettings = new SolidSettings(); // JMC: why a new bunch?
foreach (RecordAddition addition in additions)
{
string switchToCitationForm;
Record targetRecord = FindRecordByCitationFormOrLexemeForm(addition.targetHeadWord, out switchToCitationForm);
if (targetRecord == null)
string? switchToCitationForm;
Record? targetRecord = FindRecordByCitationFormOrLexemeForm(addition.targetHeadWord, out switchToCitationForm);
if (targetRecord is null)
{
targetRecord = FindRecordContainingVariantOrSubEntry(addition.targetHeadWord);
}
if (null == targetRecord)
if (targetRecord is null)
{
Record r = new Record();
var b = new StringBuilder();
Expand Down Expand Up @@ -309,7 +309,7 @@ private void SplitFieldsWithMultipleItems(List<string> markers, StringBuilder lo
}


private Record FindRecordByCitationFormOrLexemeForm(string form, out string switchToCitationForm)
private Record? FindRecordByCitationFormOrLexemeForm(string form, out string? switchToCitationForm)
{
switchToCitationForm = null;
form = form.Trim();
Expand Down Expand Up @@ -348,7 +348,7 @@ private Record FindRecordByCitationFormOrLexemeForm(string form, out string swit

return null;
}
private Record FindRecordContainingVariantOrSubEntry(string form)
private Record? FindRecordContainingVariantOrSubEntry(string form)
{

foreach (Record record in _dictionary.Records)
Expand Down