Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: tools/ddbg/lib/terminfo.dart

Issue 69343017: Add support for command-line editing to ddbg. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« tools/ddbg/lib/commando.dart ('K') | « tools/ddbg/lib/commando.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
hausner 2013/11/21 16:12:03 2013
turnidge 2013/11/21 18:25:11 Done.
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:convert';
6 import 'dart:io';
7
8 int _tputGetInteger(String capName) {
9 var result = Process.runSync('tput', ['$capName'], stdoutEncoding:UTF8);
10 if (result.exitCode != 0) {
11 return 0;
12 }
13 return int.parse(result.stdout);
14 }
15
16 String _tputGetSequence(String capName) {
17 var result = Process.runSync('tput', ['$capName'], stdoutEncoding:UTF8);
18 if (result.exitCode != 0) {
19 return '';
20 }
21 return result.stdout;
22 }
23
24 class TermInfo {
25 TermInfo() {
26 resize();
27 }
28
29 int get lines => _lines;
30 int get cols => _cols;
31
32 int _lines;
33 int _cols;
34
35 void resize() {
36 _lines = _tputGetInteger('lines');
37 _cols = _tputGetInteger('cols');
38 }
39
40 // Back one character.
41 String cursorBack = _tputGetSequence('cub1');
hausner 2013/11/21 16:12:03 Any reason why you make lines and cols a readonly
turnidge 2013/11/21 18:25:11 Done.
42
43 // Forward one character.
44 String cursorForward = _tputGetSequence('cuf1');
45
46 // Up one character.
47 String cursorUp = _tputGetSequence('cuu1');
48
49 // Down one character.
50 String cursorDown = _tputGetSequence('cud1');
51
52 // Clear to end of line.
53 String clrEOL = _tputGetSequence('el');
54
55 // Clear screen and home cursor.
56 String clear = _tputGetSequence('clear');
57
58 // Left arrow keypress
59 String keyLeftArrow = _tputGetSequence('kcub1');
60
61 String enterAmMode = _tputGetSequence('smam');
62 String exitAmMode = _tputGetSequence('rmam');
63 }
OLDNEW
« tools/ddbg/lib/commando.dart ('K') | « tools/ddbg/lib/commando.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698