mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-16 08:31:06 +00:00
Implement and add a simple go-to-line panel
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@38051 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e617310415
commit
c312302b39
8 changed files with 131 additions and 4 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-08-29 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Modules/Editors/ProjectCenter/GNUmakefile
|
||||
* Modules/Editors/ProjectCenter/LineJumper.h
|
||||
* Modules/Editors/ProjectCenter/LineJumper.m
|
||||
* Modules/Editors/ProjectCenter/PCEditorView.m
|
||||
* Modules/Editors/ProjectCenter/Resources/LineJumper.gorm
|
||||
Implement and add a simple go-to-line panel
|
||||
|
||||
2014-08-25 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Modules/Editors/ProjectCenter/PCEditor.m (unhighlightCharacter:):
|
||||
|
|
|
@ -29,7 +29,8 @@ ProjectCenter_RESOURCE_FILES= \
|
|||
Resources/FileH.tiff \
|
||||
Resources/FileHH.tiff \
|
||||
Resources/FileM.tiff \
|
||||
Resources/FileMH.tiff
|
||||
Resources/FileMH.tiff \
|
||||
Resources/LineJumper.gorm
|
||||
|
||||
#
|
||||
# Header files
|
||||
|
@ -38,7 +39,8 @@ ProjectCenter_HEADERS= \
|
|||
PCEditor.h \
|
||||
PCEditorView.h \
|
||||
SyntaxDefinition.h \
|
||||
SyntaxHighlighter.h
|
||||
SyntaxHighlighter.h \
|
||||
LineJumper.h
|
||||
|
||||
#
|
||||
# Class files
|
||||
|
@ -48,7 +50,8 @@ ProjectCenter_OBJC_FILES= \
|
|||
PCEditorView.m \
|
||||
TextPattern.m \
|
||||
SyntaxDefinition.m \
|
||||
SyntaxHighlighter.m
|
||||
SyntaxHighlighter.m \
|
||||
LineJumper.m
|
||||
|
||||
include ../../GNUmakefile.bundles
|
||||
include $(GNUSTEP_MAKEFILES)/bundle.make
|
||||
|
|
20
Modules/Editors/ProjectCenter/LineJumper.h
Normal file
20
Modules/Editors/ProjectCenter/LineJumper.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#import <Foundation/NSObject.h>
|
||||
#import <Protocols/CodeEditorView.h>
|
||||
|
||||
@interface LineJumper : NSObject
|
||||
{
|
||||
IBOutlet NSTextField *lineField;
|
||||
IBOutlet NSButton *goToButton;
|
||||
}
|
||||
|
||||
+ (id)sharedInstance;
|
||||
|
||||
- (NSPanel *)linePanel;
|
||||
|
||||
/* Gets the first responder and returns it if it's an NSTextView */
|
||||
- (NSTextView<CodeEditorView> *)editorViewToUse;
|
||||
|
||||
/* panel UI methods */
|
||||
- (IBAction)goToLine:(id)sender;
|
||||
|
||||
@end
|
72
Modules/Editors/ProjectCenter/LineJumper.m
Normal file
72
Modules/Editors/ProjectCenter/LineJumper.m
Normal file
|
@ -0,0 +1,72 @@
|
|||
#import "LineJumper.h"
|
||||
|
||||
static id sharedLineJumper = nil;
|
||||
|
||||
@implementation LineJumper
|
||||
|
||||
+ (id)sharedInstance
|
||||
{
|
||||
if (!sharedLineJumper)
|
||||
{
|
||||
sharedLineJumper = [[self allocWithZone:[[NSApplication sharedApplication] zone]] init];
|
||||
}
|
||||
return sharedLineJumper;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if (!(self = [super init])) return nil;
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidActivate:) name:NSApplicationDidBecomeActiveNotification object:[NSApplication sharedApplication]];
|
||||
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addWillDeactivate:) name:NSApplicationWillResignActiveNotification object:[NSApplication sharedApplication]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadUI
|
||||
{
|
||||
if (!lineField)
|
||||
{
|
||||
if (![NSBundle loadNibNamed:@"LineJumper" owner:self])
|
||||
{
|
||||
NSLog(@"Failed to load LineJumper.nib");
|
||||
NSBeep();
|
||||
}
|
||||
if (self == sharedLineJumper)
|
||||
[[lineField window] setFrameAutosaveName:@"GoTo Line"];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSTextView<CodeEditorView> *)editorViewToUse
|
||||
{
|
||||
id tv = [[NSApp mainWindow] firstResponder];
|
||||
if([tv conformsToProtocol:@protocol(CodeEditorView)])
|
||||
return tv;
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSPanel *)linePanel {
|
||||
if (!lineField)
|
||||
[self loadUI];
|
||||
return (NSPanel *)[lineField window];
|
||||
}
|
||||
|
||||
- (void)orderFrontLinePanel:(id)sender
|
||||
{
|
||||
NSPanel *panel = [self linePanel];
|
||||
[lineField selectText:nil];
|
||||
[panel makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
- (IBAction)goToLine:(id)sender
|
||||
{
|
||||
NSUInteger line;
|
||||
NSTextView<CodeEditorView> *cev;
|
||||
|
||||
line = (NSUInteger)[lineField integerValue];
|
||||
cev = [self editorViewToUse];
|
||||
if (cev)
|
||||
{
|
||||
[cev goToLineNumber:line];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#import "PCEditor.h"
|
||||
#import "SyntaxHighlighter.h"
|
||||
#import "LineJumper.h"
|
||||
|
||||
static inline float my_abs(float aValue)
|
||||
{
|
||||
|
@ -623,7 +624,10 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
|
|||
|
||||
- (void)performGoToLinePanelAction:(id)sender
|
||||
{
|
||||
NSLog(@"perform go to line!");
|
||||
LineJumper *lj;
|
||||
|
||||
lj = [LineJumper sharedInstance];
|
||||
[lj orderFrontLinePanel:self];
|
||||
}
|
||||
|
||||
- (void)goToLineNumber:(NSUInteger)lineNumber
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"goToLine:"
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
LineJumper = {
|
||||
Actions = (
|
||||
"goToLine:"
|
||||
);
|
||||
Outlets = (
|
||||
lineField,
|
||||
goToButton
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
}
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue