new --cursorpos argument for the location of cursor within the file's contents
This commit is contained in:
parent
fcf57d1d48
commit
caac39c3bf
2 changed files with 9 additions and 2 deletions
|
@ -149,6 +149,8 @@ def parseArguments(argv):
|
||||||
'uses current time by default')
|
'uses current time by default')
|
||||||
parser.add_argument('--lineno', dest='lineno',
|
parser.add_argument('--lineno', dest='lineno',
|
||||||
help='optional line number; current line being edited')
|
help='optional line number; current line being edited')
|
||||||
|
parser.add_argument('--cursorpos', dest='cursorpos',
|
||||||
|
help='optional cursor position in the current file')
|
||||||
parser.add_argument('--notfile', dest='notfile', action='store_true',
|
parser.add_argument('--notfile', dest='notfile', action='store_true',
|
||||||
help='when set, will accept any value for the file. for example, '+
|
help='when set, will accept any value for the file. for example, '+
|
||||||
'a domain name or other item you want to log time towards.')
|
'a domain name or other item you want to log time towards.')
|
||||||
|
@ -326,6 +328,8 @@ def send_heartbeat(project=None, branch=None, stats={}, key=None, targetFile=Non
|
||||||
data['dependencies'] = stats['dependencies']
|
data['dependencies'] = stats['dependencies']
|
||||||
if stats.get('lineno'):
|
if stats.get('lineno'):
|
||||||
data['lineno'] = stats['lineno']
|
data['lineno'] = stats['lineno']
|
||||||
|
if stats.get('cursorpos'):
|
||||||
|
data['cursorpos'] = stats['cursorpos']
|
||||||
if isWrite:
|
if isWrite:
|
||||||
data['is_write'] = isWrite
|
data['is_write'] = isWrite
|
||||||
if project:
|
if project:
|
||||||
|
@ -428,7 +432,8 @@ def main(argv=None):
|
||||||
|
|
||||||
if os.path.isfile(args.targetFile) or args.notfile:
|
if os.path.isfile(args.targetFile) or args.notfile:
|
||||||
|
|
||||||
stats = get_file_stats(args.targetFile, notfile=args.notfile, lineno=args.lineno)
|
stats = get_file_stats(args.targetFile, notfile=args.notfile,
|
||||||
|
lineno=args.lineno, cursorpos=args.cursorpos)
|
||||||
|
|
||||||
project = None
|
project = None
|
||||||
if not args.notfile:
|
if not args.notfile:
|
||||||
|
|
|
@ -86,13 +86,14 @@ def number_lines_in_file(file_name):
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
||||||
def get_file_stats(file_name, notfile=False, lineno=None):
|
def get_file_stats(file_name, notfile=False, lineno=None, cursorpos=None):
|
||||||
if notfile:
|
if notfile:
|
||||||
stats = {
|
stats = {
|
||||||
'language': None,
|
'language': None,
|
||||||
'dependencies': [],
|
'dependencies': [],
|
||||||
'lines': None,
|
'lines': None,
|
||||||
'lineno': lineno,
|
'lineno': lineno,
|
||||||
|
'cursorpos': cursorpos,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
language, lexer = guess_language(file_name)
|
language, lexer = guess_language(file_name)
|
||||||
|
@ -103,5 +104,6 @@ def get_file_stats(file_name, notfile=False, lineno=None):
|
||||||
'dependencies': dependencies,
|
'dependencies': dependencies,
|
||||||
'lines': number_lines_in_file(file_name),
|
'lines': number_lines_in_file(file_name),
|
||||||
'lineno': lineno,
|
'lineno': lineno,
|
||||||
|
'cursorpos': cursorpos,
|
||||||
}
|
}
|
||||||
return stats
|
return stats
|
||||||
|
|
Loading…
Reference in a new issue