Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js |
— | — | @@ -90,17 +90,27 @@ |
91 | 91 | this.keyboard.keys.command = true; |
92 | 92 | break; |
93 | 93 | case 36: // Home |
| 94 | + this.moveCursor( 'home' ); |
94 | 95 | break; |
95 | 96 | case 35: // End |
| 97 | + this.moveCursor( 'end' ); |
96 | 98 | break; |
97 | 99 | case 37: // Left arrow |
98 | | - this.moveCursor( 'left' ); |
| 100 | + if ( this.keyboard.keys.command ) { |
| 101 | + this.moveCursor( 'home' ); |
| 102 | + } else { |
| 103 | + this.moveCursor( 'left' ); |
| 104 | + } |
99 | 105 | break; |
100 | 106 | case 38: // Up arrow |
101 | 107 | this.moveCursor( 'up' ); |
102 | 108 | break; |
103 | 109 | case 39: // Right arrow |
104 | | - this.moveCursor( 'right' ); |
| 110 | + if ( this.keyboard.keys.command ) { |
| 111 | + this.moveCursor( 'end' ); |
| 112 | + } else { |
| 113 | + this.moveCursor( 'right' ); |
| 114 | + } |
105 | 115 | break; |
106 | 116 | case 40: // Down arrow |
107 | 117 | this.moveCursor( 'down' ); |
— | — | @@ -119,13 +129,24 @@ |
120 | 130 | // |
121 | 131 | }; |
122 | 132 | |
123 | | -es.SurfaceView.prototype.moveCursor = function( direction ) { |
124 | | - if ( direction === 'left') { |
| 133 | +es.SurfaceView.prototype.moveCursor = function( instruction ) { |
| 134 | + if ( instruction === 'left') { |
125 | 135 | this.showCursor( this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, -1 ) ); |
126 | | - } else if ( direction === 'right' ) { |
| 136 | + } else if ( instruction === 'right' ) { |
127 | 137 | this.showCursor( this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, 1 ) ); |
128 | | - } else if ( direction === 'up' || direction === 'down' ) { |
| 138 | + } else if ( instruction === 'up' || instruction === 'down' ) { |
129 | 139 | // ... |
| 140 | + } else if ( instruction === 'home' ) { |
| 141 | + this.showCursor( this.documentView.getRenderedLineRange( this.cursor.offset ).start ); |
| 142 | + } else if ( instruction === 'end' ) { |
| 143 | + var end = this.documentView.getRenderedLineRange( this.cursor.offset ).end |
| 144 | + var data = this.documentView.getModel().data; |
| 145 | + if ( es.DocumentModel.isContentData( data, end ) ) { |
| 146 | + while( data[ end - 1] === ' ' ) { |
| 147 | + end--; |
| 148 | + } |
| 149 | + } |
| 150 | + this.showCursor( end ); |
130 | 151 | } |
131 | 152 | }; |
132 | 153 | |