From 59ffc88b7971d5f2aba124ead31cd6da8a9fbe76 Mon Sep 17 00:00:00 2001 From: TheDen Date: Sun, 5 May 2024 17:22:33 +1000 Subject: [PATCH] update modules + use go 1.22 + fix typo --- .github/workflows/ci.yml | 17 +--------- Galvani.app/Contents/Info.plist | 2 +- go.mod | 4 +-- go.sum | 4 +-- main.go | 4 +-- .../caseymrm/menuet/EditableNSTextField.h | 7 ++++ .../caseymrm/menuet/EditableNSTextField.m | 34 +++++++++++++++++++ vendor/github.com/caseymrm/menuet/alert.m | 9 ++--- vendor/modules.txt | 2 +- 9 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 vendor/github.com/caseymrm/menuet/EditableNSTextField.h create mode 100644 vendor/github.com/caseymrm/menuet/EditableNSTextField.m diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a946a10..e5bb52b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,21 +3,6 @@ name: CI on: push jobs: - misspell: - name: runner / misspell - runs-on: ubuntu-latest - steps: - - name: Check out code. - uses: actions/checkout@v3 - - name: misspell - uses: reviewdog/action-misspell@v1 - with: - github_token: ${{ secrets.github_token }} - locale: "US" - exclude: | - ./.git/* - ./.vendor/* - build: name: runner / Go package runs-on: macos-latest @@ -27,7 +12,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: "1.20" + go-version: "1.22" - name: build run: go build diff --git a/Galvani.app/Contents/Info.plist b/Galvani.app/Contents/Info.plist index 626548c..7df4a34 100644 --- a/Galvani.app/Contents/Info.plist +++ b/Galvani.app/Contents/Info.plist @@ -3,7 +3,7 @@ CFBundleShortVersionString - 0.2.3 + 0.2.4 CFBundleDevelopmentRegion en CFBundleName diff --git a/go.mod b/go.mod index 231445a..b26d594 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/TheDen/galvani -go 1.21 +go 1.22 require ( - github.com/caseymrm/menuet v1.0.2 + github.com/caseymrm/menuet v1.0.3 howett.net/plist v1.0.1 ) diff --git a/go.sum b/go.sum index 0d9866e..cd78421 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/caseymrm/askm v1.0.0 h1:Ff5QN5GwuyCzg63++hU1jV+1JVYHYd0sw6KUkVd2GiQ= github.com/caseymrm/askm v1.0.0/go.mod h1:raj+vtH8SsGkuSg1/970qaONNyNlIb7zFv2LDVk6j+U= -github.com/caseymrm/menuet v1.0.2 h1:gKacgAxxSr7BTsTlCihxCzJaZGPyKd9o3T49tUTc6Lg= -github.com/caseymrm/menuet v1.0.2/go.mod h1:Vdn4A7NdnGnx9CwlhyhAn4ii5xrpQkvaONdzpTyJ4j0= +github.com/caseymrm/menuet v1.0.3 h1:+JC25L0mxE9a5RUtY88JNZV0awQSbObw/kqKbBWYMTs= +github.com/caseymrm/menuet v1.0.3/go.mod h1:Vdn4A7NdnGnx9CwlhyhAn4ii5xrpQkvaONdzpTyJ4j0= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= diff --git a/main.go b/main.go index df7e1fd..5df7f4c 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( ) const ( - appVersion = "0.2.3" + appVersion = "0.2.4" boltIconOutline = "bolt.png" boltIconFilled = "bolt-filled.png" ALWAYS BatteryState = iota @@ -85,7 +85,7 @@ func setLowPowerMode(str string) error { "/usr/bin/osascript", "-e", fmt.Sprintf( - "do shell script \"%s\" with prompt \"Galvani is trying to update battery prefrences\" with administrator privileges", + "do shell script \"%s\" with prompt \"Galvani is trying to update battery preferences\" with administrator privileges", str, ), ) diff --git a/vendor/github.com/caseymrm/menuet/EditableNSTextField.h b/vendor/github.com/caseymrm/menuet/EditableNSTextField.h new file mode 100644 index 0000000..edf5eaa --- /dev/null +++ b/vendor/github.com/caseymrm/menuet/EditableNSTextField.h @@ -0,0 +1,7 @@ +#import + +@interface EditableNSTextField : NSTextField + +- (BOOL)performKeyEquivalent:(NSEvent *)event; + +@end \ No newline at end of file diff --git a/vendor/github.com/caseymrm/menuet/EditableNSTextField.m b/vendor/github.com/caseymrm/menuet/EditableNSTextField.m new file mode 100644 index 0000000..8e6ecd0 --- /dev/null +++ b/vendor/github.com/caseymrm/menuet/EditableNSTextField.m @@ -0,0 +1,34 @@ +#import "EditableNSTextField.h" + +// https://blog.kulman.sk/making-copy-paste-work-with-nstextfield/ + +@implementation EditableNSTextField + +NSUInteger commandKey = NSEventModifierFlagCommand; +NSUInteger commandShiftKey = NSEventModifierFlagCommand | NSEventModifierFlagShift; + +- (BOOL)performKeyEquivalent:(NSEvent *)event { + if (event.type == NSEventTypeKeyDown) { + if ((event.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask) == commandKey) { + NSString *key = event.charactersIgnoringModifiers; + if ([key isEqualToString:@"x"]) { + return [NSApp sendAction:@selector(cut:) to:nil from:self]; + } else if ([key isEqualToString:@"c"]) { + return [NSApp sendAction:@selector(copy:) to:nil from:self]; + } else if ([key isEqualToString:@"v"]) { + return [NSApp sendAction:@selector(paste:) to:nil from:self]; + } else if ([key isEqualToString:@"z"]) { + return [NSApp sendAction:@selector(undo:) to:nil from:self]; + } else if ([key isEqualToString:@"a"]) { + return [NSApp sendAction:@selector(selectAll:) to:nil from:self]; + } + } else if ((event.modifierFlags & NSEventModifierFlagDeviceIndependentFlagsMask) == commandShiftKey) { + if ([event.charactersIgnoringModifiers isEqualToString:@"Z"]) { + return [NSApp sendAction:@selector(redo:) to:nil from:self]; + } + } + } + return [super performKeyEquivalent:event]; +} + +@end \ No newline at end of file diff --git a/vendor/github.com/caseymrm/menuet/alert.m b/vendor/github.com/caseymrm/menuet/alert.m index cb0abb7..84ff44a 100644 --- a/vendor/github.com/caseymrm/menuet/alert.m +++ b/vendor/github.com/caseymrm/menuet/alert.m @@ -1,6 +1,7 @@ #import #import "alert.h" +#import "EditableNSTextField.h" void alertClicked(int, const char *); @@ -30,8 +31,8 @@ void showAlert(const char *jsonString) { accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, y)]; for (NSString *input in inputs) { y -= 30; - NSTextField *textfield = - [[NSTextField alloc] initWithFrame:NSMakeRect(0, y, 200, 25)]; + EditableNSTextField *textfield = + [[EditableNSTextField alloc] initWithFrame:NSMakeRect(0, y, 200, 25)]; [textfield setPlaceholderString:input]; [accessoryView addSubview:textfield]; if (!first) { @@ -47,10 +48,10 @@ void showAlert(const char *jsonString) { NSMutableArray *values = [NSMutableArray new]; if (hasInputs) { for (NSView *subview in accessoryView.subviews) { - if (![subview isKindOfClass:[NSTextField class]]) { + if (![subview isKindOfClass:[EditableNSTextField class]]) { continue; } - [values addObject:((NSTextField *)subview).stringValue]; + [values addObject:((EditableNSTextField *)subview).stringValue]; } } NSData *jsonData = diff --git a/vendor/modules.txt b/vendor/modules.txt index dbcd9e7..22a541d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/caseymrm/askm v1.0.0 ## explicit github.com/caseymrm/askm -# github.com/caseymrm/menuet v1.0.2 +# github.com/caseymrm/menuet v1.0.3 ## explicit; go 1.13 github.com/caseymrm/menuet # howett.net/plist v1.0.1