-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tail feature #486
base: master
Are you sure you want to change the base?
Tail feature #486
Changes from all commits
a0e36e3
cd19a96
8a2135c
63dfd41
c746043
5a2824f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,11 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |
updateLanguageMenu() | ||
} | ||
} | ||
|
||
/// Flag to determine if current file is being tailed. | ||
var isTailEnabled: Bool = false | ||
|
||
var isExistingFile: Bool = false | ||
|
||
// used to calculate the gutter width. Initial -1 so that a new document | ||
// still triggers update of gutter width. | ||
|
@@ -329,6 +334,12 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |
_previousViewportSize = CGSize.zero | ||
redrawEverything() | ||
} | ||
|
||
func enableTailMenu() { | ||
let toggleTailSubMenu = NSApplication.shared.mainMenu!.item(withTitle: "Debug")!.submenu!.item(withTitle: "Tail File") | ||
toggleTailSubMenu!.isEnabled = true | ||
self.isExistingFile = true | ||
} | ||
|
||
/// If font size or theme changes, we invalidate all views. | ||
func redrawEverything() { | ||
|
@@ -711,6 +722,10 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |
document.xiCore.setTheme(themeName: sender.title) | ||
} | ||
|
||
@IBAction func debugToggleTail(_ sender: NSMenuItem) { | ||
document.xiCore.toggleTailConfig(identifier: document.coreViewIdentifier!, enabled: !self.isTailEnabled) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably rewrite this in a way so we don't have to do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrite how? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a little nit, but I'd prefer if this was
|
||
} | ||
|
||
@IBAction func debugSetLanguage(_ sender: NSMenuItem) { | ||
guard sender.state != NSControl.StateValue.on else { print("language already active"); return } | ||
document.xiCore.setLanguage(identifier: document.coreViewIdentifier!, languageName: sender.title) | ||
|
@@ -840,11 +855,28 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |
item.state = findViewController.showMultipleSearchQueries ? .on : .off | ||
} | ||
|
||
func updateTailMenu() { | ||
let toggleTailSubMenu = NSApplication.shared.mainMenu!.item(withTitle: "Debug")!.submenu!.item(withTitle: "Tail File") | ||
if self.isExistingFile { | ||
toggleTailSubMenu!.isEnabled = true | ||
if self.isTailEnabled { | ||
toggleTailSubMenu!.state = NSControl.StateValue.on | ||
} else { | ||
toggleTailSubMenu!.state = NSControl.StateValue.off | ||
} | ||
} else { | ||
toggleTailSubMenu!.isEnabled = false | ||
toggleTailSubMenu!.state = NSControl.StateValue.off | ||
self.isTailEnabled = false | ||
} | ||
} | ||
|
||
// Gets called when active window changes | ||
func updateMenuState() { | ||
updatePluginMenu() | ||
updateLanguageMenu() | ||
updateFindMenu() | ||
updateTailMenu() | ||
} | ||
|
||
@objc func handleCommand(_ sender: NSMenuItem) { | ||
|
@@ -919,6 +951,11 @@ class EditViewController: NSViewController, EditViewDataSource, FindDelegate, Sc | |
languagesMenu.addItem(item) | ||
} | ||
} | ||
|
||
public func enableTailing(_ isTailEnabled: Bool) { | ||
self.isTailEnabled = isTailEnabled | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .. and this part is instead: This avoids having to rely on state from another method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my long comment below. |
||
self.updateTailMenu() | ||
} | ||
|
||
@IBAction func gotoLine(_ sender: AnyObject) { | ||
guard let window = self.view.window else { return } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
enable_tailing
should betoggle_tailing
instead, since it's way clearer in conveying what it does exactly.enable_tailing
implies that it always enables tailing for any file, not what it actually does (which is toggle the tailing state for a specific view).Since you changed this here, your plugin doesn't handle the old JSON properly. Perhaps you should update your other PR as well with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent push the change. I'll do it based on outcome of the naming discussion we are having.