Move GoToLine to the View akin to the NSTextView find panel and declare it in the editor view protocol.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@38031 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Riccardo Mottola 2014-08-03 22:03:38 +00:00
parent 7fc6faaddc
commit a7673e0ac3
7 changed files with 62 additions and 28 deletions

View file

@ -1,3 +1,13 @@
2014-08-04 Riccardo Mottola <rm@gnu.org>
* English.lproj/ProjectCenter.gorm
* Headers/Protocols/CodeEditorView.h
* Modules/Editors/ProjectCenter/PCEditor.m
* Modules/Editors/ProjectCenter/PCEditorView.h
* Modules/Editors/ProjectCenter/PCEditorView.m
Move GoToLine to the View akin to the NSTextView find panel and
declare it in the editor view protocol.
2014-08-03 German Arias <germanandre@gmx.es>
* Modules/Editors/ProjectCenter/PCEditor.m: Don't use

View file

@ -7,8 +7,7 @@
"findNext:",
"findPrevious:",
"findShowPanel:",
"openGoToLinePanel:",
"newAction:"
"performGoToLinePanelAction:"
);
Super = NSObject;
};

View file

@ -1,7 +1,7 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
Copyright (C) 2010 Free Software Foundation
Copyright (C) 2010-2014 Free Software Foundation
Authors: Riccardo Mottola
@ -30,4 +30,7 @@
- (NSObject <CodeEditor> *)editor;
- (void)performGoToLinePanelAction:(id)sender;
- (void)goToLineNumber:(NSUInteger)lineNumber;
@end

View file

@ -990,30 +990,8 @@
- (void)scrollToLineNumber:(NSUInteger)lineNumber
{
NSUInteger offset;
NSUInteger i;
NSString *line;
NSEnumerator *e;
NSArray *lines;
NSRange range;
lines = [[_intEditorView string] componentsSeparatedByString: @"\n"];
e = [lines objectEnumerator];
for (offset = 0, i = 1;
(line = [e nextObject]) != nil && i < lineNumber;
i++, offset += [line length] + 1);
if (line != nil)
{
range = NSMakeRange(offset, [line length]);
}
else
{
range = NSMakeRange([[_intEditorView string] length], 0);
}
[_intEditorView setSelectedRange:range];
[_intEditorView scrollRangeToVisible:range];
[_intEditorView goToLineNumber:lineNumber];
[_extEditorView goToLineNumber:lineNumber];
}
@end

View file

@ -4,7 +4,7 @@
Interface declaration of the EditorTextView class for the
ProjectManager application.
Copyright (C) 2005-2010 Free Software Foundation
Copyright (C) 2005-2014 Free Software Foundation
Saso Kiselkov
Riccardo Mottola
@ -50,4 +50,10 @@
- (NSRect)selectionRect;
// =====
// CodeEditorView protocol
// =====
- (void)performGoToLinePanelAction:(id)sender;
- (void)goToLineNumber:(NSUInteger)lineNumber;
@end

View file

@ -616,4 +616,42 @@ static int ComputeIndentingOffset(NSString * string, unsigned int start)
return _insertionPointRect;
}
- (void)usesFindPanel
{
return YES;
}
- (void)performGoToLinePanelAction:(id)sender
{
NSLog(@"perform go to line!");
}
- (void)goToLineNumber:(NSUInteger)lineNumber
{
NSUInteger offset;
NSUInteger i;
NSString *line;
NSEnumerator *e;
NSArray *lines;
NSRange range;
lines = [[self string] componentsSeparatedByString: @"\n"];
e = [lines objectEnumerator];
for (offset = 0, i = 1;
(line = [e nextObject]) != nil && i < lineNumber;
i++, offset += [line length] + 1);
if (line != nil)
{
range = NSMakeRange(offset, [line length]);
}
else
{
range = NSMakeRange([[self string] length], 0);
}
[self setSelectedRange:range];
[self scrollRangeToVisible:range];
}
@end