Revision: 4393
http://skim-app.svn.sourceforge.net/skim-app/?rev=4393&view=rev
Author: hofman
Date: 2008-08-13 12:29:27 +0000 (Wed, 13 Aug 2008)
Log Message:
-----------
Consistently use 0-based line numbers for pdf-sync-tex in code and 1-based in
AppleScript or passed to a script.
Modified Paths:
--------------
trunk/SKApplication.m
trunk/SKLine.h
trunk/SKLine.m
trunk/SKPDFDocument.m
trunk/SKPDFSyncRecord.m
trunk/SKPDFSynchronizer.m
trunk/Skim.sdef
Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKApplication.m 2008-08-13 12:29:27 UTC (rev 4393)
@@ -117,7 +117,7 @@
[self presentError:error];
if ([[NSFileManager defaultManager] fileExistsAtPath:source] &&
[document respondsToSelector:@selector(synchronizer)])
- [[document synchronizer]
findPageAndLocationForLine:[lineNumber intValue] inFile:source];
+ [[document synchronizer] findPageAndLocationForLine:MAX(0,
[lineNumber intValue] - 1) inFile:source];
} else {
[command setScriptErrorNumber:NSArgumentsWrongScriptError];
Modified: trunk/SKLine.h
===================================================================
--- trunk/SKLine.h 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKLine.h 2008-08-13 12:29:27 UTC (rev 4393)
@@ -44,4 +44,5 @@
}
- (id)initWithLine:(int)aLine;
- (int)line;
+- (int)index;
@end
Modified: trunk/SKLine.m
===================================================================
--- trunk/SKLine.m 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKLine.m 2008-08-13 12:29:27 UTC (rev 4393)
@@ -57,4 +57,8 @@
return line;
}
+- (int)index {
+ return line + 1;
+}
+
@end
Modified: trunk/SKPDFDocument.m
===================================================================
--- trunk/SKPDFDocument.m 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKPDFDocument.m 2008-08-13 12:29:27 UTC (rev 4393)
@@ -1459,7 +1459,7 @@
break;
nextChar = NSMaxRange(range) < [cmdString length] ? [cmdString
characterAtIndex:NSMaxRange(range)] : 0;
if ([[NSCharacterSet letterCharacterSet]
characterIsMember:nextChar] == NO) {
- NSString *lineString = [NSString stringWithFormat:@"%d", line];
+ NSString *lineString = [NSString stringWithFormat:@"%d", line
+ 1];
[cmdString replaceCharactersInRange:range
withString:lineString];
range.length = [lineString length];
}
Modified: trunk/SKPDFSyncRecord.m
===================================================================
--- trunk/SKPDFSyncRecord.m 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKPDFSyncRecord.m 2008-08-13 12:29:27 UTC (rev 4393)
@@ -47,7 +47,7 @@
pageIndex = NSNotFound;
point = NSZeroPoint;
file = nil;
- line = 0;
+ line = -1;
}
return self;
}
Modified: trunk/SKPDFSynchronizer.m
===================================================================
--- trunk/SKPDFSynchronizer.m 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/SKPDFSynchronizer.m 2008-08-13 12:29:27 UTC (rev 4393)
@@ -393,7 +393,7 @@
[sc scanInt:NULL];
record = [records recordForIndex:recordIndex];
[record setFile:file];
- [record setLine:line + 1];
+ [record setLine:line];
[[lines objectForKey:file] addObject:record];
}
} else if (ch == 'p') {
@@ -457,7 +457,7 @@
return rv;
}
-- (BOOL)pdfsyncFindFileLine:(int *)line file:(NSString **)file
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds
atPageIndex:(unsigned int)pageIndex {
+- (BOOL)pdfsyncFindFileLine:(int *)linePtr file:(NSString **)filePtr
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds
atPageIndex:(unsigned int)pageIndex {
BOOL rv = NO;
if (pageIndex < [pages count]) {
@@ -510,15 +510,15 @@
}
if (record) {
- *line = [record line];
- *file = [record file];
+ *linePtr = [record line];
+ *filePtr = [record file];
rv = YES;
}
}
return rv;
}
-- (BOOL)pdfsyncFindPage:(unsigned int *)pageIndex location:(NSPoint *)point
forLine:(int)line inFile:(NSString *)file {
+- (BOOL)pdfsyncFindPage:(unsigned int *)pageIndexPtr location:(NSPoint
*)pointPtr forLine:(int)line inFile:(NSString *)file {
BOOL rv = NO;
if ([lines objectForKey:file]) {
@@ -559,8 +559,8 @@
}
if (record) {
- *pageIndex = [record pageIndex];
- *point = [record point];
+ *pageIndexPtr = [record pageIndex];
+ *pointPtr = [record point];
rv = YES;
}
}
@@ -591,28 +591,28 @@
return rv;
}
-- (BOOL)synctexFindFileLine:(int *)line file:(NSString **)file
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds
atPageIndex:(unsigned int)pageIndex {
+- (BOOL)synctexFindFileLine:(int *)linePtr file:(NSString **)filePtr
forLocation:(NSPoint)point inRect:(NSRect)rect pageBounds:(NSRect)bounds
atPageIndex:(unsigned int)pageIndex {
BOOL rv = NO;
if (synctex_edit_query(scanner, (int)pageIndex + 1, point.x,
NSMaxY(bounds) - point.y) > 0) {
synctex_node_t node = synctex_next_result(scanner);
if (node) {
- *line = synctex_node_line(node);
- *file = [self
sourceFileForFileSystemRepresentation:synctex_scanner_get_name(scanner,
synctex_node_tag(node)) defaultExtension:SKPDFSynchronizerTexExtension];
+ *linePtr = MAX(synctex_node_line(node), 1) - 1;
+ *filePtr = [self
sourceFileForFileSystemRepresentation:synctex_scanner_get_name(scanner,
synctex_node_tag(node)) defaultExtension:SKPDFSynchronizerTexExtension];
rv = YES;
}
}
return rv;
}
-- (BOOL)synctexFindPage:(unsigned int *)pageIndex location:(NSPoint *)point
forLine:(int)line inFile:(NSString *)file {
+- (BOOL)synctexFindPage:(unsigned int *)pageIndexPtr location:(NSPoint
*)pointPtr forLine:(int)line inFile:(NSString *)file {
BOOL rv = NO;
NSString *filename = [filenames objectForKey:file] ?: [file
lastPathComponent];
- if (synctex_display_query(scanner, [filename fileSystemRepresentation],
line, 0) > 0) {
+ if (synctex_display_query(scanner, [filename fileSystemRepresentation],
line + 1, 0) > 0) {
synctex_node_t node = synctex_next_result(scanner);
if (node) {
unsigned int page = synctex_node_page(node);
- *pageIndex = page > 0 ? page - 1 : page;
- *point = NSMakePoint(synctex_node_visible_h(node),
synctex_node_visible_v(node));
+ *pageIndexPtr = MAX(page, 1u) - 1;
+ *pointPtr = NSMakePoint(synctex_node_visible_h(node),
synctex_node_visible_v(node));
rv = YES;
}
}
Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef 2008-08-13 00:25:10 UTC (rev 4392)
+++ trunk/Skim.sdef 2008-08-13 12:29:27 UTC (rev 4393)
@@ -749,7 +749,7 @@
<cocoa class="SKLine"/>
<property name="index" code="pidx" type="integer" access="r"
description="the line number.">
- <cocoa key="line"/>
+ <cocoa key="index"/>
</property>
</class>
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit