Skip to content
Snippets Groups Projects
Commit cc6e0a3e authored by George Nachman's avatar George Nachman
Browse files

Use Core Data to store command history and directory history. This is designed...

Use Core Data to store command history and directory history. This is designed to improve performance. Previously, we'd write the whole plist of all history out on every new command or directory change, and it could easily be large (mine was 105kb).
parent bf32c20d
No related branches found
No related tags found
No related merge requests found
Showing
with 1592 additions and 46 deletions
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="8195" systemVersion="15A282b" minimumToolsVersion="Xcode 7.0">
<entity name="CommandHistoryCommandUse" representedClassName="iTermCommandHistoryCommandUseMO" syncable="YES">
<attribute name="code" optional="YES" attributeType="Integer 32" syncable="YES"/>
<attribute name="command" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="directory" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="markGuid" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="time" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<relationship name="entry" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="CommandHistoryEntry" inverseName="uses" inverseEntity="CommandHistoryEntry" syncable="YES"/>
</entity>
<entity name="CommandHistoryEntry" representedClassName="iTermCommandHistoryEntryMO" syncable="YES">
<attribute name="command" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="matchLocation" optional="YES" transient="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="numberOfUses" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="timeOfLastUse" optional="YES" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<relationship name="remoteHost" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="HostRecord" inverseName="entries" inverseEntity="HostRecord" syncable="YES"/>
<relationship name="uses" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="CommandHistoryCommandUse" inverseName="entry" inverseEntity="CommandHistoryCommandUse" syncable="YES"/>
</entity>
<entity name="HostRecord" representedClassName="iTermHostRecordMO" syncable="YES">
<attribute name="hostname" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="username" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="directories" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="RecentDirectory" inverseName="remoteHost" inverseEntity="RecentDirectory" syncable="YES"/>
<relationship name="entries" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="CommandHistoryEntry" inverseName="remoteHost" inverseEntity="CommandHistoryEntry" syncable="YES"/>
</entity>
<entity name="RecentDirectory" representedClassName="iTermRecentDirectoryMO" syncable="YES">
<attribute name="lastUse" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="path" attributeType="String" syncable="YES"/>
<attribute name="starred" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="useCount" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<relationship name="remoteHost" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="HostRecord" inverseName="directories" inverseEntity="HostRecord" syncable="YES"/>
</entity>
<elements>
<element name="HostRecord" positionX="0" positionY="0" width="128" height="105"/>
<element name="CommandHistoryCommandUse" positionX="0" positionY="0" width="128" height="135"/>
<element name="CommandHistoryEntry" positionX="0" positionY="0" width="128" height="135"/>
<element name="RecentDirectory" positionX="18" positionY="63" width="128" height="120"/>
</elements>
</model>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Loading
Loading
@@ -7,12 +7,10 @@
//
 
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#import "CommandHistory.h"
#import "iTermApplication.h"
#import "iTermController.h"
#import "iTermDirectoriesModel.h"
#import "iTermRootTerminalView.h"
#import "iTermShellHistoryController.h"
#import "PseudoTerminal.h"
#import "PTYTab.h"
#import "ToolCapturedOutputView.h"
Loading
Loading
@@ -20,6 +18,7 @@
#import "ToolDirectoriesView.h"
#import "Trigger.h"
#import "VT100RemoteHost.h"
#import <XCTest/XCTest.h>
 
@interface iTermToolbeltTest : XCTestCase<iTermToolbeltViewDelegate>
@property(nonatomic, retain) NSString *currentDir;
Loading
Loading
@@ -44,10 +43,10 @@
VT100RemoteHost *host = [[[VT100RemoteHost alloc] init] autorelease];
host.hostname = @"hostname";
host.username = @"user";
[[CommandHistory sharedInstance] eraseHistoryForHost:host];
[[iTermShellHistoryController sharedInstance] eraseCommandHistoryForHost:host];
 
// Erase directory history for the remotehost we test with.
[[iTermDirectoriesModel sharedInstance] eraseHistoryForHost:host];
[[iTermShellHistoryController sharedInstance] eraseDirectoriesForHost:host];
 
// Create a window and save convenience pointers to its various bits.
_session = [[iTermController sharedInstance] launchBookmark:nil inTerminal:nil];
Loading
Loading
@@ -510,7 +509,7 @@
return NO;
}
 
- (NSArray *)toolbeltCommandUsesForCurrentSession {
- (NSArray<iTermCommandHistoryCommandUseMO *> *)toolbeltCommandUsesForCurrentSession {
return @[];
}
 
Loading
Loading
//
// iTermCommandHistoryCommandUseMO+CoreDataProperties.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermCommandHistoryCommandUseMO.h"
NS_ASSUME_NONNULL_BEGIN
@interface iTermCommandHistoryCommandUseMO (CoreDataProperties)
@property (nullable, nonatomic, retain) NSNumber *code;
@property (nullable, nonatomic, retain) NSString *command;
@property (nullable, nonatomic, retain) NSString *directory;
@property (nullable, nonatomic, retain) NSString *markGuid;
@property (nullable, nonatomic, retain) NSNumber *time;
@property (nullable, nonatomic, retain) iTermCommandHistoryEntryMO *entry;
@end
NS_ASSUME_NONNULL_END
//
// iTermCommandHistoryCommandUseMO+CoreDataProperties.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermCommandHistoryCommandUseMO+CoreDataProperties.h"
@implementation iTermCommandHistoryCommandUseMO (CoreDataProperties)
@dynamic code;
@dynamic command;
@dynamic directory;
@dynamic markGuid;
@dynamic time;
@dynamic entry;
@end
//
// iTermCommandHistoryCommandUseMO.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class iTermCommandHistoryEntryMO;
NS_ASSUME_NONNULL_BEGIN
@interface iTermCommandHistoryCommandUseMO : NSManagedObject
// Insert code here to declare functionality of your managed object subclass
@end
NS_ASSUME_NONNULL_END
#import "iTermCommandHistoryCommandUseMO+CoreDataProperties.h"
//
// iTermCommandHistoryCommandUseMO.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import "iTermCommandHistoryCommandUseMO.h"
#import "iTermCommandHistoryEntryMO.h"
@implementation iTermCommandHistoryCommandUseMO
// Insert code here to add functionality to your managed object subclass
@end
//
// iTermCommandHistoryEntryMO+CoreDataProperties.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermCommandHistoryEntryMO.h"
NS_ASSUME_NONNULL_BEGIN
@interface iTermCommandHistoryEntryMO (CoreDataProperties)
@property (nullable, nonatomic, retain) NSString *command;
@property (nullable, nonatomic, retain) NSNumber *matchLocation;
@property (nullable, nonatomic, retain) NSNumber *numberOfUses;
@property (nullable, nonatomic, retain) NSNumber *timeOfLastUse;
@property (nullable, nonatomic, retain) iTermHostRecordMO *remoteHost;
@property (nullable, nonatomic, retain) NSOrderedSet<iTermCommandHistoryCommandUseMO *> *uses;
@end
@interface iTermCommandHistoryEntryMO (CoreDataGeneratedAccessors)
- (void)insertObject:(iTermCommandHistoryCommandUseMO *)value inUsesAtIndex:(NSUInteger)idx;
- (void)removeObjectFromUsesAtIndex:(NSUInteger)idx;
- (void)insertUses:(NSArray<iTermCommandHistoryCommandUseMO *> *)value atIndexes:(NSIndexSet *)indexes;
- (void)removeUsesAtIndexes:(NSIndexSet *)indexes;
- (void)replaceObjectInUsesAtIndex:(NSUInteger)idx withObject:(iTermCommandHistoryCommandUseMO *)value;
- (void)replaceUsesAtIndexes:(NSIndexSet *)indexes withUses:(NSArray<iTermCommandHistoryCommandUseMO *> *)values;
- (void)addUsesObject:(iTermCommandHistoryCommandUseMO *)value;
- (void)removeUsesObject:(iTermCommandHistoryCommandUseMO *)value;
- (void)addUses:(NSOrderedSet<iTermCommandHistoryCommandUseMO *> *)values;
- (void)removeUses:(NSOrderedSet<iTermCommandHistoryCommandUseMO *> *)values;
@end
NS_ASSUME_NONNULL_END
//
// iTermCommandHistoryEntryMO+CoreDataProperties.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermCommandHistoryEntryMO+CoreDataProperties.h"
@implementation iTermCommandHistoryEntryMO (CoreDataProperties)
@dynamic command;
@dynamic matchLocation;
@dynamic numberOfUses;
@dynamic timeOfLastUse;
@dynamic remoteHost;
@dynamic uses;
@end
//
// iTermCommandHistoryEntryMO.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class iTermCommandHistoryCommandUseMO, iTermHostRecordMO;
NS_ASSUME_NONNULL_BEGIN
@interface iTermCommandHistoryEntryMO : NSManagedObject
// Insert code here to declare functionality of your managed object subclass
@end
NS_ASSUME_NONNULL_END
#import "iTermCommandHistoryEntryMO+CoreDataProperties.h"
//
// iTermCommandHistoryEntryMO.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import "iTermCommandHistoryEntryMO.h"
#import "iTermCommandHistoryCommandUseMO.h"
#import "iTermHostRecordMO.h"
@implementation iTermCommandHistoryEntryMO
// Insert code here to add functionality to your managed object subclass
@end
//
// iTermHostRecordMO+CoreDataProperties.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermHostRecordMO.h"
NS_ASSUME_NONNULL_BEGIN
@interface iTermHostRecordMO (CoreDataProperties)
@property (nullable, nonatomic, retain) NSString *hostname;
@property (nullable, nonatomic, retain) NSString *username;
@property (nullable, nonatomic, retain) NSSet<iTermCommandHistoryEntryMO *> *entries;
@property (nullable, nonatomic, retain) NSSet<iTermRecentDirectoryMO *> *directories;
@end
@interface iTermHostRecordMO (CoreDataGeneratedAccessors)
- (void)addEntriesObject:(iTermCommandHistoryEntryMO *)value;
- (void)removeEntriesObject:(iTermCommandHistoryEntryMO *)value;
- (void)addEntries:(NSSet<iTermCommandHistoryEntryMO *> *)values;
- (void)removeEntries:(NSSet<iTermCommandHistoryEntryMO *> *)values;
- (void)addDirectoriesObject:(iTermRecentDirectoryMO *)value;
- (void)removeDirectoriesObject:(iTermRecentDirectoryMO *)value;
- (void)addDirectories:(NSSet<iTermRecentDirectoryMO *> *)values;
- (void)removeDirectories:(NSSet<iTermRecentDirectoryMO *> *)values;
@end
NS_ASSUME_NONNULL_END
//
// iTermHostRecordMO+CoreDataProperties.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermHostRecordMO+CoreDataProperties.h"
@implementation iTermHostRecordMO (CoreDataProperties)
@dynamic hostname;
@dynamic username;
@dynamic entries;
@dynamic directories;
@end
//
// iTermHostRecordMO.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class iTermCommandHistoryEntryMO, iTermRecentDirectoryMO;
NS_ASSUME_NONNULL_BEGIN
@interface iTermHostRecordMO : NSManagedObject
// Insert code here to declare functionality of your managed object subclass
@end
NS_ASSUME_NONNULL_END
#import "iTermHostRecordMO+CoreDataProperties.h"
//
// iTermHostRecordMO.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import "iTermHostRecordMO.h"
#import "iTermCommandHistoryEntryMO.h"
#import "iTermRecentDirectoryMO.h"
@implementation iTermHostRecordMO
// Insert code here to add functionality to your managed object subclass
@end
//
// iTermRecentDirectoryMO+CoreDataProperties.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermRecentDirectoryMO.h"
NS_ASSUME_NONNULL_BEGIN
@interface iTermRecentDirectoryMO (CoreDataProperties)
@property (nullable, nonatomic, retain) NSString *path;
@property (nullable, nonatomic, retain) NSNumber *useCount;
@property (nullable, nonatomic, retain) NSNumber *lastUse;
@property (nullable, nonatomic, retain) NSNumber *starred;
@property (nullable, nonatomic, retain) iTermHostRecordMO *remoteHost;
@end
NS_ASSUME_NONNULL_END
//
// iTermRecentDirectoryMO+CoreDataProperties.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu
// to delete and recreate this implementation file for your updated model.
//
#import "iTermRecentDirectoryMO+CoreDataProperties.h"
@implementation iTermRecentDirectoryMO (CoreDataProperties)
@dynamic path;
@dynamic useCount;
@dynamic lastUse;
@dynamic starred;
@dynamic remoteHost;
@end
//
// iTermRecentDirectoryMO.h
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@class iTermHostRecordMO;
NS_ASSUME_NONNULL_BEGIN
@interface iTermRecentDirectoryMO : NSManagedObject
// Insert code here to declare functionality of your managed object subclass
@end
NS_ASSUME_NONNULL_END
#import "iTermRecentDirectoryMO+CoreDataProperties.h"
//
// iTermRecentDirectoryMO.m
// iTerm2
//
// Created by George Nachman on 10/12/15.
//
//
#import "iTermRecentDirectoryMO.h"
#import "iTermHostRecordMO.h"
@implementation iTermRecentDirectoryMO
// Insert code here to add functionality to your managed object subclass
@end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment