Skip to content

Commit 52e5fbd

Browse files
committed
Complete proof-of-concept of custom expansions
1 parent 70452c2 commit 52e5fbd

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

Streamline.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
D3CCBEC4297E3BA100BEBC61 /* WorkflowGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CCBEC3297E3BA100BEBC61 /* WorkflowGroup.swift */; };
2424
D3CCBEC9297E3FB100BEBC61 /* GroupsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CCBEC8297E3FB100BEBC61 /* GroupsView.swift */; };
2525
D3CCBED0297E44DF00BEBC61 /* WorkflowGroupsState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3CCBECF297E44DF00BEBC61 /* WorkflowGroupsState.swift */; };
26+
D3F7079C29823E0100FE2EA8 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = D3F7079B29823E0100FE2EA8 /* Credits.rtf */; };
2627
/* End PBXBuildFile section */
2728

2829
/* Begin PBXFileReference section */
@@ -44,6 +45,7 @@
4445
D3CCBEC3297E3BA100BEBC61 /* WorkflowGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkflowGroup.swift; sourceTree = "<group>"; };
4546
D3CCBEC8297E3FB100BEBC61 /* GroupsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupsView.swift; sourceTree = "<group>"; };
4647
D3CCBECF297E44DF00BEBC61 /* WorkflowGroupsState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkflowGroupsState.swift; sourceTree = "<group>"; };
48+
D3F7079B29823E0100FE2EA8 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
4749
/* End PBXFileReference section */
4850

4951
/* Begin PBXFrameworksBuildPhase section */
@@ -94,6 +96,7 @@
9496
D38AD1D82978F61500168E90 /* Assets.xcassets */,
9597
D38AD1DD2978F61500168E90 /* Streamline.entitlements */,
9698
D38AD1DA2978F61500168E90 /* Preview Content */,
99+
D3F7079B29823E0100FE2EA8 /* Credits.rtf */,
97100
);
98101
path = Streamline;
99102
sourceTree = "<group>";
@@ -236,6 +239,7 @@
236239
buildActionMask = 2147483647;
237240
files = (
238241
D38AD1DC2978F61500168E90 /* Preview Assets.xcassets in Resources */,
242+
D3F7079C29823E0100FE2EA8 /* Credits.rtf in Resources */,
239243
D38AD1D92978F61500168E90 /* Assets.xcassets in Resources */,
240244
);
241245
runOnlyForDeploymentPostprocessing = 0;
@@ -400,7 +404,7 @@
400404
"@executable_path/../Frameworks",
401405
);
402406
MACOSX_DEPLOYMENT_TARGET = 12.0;
403-
MARKETING_VERSION = 1.0;
407+
MARKETING_VERSION = 0.1.0;
404408
PRODUCT_BUNDLE_IDENTIFIER = me.brianyu.Streamline;
405409
PRODUCT_NAME = "$(TARGET_NAME)";
406410
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -428,7 +432,7 @@
428432
"@executable_path/../Frameworks",
429433
);
430434
MACOSX_DEPLOYMENT_TARGET = 12.0;
431-
MARKETING_VERSION = 1.0;
435+
MARKETING_VERSION = 0.1.0;
432436
PRODUCT_BUNDLE_IDENTIFIER = me.brianyu.Streamline;
433437
PRODUCT_NAME = "$(TARGET_NAME)";
434438
SWIFT_EMIT_LOC_STRINGS = YES;

Streamline/AutomationEngine/EventHandler.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ struct EventHandler {
6565
}
6666
// print("Monitored Input: \(AppState.shared.monitoredInput)")
6767

68-
if let workflow = Workflow.findWorkflowMatchingInput(input: AppState.shared.monitoredInput, workflows: AppState.shared.workflows) {
68+
if let workflow = Workflow.findWorkflowMatchingInput(
69+
input: AppState.shared.monitoredInput,
70+
workflows: AppState.shared.workflows) {
6971
AppState.shared.isCurrentlyExecutingWorkflow = true
7072
Self.copyToClipboard(content: workflow.content)
7173
Self.simulateDeletes(count: workflow.trigger.count)

Streamline/AutomationEngine/Workflow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension Workflow {
2121
// TODO: Make this more efficient, don't linearly serach on every key press.
2222
static func findWorkflowMatchingInput(input: String, workflows: [Workflow]) -> Workflow? {
2323
for workflow in workflows {
24-
if input.hasSuffix(workflow.trigger) {
24+
if workflow.trigger.count > 0 && input.hasSuffix(workflow.trigger) {
2525
return workflow
2626
}
2727
}

Streamline/Credits.rtf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{\rtf1\ansi\ansicpg1252\cocoartf2707
2+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3+
{\colortbl;\red255\green255\blue255;}
4+
{\*\expandedcolortbl;;}
5+
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
6+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
7+
8+
\f0\fs24 \cf0 Developed by Brian Yu\
9+
https://brianyu.me}

Streamline/State/AppState.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class AppState: ObservableObject {
2121

2222
@Published var workflowGroups: [WorkflowGroup] = []
2323

24-
/** Workflows to actively listen for. */
25-
// TODO: Let user configure these. For testing for now, using a predefined list of workflows.
26-
@Published var workflows: [Workflow] = [
27-
Workflow(name: "Trigger 1", trigger: ":test1", content: "Expanded 1"),
28-
Workflow(name: "Trigger 2", trigger: ":test2", content: "Expanded 2"),
29-
Workflow(name: "Trigger 3", trigger: ":testing2", content: "Expanded 3"),
30-
]
24+
var workflows: [Workflow] {
25+
var results: [Workflow] = []
26+
for group in self.workflowGroups {
27+
for workflow in group.workflows {
28+
results.append(workflow)
29+
}
30+
}
31+
return results
32+
}
3133
}
3234

3335
// Preview state

0 commit comments

Comments
 (0)