Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Add TerminalBuffer & TerminalCursor, parse \n \r \b, and more escape codes #85

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f87ab5
Added TerminalCursor, more control character recognition
ian-mcdowell Feb 11, 2018
25f4c61
Merge branch 'master' into carriage
ian-mcdowell Feb 11, 2018
604e891
A few fixes after merge
ian-mcdowell Feb 11, 2018
248f75b
Added tests for TerminalCursor
ian-mcdowell Feb 11, 2018
04e1292
Added TerminalBufferTests, Moved GCD helpers into Dispatch+Custom
ian-mcdowell Feb 11, 2018
194a57f
Removed absolute path from pbxproj to fix build
ian-mcdowell Feb 11, 2018
b072134
Removed cyclomatic complexity error for Parser method
ian-mcdowell Feb 11, 2018
3eaa455
Added ParserTests, XCTAssert -> XCTAssertEqual, enabled codecov
ian-mcdowell Feb 12, 2018
779714b
Moved ios_system setup to AppDelegate
ian-mcdowell Feb 13, 2018
66ba9f8
Synchronize TerminalCursor & textview cursor, add distance to Termina…
ian-mcdowell Feb 13, 2018
f3b3af8
Fixed bug causing history to be corrupted
ian-mcdowell Feb 13, 2018
ba89fcf
Added Outputsanitizer into the Parser
ian-mcdowell Feb 13, 2018
0abe5dc
Merge branch 'master' into carriage
ian-mcdowell Feb 13, 2018
d09ebcd
Fixed parser tests
ian-mcdowell Feb 13, 2018
59f516d
Added basic sanitizer test, refactored ParserTests a bit
ian-mcdowell Feb 13, 2018
872573a
Fix for missing libtext.dylib & share reading from stdin (#90)
ian-mcdowell Feb 13, 2018
55804dc
Added ls colors test
ian-mcdowell Feb 13, 2018
3d36b8c
Added CommandExecutorTests, ls & cat tests
ian-mcdowell Feb 14, 2018
569865f
Merge branch 'master' into carriage
ian-mcdowell Feb 14, 2018
f474440
Performance improvements for ANSITextState
ian-mcdowell Feb 14, 2018
c577698
No longer mess with process stdout/stderr since it causes bugs
ian-mcdowell Feb 15, 2018
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
28 changes: 28 additions & 0 deletions OpenTerm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
3CA32105201FFC1300974B5F /* ScriptEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA32104201FFC1300974B5F /* ScriptEditViewController.swift */; };
3CA3210920211D5600974B5F /* ScriptExecutorCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA3210820211D5600974B5F /* ScriptExecutorCommand.swift */; };
3CA3210B20212D4200974B5F /* CommandExecutionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA3210A20212D4200974B5F /* CommandExecutionContext.swift */; };
3CD59E63202EFE18002298B4 /* TerminalCursor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CD59E62202EFE17002298B4 /* TerminalCursor.swift */; };
3CD59E67202FDEBA002298B4 /* TerminalCursorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CD59E66202FDEBA002298B4 /* TerminalCursorTests.swift */; };
3CD59E6920301329002298B4 /* TerminalBufferTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CD59E6820301329002298B4 /* TerminalBufferTests.swift */; };
3CD59E6B20301588002298B4 /* Dispatch+Custom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CD59E6A20301588002298B4 /* Dispatch+Custom.swift */; };
3CE5764320225E1B00760E43 /* HistoryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE5764220225E1B00760E43 /* HistoryManager.swift */; };
3CE5764820226A1500760E43 /* ANSITextState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE5764720226A1500760E43 /* ANSITextState.swift */; };
3CE57680202A529200760E43 /* TerminalTabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C905FC42025CAEC0084BA63 /* TerminalTabViewController.swift */; };
3CE57681202A52ED00760E43 /* TerminalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3808571FD9BFB600393EB8 /* TerminalViewController.swift */; };
3CE5769E202A7EC500760E43 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE5769D202A7EC500760E43 /* Parser.swift */; };
3CE576A0202A874C00760E43 /* OutputSanitizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE5769F202A874C00760E43 /* OutputSanitizer.swift */; };
3CE576AA202E61DE00760E43 /* TerminalBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE576A9202E61DE00760E43 /* TerminalBuffer.swift */; };
5A38CC73C499E1A878353871 /* Pods_OpenTerm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC01604DAC695ABD64544260 /* Pods_OpenTerm.framework */; };
BE000C081FEC4F6C00D06B91 /* ios_system.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE3768EE1FEC4DCE00D5A2D1 /* ios_system.framework */; settings = {ATTRIBUTES = (Required, ); }; };
BE000C091FEC4F6F00D06B91 /* ios_system.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE3768EE1FEC4DCE00D5A2D1 /* ios_system.framework */; settings = {ATTRIBUTES = (Required, ); }; };
Expand Down Expand Up @@ -124,10 +129,15 @@
3CA32104201FFC1300974B5F /* ScriptEditViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptEditViewController.swift; sourceTree = "<group>"; };
3CA3210820211D5600974B5F /* ScriptExecutorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptExecutorCommand.swift; sourceTree = "<group>"; };
3CA3210A20212D4200974B5F /* CommandExecutionContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandExecutionContext.swift; sourceTree = "<group>"; };
3CD59E62202EFE17002298B4 /* TerminalCursor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalCursor.swift; sourceTree = "<group>"; };
3CD59E66202FDEBA002298B4 /* TerminalCursorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalCursorTests.swift; sourceTree = "<group>"; };
3CD59E6820301329002298B4 /* TerminalBufferTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalBufferTests.swift; sourceTree = "<group>"; };
3CD59E6A20301588002298B4 /* Dispatch+Custom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Dispatch+Custom.swift"; sourceTree = "<group>"; };
3CE5764220225E1B00760E43 /* HistoryManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryManager.swift; sourceTree = "<group>"; };
3CE5764720226A1500760E43 /* ANSITextState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ANSITextState.swift; sourceTree = "<group>"; };
3CE5769D202A7EC500760E43 /* Parser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Parser.swift; sourceTree = "<group>"; };
3CE5769F202A874C00760E43 /* OutputSanitizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutputSanitizer.swift; sourceTree = "<group>"; };
3CE576A9202E61DE00760E43 /* TerminalBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TerminalBuffer.swift; sourceTree = "<group>"; };
448CC7691FD84EB5D2C24705 /* Pods-OpenTerm.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenTerm.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OpenTerm/Pods-OpenTerm.debug.xcconfig"; sourceTree = "<group>"; };
83138AA9A57F46310B4DFF53 /* Pods_Terminal.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Terminal.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BE165407201909030067EC92 /* xCallBackUrl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = xCallBackUrl.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -257,6 +267,15 @@
path = Scripting;
sourceTree = "<group>";
};
3CD59E61202EFDFA002298B4 /* Terminal */ = {
isa = PBXGroup;
children = (
3CD59E62202EFE17002298B4 /* TerminalCursor.swift */,
3CE576A9202E61DE00760E43 /* TerminalBuffer.swift */,
);
path = Terminal;
sourceTree = "<group>";
};
3CE5764120225E1B00760E43 /* History */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -380,6 +399,7 @@
BEA8E28F2001346D00002475 /* Util */ = {
isa = PBXGroup;
children = (
3CD59E61202EFDFA002298B4 /* Terminal */,
3CE576442022607000760E43 /* Parsing & Formatting */,
3C406E1B2020987B005F97C4 /* AutoComplete */,
3C406E1820207CDA005F97C4 /* Execution */,
Expand All @@ -392,6 +412,7 @@
BEA499251FD9C4D7001B9B9D /* DocumentManager.swift */,
BE9275052013961D00BD2761 /* UserDefaultsController.swift */,
3C905FC920265BC60084BA63 /* StoreReviewPrompter.swift */,
3CD59E6A20301588002298B4 /* Dispatch+Custom.swift */,
);
path = Util;
sourceTree = "<group>";
Expand All @@ -401,6 +422,8 @@
children = (
BEC75BFC202B716600216462 /* OpenTermTests.swift */,
BEC75BFE202B716600216462 /* Info.plist */,
3CD59E66202FDEBA002298B4 /* TerminalCursorTests.swift */,
3CD59E6820301329002298B4 /* TerminalBufferTests.swift */,
);
path = OpenTermTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -621,10 +644,13 @@
F4602B49200A63FC009D0547 /* UserDefaults+UIColor.swift in Sources */,
28CDA426202444CC0055206D /* BookmarkViewController.swift in Sources */,
3CA32105201FFC1300974B5F /* ScriptEditViewController.swift in Sources */,
3CE576AA202E61DE00760E43 /* TerminalBuffer.swift in Sources */,
3C2E4374201EF67C00E4254A /* TerminalView+AutoComplete.swift in Sources */,
BEECFF391FFEC187009608B3 /* SettingsViewController.swift in Sources */,
3CD59E6B20301588002298B4 /* Dispatch+Custom.swift in Sources */,
F456629E200B9BC500C574AA /* ColorDisplayView.swift in Sources */,
BE165408201909040067EC92 /* xCallBackUrl.swift in Sources */,
3CD59E63202EFE18002298B4 /* TerminalCursor.swift in Sources */,
BEA499261FD9C4D7001B9B9D /* DocumentManager.swift in Sources */,
BE505066201E5ED900CDFC60 /* Share.swift in Sources */,
3CE5764820226A1500760E43 /* ANSITextState.swift in Sources */,
Expand All @@ -650,7 +676,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3CD59E6920301329002298B4 /* TerminalBufferTests.swift in Sources */,
BEC75BFD202B716600216462 /* OpenTermTests.swift in Sources */,
3CD59E67202FDEBA002298B4 /* TerminalCursorTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
21 changes: 21 additions & 0 deletions OpenTerm/Util/Dispatch+Custom.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Dispatch+Custom.swift
// OpenTerm
//
// Created by Ian McDowell on 2/10/18.
// Copyright © 2018 Silver Fox. All rights reserved.
//

import Foundation

extension DispatchQueue {

/// Performs the given block on the main thread, without dispatching if already there.
static func performOnMain(_ block: @escaping () -> Void) {
if Thread.isMainThread {
block()
} else {
DispatchQueue.main.async(execute: block)
}
}
}
2 changes: 1 addition & 1 deletion OpenTerm/Util/Parsing & Formatting/ANSITextState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ enum ANSIFontState: Int {

struct ANSITextState {
var foregroundColor: UIColor = UserDefaultsController.shared.terminalTextColor
var backgroundColor: UIColor = UserDefaultsController.shared.terminalBackgroundColor
var backgroundColor: UIColor = .clear
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, switching background colors while terminal is open will not keep remnants of the background color visible where text was printed.

var isUnderlined: Bool = false
var isStrikethrough: Bool = false
var font: UIFont = ANSITextState.font(fromTraits: [])
Expand Down
Loading