Skip to content
Draft
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
40 changes: 21 additions & 19 deletions src/functions/Cell.bas
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,22 @@ End Function

Function YankFromUpCell(Optional ByVal g As String) As Boolean
Call RepeatRegister("YankFromUpCell")
Call KeyStroke(Alt_, H_, F_, I_, D_)
Selection.FillDown
End Function

Function YankFromDownCell(Optional ByVal g As String) As Boolean
Call RepeatRegister("YankFromDownCell")
Call KeyStroke(Alt_, H_, F_, I_, U_)
Selection.FillUp
End Function

Function YankFromLeftCell(Optional ByVal g As String) As Boolean
Call RepeatRegister("YankFromLeftCell")
Call KeyStroke(Alt_, H_, F_, I_, R_)
Selection.FillRight
End Function

Function YankFromRightCell(Optional ByVal g As String) As Boolean
Call RepeatRegister("YankFromRightCell")
Call KeyStroke(Alt_, H_, F_, I_, L_)
Selection.FillLeft
End Function

Function YankAsPlaintext(Optional ByVal ColumnSpliter As String = vbTab) As Boolean
Expand Down Expand Up @@ -411,7 +411,7 @@ Function IncrementText(Optional ByVal g As String) As Boolean
Dim i As Integer

For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, k6_)
Application.CommandBars.ExecuteMso "IndentIncrease"
Next i
End Function

Expand All @@ -422,7 +422,7 @@ Function DecrementText(Optional ByVal g As String) As Boolean
Dim i As Integer

For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, k5_)
Application.CommandBars.ExecuteMso "IndentDecrease"
Next i
End Function

Expand All @@ -433,7 +433,7 @@ Function IncreaseDecimal(Optional ByVal g As String) As Boolean
Dim i As Integer

For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, k0_)
Application.CommandBars.ExecuteMso "DecimalsIncrease"
Next i
End Function

Expand All @@ -444,7 +444,7 @@ Function DecreaseDecimal(Optional ByVal g As String) As Boolean
Dim i As Integer

For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, k9_)
Application.CommandBars.ExecuteMso "DecimalsDecrease"
Next i
End Function

Expand Down Expand Up @@ -741,7 +741,9 @@ End Function

Function ToggleWrapText(Optional ByVal g As String) As Boolean
Call StopVisualMode
Call KeyStroke(Alt_, H_, W_)
If TypeName(Selection) = "Range" Then
Selection.WrapText = Not Selection.WrapText
End If
End Function

Function ToggleMergeCells(Optional ByVal g As String) As Boolean
Expand All @@ -754,9 +756,9 @@ Function ToggleMergeCells(Optional ByVal g As String) As Boolean
End If

If ActiveCell.MergeCells Then
Call KeyStroke(Alt_, H_, M_, U_)
Selection.UnMerge
Else
Call KeyStroke(Alt_, H_, M_, M_)
Application.CommandBars.ExecuteMso "MergeCenter"
End If
End If
End Function
Expand All @@ -765,7 +767,7 @@ Function ApplyCommaStyle(Optional ByVal g As String) As Boolean
Call RepeatRegister("ApplyCommaStyle")
Call StopVisualMode

Call KeyStroke(Alt_, H_, K_)
Application.CommandBars.ExecuteMso "CommaStyle"
End Function

Function ChangeInteriorColor(Optional ByVal resultColor As cls_FontColor) As Boolean
Expand Down Expand Up @@ -1154,38 +1156,38 @@ Function ShowCellPicker(Optional ByVal g As String) As Boolean
Call UF_Picker.Launch(New cls_CellPicker)
End Function

Private Function AutoSumInner(ByVal lastKey As Long)
Private Function AutoSumInner(ByVal msoId As String)
On Error GoTo Catch

If TypeName(Selection) <> "Range" Then
Exit Function
End If

Call KeyStroke(Alt_, M_, U_, lastKey)
Application.CommandBars.ExecuteMso msoId

Exit Function
Catch:
Call ErrorHandler("AutoSumInner")
End Function

Function AutoSum(Optional ByVal g As String) As Boolean
Call AutoSumInner(S_)
Call AutoSumInner("AutoSum")
End Function

Function AutoAverage(Optional ByVal g As String) As Boolean
Call AutoSumInner(A_)
Call AutoSumInner("AutoSumAverage")
End Function

Function AutoCount(Optional ByVal g As String) As Boolean
Call AutoSumInner(C_)
Call AutoSumInner("AutoSumCount")
End Function

Function AutoMax(Optional ByVal g As String) As Boolean
Call AutoSumInner(M_)
Call AutoSumInner("AutoSumMax")
End Function

Function AutoMin(Optional ByVal g As String) As Boolean
Call AutoSumInner(I_)
Call AutoSumInner("AutoSumMin")
End Function

Function InsertFunction(Optional ByVal g As String) As Boolean
Expand Down
10 changes: 5 additions & 5 deletions src/functions/Column.bas
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Function InsertColumns(Optional ByVal g As String) As Boolean
Target.Select
savedCell.Activate

Call KeyStroke(Alt_, I_, C_)
Selection.EntireColumn.Insert Shift:=xlToRight

Catch:
Application.ScreenUpdating = True
Expand Down Expand Up @@ -202,7 +202,7 @@ Function AppendColumns(Optional ByVal g As String) As Boolean
Target.Select
savedCell.Activate

Call KeyStroke(Alt_, I_, C_)
Selection.EntireColumn.Insert Shift:=xlToRight

Catch:
Application.ScreenUpdating = True
Expand Down Expand Up @@ -298,7 +298,7 @@ Function UnhideColumns(Optional ByVal g As String) As Boolean

'ref: https://excel.nj-clucker.com/ctrl-shift-0-not-working/
'Call KeyStroke(Ctrl_ + Shift_ + k0_)
Call KeyStroke(Alt_, H_, O_, U_, L_)
Selection.EntireColumn.Hidden = False
Exit Function

Catch:
Expand Down Expand Up @@ -393,7 +393,7 @@ Function AdjustColumnsWidth(Optional ByVal g As String) As Boolean
Selection.Resize(Selection.Rows.Count, gVim.Count1).Select
End If

Call KeyStroke(Alt_, H_, O_, I_)
Selection.EntireColumn.AutoFit
Exit Function

Catch:
Expand All @@ -409,7 +409,7 @@ Function SetColumnsWidth(Optional ByVal g As String) As Boolean
Selection.Resize(Selection.Rows.Count, gVim.Count1).Select
End If

Call KeyStroke(Alt_, H_, O_, W_)
Application.Dialogs(xlDialogColumnWidth).Show
Exit Function

Catch:
Expand Down
30 changes: 19 additions & 11 deletions src/functions/Filter.bas
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,27 @@ Function ToggleAutoFilter(Optional ByVal g As String) As Boolean

If Not lo Is Nothing Then
' Table context
Call KeyStroke(Alt_ + J_, T_, B_)
lo.ShowAutoFilterDropDown = Not lo.ShowAutoFilterDropDown

If lo.ShowAutoFilterDropDown Then
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOff, 2000)
Else
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOn, 2000)
Else
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOff, 2000)
End If
Else
' Worksheet context
Call KeyStroke(Alt_ + A_, T_)
Dim wasOn As Boolean
wasOn = ws.AutoFilterMode

If ws.AutoFilterMode Then
If wasOn Then
ws.AutoFilterMode = False
Else
If ws.UsedRange.Count > 0 Then
ws.UsedRange.AutoFilter
End If
End If

If wasOn Then
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOff, 2000)
Else
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOn, 2000)
Expand Down Expand Up @@ -145,17 +154,16 @@ Function ClearAllFilters(Optional ByVal g As String) As Boolean

If Not lo Is Nothing Then
If lo.ShowAutoFilter Then
' Check if any filter is applied
If Not lo.AutoFilter Is Nothing Then
If lo.AutoFilter.FilterMode Then
Call KeyStroke(Alt_ + A_, C_)
lo.AutoFilter.ShowAllData
cleared = True
End If
End If
End If
Else
If ws.FilterMode Then
Call KeyStroke(Alt_ + A_, C_)
ws.ShowAllData
cleared = True
End If
End If
Expand Down Expand Up @@ -255,9 +263,9 @@ Private Function ApplyAutoFilter(ByVal Field As Long, ByVal Criteria1 As Variant
Set ws = ActiveSheet

If Not IsAutoFilterOn(ws) Then
' If AutoFilter is not active, apply it to the current region.
' This assumes the active cell is within the data range.
Call KeyStroke(Alt_ + A_, T_)
If ws.UsedRange.Count > 0 Then
ws.UsedRange.AutoFilter
End If
Call SetStatusBarTemporarily(gVim.Msg.AutoFilterOn, 2000)
End If

Expand Down
2 changes: 1 addition & 1 deletion src/functions/Find_Replace.bas
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Catch:
End Function

Function ShowReplaceWindow(Optional ByVal g As String) As Boolean
Call KeyStroke(Alt_, E_, E_)
Application.CommandBars.ExecuteMso "ReplaceDialog"
End Function

Function FindActiveValueNext(Optional ByVal g As String) As Boolean
Expand Down
46 changes: 9 additions & 37 deletions src/functions/Font.bas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Function IncreaseFontSize(Optional ByVal g As String) As Boolean

Dim i As Long
For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, F_, G_)
Application.CommandBars.ExecuteMso "GrowFont"
Next i
End Function

Expand All @@ -18,7 +18,7 @@ Function DecreaseFontSize(Optional ByVal g As String) As Boolean

Dim i As Long
For i = 1 To gVim.Count1
Call KeyStroke(Alt_, H_, F_, K_)
Application.CommandBars.ExecuteMso "ShrinkFont"
Next i
End Function

Expand All @@ -33,65 +33,37 @@ End Function
Function AlignLeft(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignLeft")
Call StopVisualMode

'Check excel version
On Error GoTo Excel2019
If CDbl(Application.Version) >= 16 Then
'Raise error in Excel 2016, 2019 (Sequence exists in Excel 2021 and later)
WorksheetFunction.Sequence 1
End If

'Default
Call KeyStroke(Alt_, H_, A_, L_)
Exit Function

Excel2019:
'Excel 2019 and earlier
Call KeyStroke(Alt_, H_, L_, k1_)
Selection.HorizontalAlignment = xlLeft
End Function

Function AlignCenter(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignCenter")
Call StopVisualMode
Call KeyStroke(Alt_, H_, A_, C_)
Selection.HorizontalAlignment = xlCenter
End Function

Function AlignRight(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignRight")
Call StopVisualMode

'Check excel version
On Error GoTo Excel2019
If CDbl(Application.Version) >= 16 Then
'Raise error in Excel 2016, 2019 (Sequence exists in Excel 2021 and later)
WorksheetFunction.Sequence 1
End If

'Default
Call KeyStroke(Alt_, H_, A_, R_)
Exit Function

Excel2019:
'Excel 2019 and earlier
Call KeyStroke(Alt_, H_, R_)
Selection.HorizontalAlignment = xlRight
End Function

Function AlignTop(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignTop")
Call StopVisualMode
Call KeyStroke(Alt_, H_, A_, T_)
Selection.VerticalAlignment = xlTop
End Function

Function AlignMiddle(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignMiddle")
Call StopVisualMode
Call KeyStroke(Alt_, H_, A_, M_)
Selection.VerticalAlignment = xlCenter
End Function

Function AlignBottom(Optional ByVal g As String) As Boolean
Call RepeatRegister("AlignBottom")
Call StopVisualMode
Call KeyStroke(Alt_, H_, A_, B_)
Selection.VerticalAlignment = xlBottom
End Function

Function ToggleBold(Optional ByVal g As String) As Boolean
Expand Down Expand Up @@ -119,7 +91,7 @@ Function ToggleStrikethrough(Optional ByVal g As String) As Boolean
End Function

Function ChangeFormat(Optional ByVal g As String) As Boolean
Call KeyStroke(Alt_, H_, N_, Down_, Down_)
Application.CommandBars.ExecuteMso "NumberFormatsDialog"
End Function

Function showFontDialog(Optional ByVal g As String) As Boolean
Expand Down
8 changes: 4 additions & 4 deletions src/functions/Paste.bas
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ Function PasteValue(Optional ByVal g As String) As Boolean
End If
cbType = cb(2)

If Application.CutCopyMode > 0 Then 'Cells
Call KeyStroke(Alt_, H_, V_, V_)
If Application.CutCopyMode > 0 Then
Selection.PasteSpecial Paste:=xlPasteValues

Else
Select Case cbType
Case xlClipboardFormatText
Call KeyStroke(Ctrl_ + V_)
Case xlClipboardFormatRTF
Call KeyStroke(Alt_, H_, V_, T_)
Application.CommandBars.ExecuteMso "PasteTextOnly"
Case xlHtml
Call KeyStroke(Alt_, H_, V_, S_, End_, Enter_)
Application.CommandBars.ExecuteMso "PasteSpecialDialog"
Case Else
Call DebugPrint("Unknown ClipboardType: " & cbType, "PasteValue")
End Select
Expand Down
Loading