# CutBox.app

## Coverage Report

#### Created: 2024-03-12 03:40

    .../Source/App/SearchAndPreview/SearchAndPreview+KeyDownHandler.swift

    Line

    Count

    Source (jump to first uncovered line)

    1

    //

    2

    //  SearchAndPreview+KeyDownHandler.swift

    3

    //  CutBox

    4

    //

    5

    //  Created by Jason Milkins on 10/4/18.

    6

    //  Copyright © 2018-2023 ocodo. All rights reserved.

    7

    //

    8

    9

    import RxSwift

    10

    import Carbon.HIToolbox

    11

    12

    extension SearchAndPreviewView {

    13

    20

        override func keyDown(with event: NSEvent) {

    14

    20

            onKeyDown(with: event)

    15

    20

        }

    16

    17

        // swiftlint:disable cyclomatic_complexity

    18

    20

        func onKeyDown(with event: NSEvent) {

    19

    20

            switch (event.key, event.modifiers) {

    20

    20

            case (kVK_LeftArrow, _), (kVK_RightArrow, _):

    21

    0

                self.hideSearchResults(false)

    22

    20

    23

    20

            case (kVK_UpArrow, _), (kVK_DownArrow, _):

    24

    1

                self.hideSearchResults(false)

    25

    1

                if !HistoryService.shared.items.isEmpty {

    26

    1

                    self.itemsList.keyDown(with: event)

    27

    20

                }

    28

    20

    29

    20

            case (kVK_ANSI_G, [.control]):

    30

    2

                self.events

    31

    2

                    .onNext(.justClose)

    32

    20

    33

    20

            case (kVK_Return, [.command]):

    34

    1

                self.events

    35

    1

                    .onNext(.selectJavascriptFunction)

    36

    20

    37

    20

            case (kVK_ANSI_A, [.command, .shift]):

    38

    1

                self.events

    39

    1

                    .onNext(.selectJavascriptFunction)

    40

    20

    41

    20

            case (kVK_ANSI_Comma, [.command]):

    42

    2

                self.events

    43

    2

                    .onNext(.openPreferences)

    44

    20

    45

    20

            case (kVK_Return, _):

    46

    1

                self.events

    47

    1

                    .onNext(.closeAndPasteSelected)

    48

    20

    49

    20

            case (kVK_ANSI_T, [.command]):

    50

    1

                self.events

    51

    1

                    .onNext(.cycleTheme)

    52

    20

    53

    20

            case (kVK_ANSI_H, [.command]):

    54

    1

                self.events

    55

    1

                    .onNext(.toggleTimeFilter)

    56

    20

    57

    20

            case (kVK_ANSI_LeftBracket, [.command]):

    58

    1

                self.events

    59

    1

                    .onNext(.toggleWrappingStrings)

    60

    20

    61

    20

            case (kVK_ANSI_Minus, [.command]):

    62

    1

                self.events

    63

    1

                    .onNext(.toggleJoinStrings)

    64

    20

    65

    20

            case (kVK_ANSI_0, [.command, .shift]):

    66

    1

                self.events

    67

    1

                    .onNext(.scaleTextNormalize)

    68

    20

    69

    20

            case (kVK_ANSI_Minus, [.command, .shift]):

    70

    1

                self.events

    71

    1

                    .onNext(.scaleTextDown)

    72

    20

    73

    20

            case (kVK_ANSI_Equal, [.command, .shift]):

    74

    1

                self.events

    75

    1

                    .onNext(.scaleTextUp)

    76

    20

    77

    20

            case (kVK_ANSI_F, [.command]):

    78

    1

                self.events

    79

    1

                    .onNext(.toggleSearchScope)

    80

    20

    81

    20

            case (kVK_ANSI_S, [.command]):

    82

    1

                self.events

    83

    1

                    .onNext(.toggleSearchMode)

    84

    20

    85

    20

            case (kVK_Delete, [.command]):

    86

    1

                self.events

    87

    1

                    .onNext(.removeSelected)

    88

    20

    89

    20

            case (kVK_Delete, [.command, .shift]):

    90

    1

                self.events

    91

    1

                    .onNext(.clearHistory)

    92

    20

    93

    20

            case (kVK_ANSI_P, [.command]):

    94

    1

                self.events

    95

    1

                    .onNext(.togglePreview)

    96

    20

    97

    20

            default:

    98

    0

                return

    99

    20

            }

    100

    20

        }

    101

        // swiftlint:enable cyclomatic_complexity

    102

    }