diff --git a/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.dfm b/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.dfm index 7cea795c20..16ee56b0f3 100644 --- a/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.dfm +++ b/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.dfm @@ -1,87 +1,88 @@ -inherited frameWordlistEditor: TframeWordlistEditor - BorderIcons = [] - BorderStyle = bsNone - Caption = 'frameWordlistEditor' - ClientHeight = 338 - ClientWidth = 651 - OnResize = FormResize - ExplicitWidth = 651 - ExplicitHeight = 338 - PixelsPerInch = 96 - TextHeight = 13 - object pages: TPageControl - Left = 0 - Top = 0 - Width = 651 - Height = 338 - ActivePage = pageDesign - Align = alClient - TabOrder = 0 - TabPosition = tpBottom - OnChanging = pagesChanging - ExplicitWidth = 635 - ExplicitHeight = 299 - object pageDesign: TTabSheet - Caption = 'Design' - ImageIndex = -1 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 627 - ExplicitHeight = 273 - object gridWordlist: TStringGridEditControlled - Left = 0 - Top = 0 - Width = 643 - Height = 271 - Align = alClient - ColCount = 3 - DefaultRowHeight = 16 - DefaultDrawing = False - FixedCols = 0 - Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goTabs, goAlwaysShowEditor] - TabOrder = 0 - OnClick = gridWordlistClick - OnDrawCell = gridWordlistDrawCell - OnSetEditText = gridWordlistSetEditText - ExplicitWidth = 627 - ExplicitHeight = 232 - end - object panGridControls: TPanel - Left = 0 - Top = 271 - Width = 643 - Height = 41 - Align = alBottom - TabOrder = 1 - ExplicitTop = 232 - ExplicitWidth = 627 - object cmdDeleteRow: TButton - Left = 0 - Top = 6 - Width = 75 - Height = 25 - Caption = '&Delete row' - TabOrder = 0 - OnClick = cmdDeleteRowClick - end - object cmdSortByFrequency: TButton - Left = 81 - Top = 6 - Width = 104 - Height = 25 - Caption = '&Sort by frequency' - TabOrder = 1 - OnClick = cmdSortByFrequencyClick - end - end - end - object pageCode: TTabSheet - Caption = 'Code' - ImageIndex = -1 - ExplicitLeft = 0 - ExplicitTop = 0 - ExplicitWidth = 0 - ExplicitHeight = 0 - end - end -end +inherited frameWordlistEditor: TframeWordlistEditor + BorderIcons = [] + BorderStyle = bsNone + Caption = 'frameWordlistEditor' + ClientHeight = 338 + ClientWidth = 651 + OnResize = FormResize + ExplicitWidth = 651 + ExplicitHeight = 338 + PixelsPerInch = 96 + TextHeight = 13 + object pages: TPageControl + Left = 0 + Top = 0 + Width = 651 + Height = 338 + ActivePage = pageDesign + Align = alClient + TabOrder = 0 + TabPosition = tpBottom + OnChanging = pagesChanging +ExplicitWidth = 635 + ExplicitHeight = 299 + object pageDesign: TTabSheet + Caption = 'Design' + ImageIndex = -1 +ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 627 + ExplicitHeight = 273 + object gridWordlist: TStringGridEditControlled + Left = 0 + Top = 0 + Width = 643 + Height = 271 + Align = alClient + ColCount = 3 + DefaultRowHeight = 16 + DefaultDrawing = False + FixedCols = 0 + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goTabs, goAlwaysShowEditor] + TabOrder = 0 + OnClick = gridWordlistClick + OnDrawCell = gridWordlistDrawCell + OnSelectCell = gridWordlistSelectCell + OnSetEditText = gridWordlistSetEditText +ExplicitWidth = 627 + ExplicitHeight = 232 + end + object panGridControls: TPanel + Left = 0 + Top = 271 + Width = 643 + Height = 41 + Align = alBottom + TabOrder = 1 +ExplicitTop = 232 + ExplicitWidth = 627 + object cmdDeleteRow: TButton + Left = 0 + Top = 6 + Width = 75 + Height = 25 + Caption = '&Delete row' + TabOrder = 0 + OnClick = cmdDeleteRowClick + end + object cmdSortByFrequency: TButton + Left = 81 + Top = 6 + Width = 104 + Height = 25 + Caption = '&Sort by frequency' + TabOrder = 1 + OnClick = cmdSortByFrequencyClick + end + end + end + object pageCode: TTabSheet + Caption = 'Code' + ImageIndex = -1 +ExplicitLeft = 0 + ExplicitTop = 0 + ExplicitWidth = 0 + ExplicitHeight = 0 + end + end +end diff --git a/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.pas b/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.pas index 3d14c855b1..ea9bdc371a 100644 --- a/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.pas +++ b/developer/src/tike/child/Keyman.Developer.UI.UframeWordlistEditor.pas @@ -41,6 +41,8 @@ type procedure cmdDeleteRowClick(Sender: TObject); procedure gridWordlistClick(Sender: TObject); procedure cmdSortByFrequencyClick(Sender: TObject); + procedure gridWordlistSelectCell(Sender: TObject; ACol, ARow: Integer; + var CanSelect: Boolean); private FWordlist: TWordlistTsvFile; frameSource: TframeTextEditor; @@ -313,6 +315,25 @@ begin ARect.Top+((ARect.Height - gridWordlist.Canvas.TextHeight(LText)) div 2), LText); end; +procedure TframeWordlistEditor.gridWordlistSelectCell(Sender: TObject; ACol, + ARow: Integer; var CanSelect: Boolean); +var + Value: string; +begin + if gridWordlist.Col = 0 then + begin + // The value is trimmed in the backing data but trim it here also when + // we exit a cell, so the visible text matches + Value := Trim(gridWordlist.Cells[gridWordlist.Col, gridWordlist.Row]); + gridWordlist.Cells[gridWordlist.Col, gridWordlist.Row] := Value; + if (gridWordlist.Row = gridWordlist.RowCount - 1) and (Value = '') then + begin + // And if the last row was just whitespace, show the hint text again + FillGridNewRow; + end; + end; +end; + procedure TframeWordlistEditor.gridWordlistSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string); var @@ -324,12 +345,14 @@ begin Inc(FSetup); try + TrimmedValue := Value.Trim; + if ARow = gridWordlist.RowCount - 1 then begin - if (Value = '') or (Value = S_AddRowText) then + if (TrimmedValue = '') or (TrimmedValue = S_AddRowText) then Exit; - w.Word := Value; + w.Word := TrimmedValue; w.Frequency := 0; w.Comment := ''; FWordlist.AddWord(w); @@ -338,7 +361,6 @@ begin end else begin - TrimmedValue := Value.Trim; Frequency := StrToIntDef(TrimmedValue.Replace(',', '', [rfReplaceAll]), 0); w := FWordlist.Word[ARow-1]; case ACol of