Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js |
— | — | @@ -165,6 +165,19 @@ |
166 | 166 | return new es.Range( 0, this.content.getLength() ); |
167 | 167 | }; |
168 | 168 | |
| 169 | +es.ParagraphBlock.prototype.getLineFromOffset = function( offset ) { |
| 170 | + var line; |
| 171 | + |
| 172 | + for ( var i = 0; i < this.flow.lines.length; i++ ) { |
| 173 | + line = this.flow.lines[i]; |
| 174 | + if ( offset >= line.range.start && offset < line.range.end ) { |
| 175 | + break; |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + return line; |
| 180 | +}; |
| 181 | + |
169 | 182 | /* Registration */ |
170 | 183 | |
171 | 184 | /** |
Index: trunk/parsers/wikidom/lib/es/es.Surface.js |
— | — | @@ -144,6 +144,24 @@ |
145 | 145 | |
146 | 146 | es.Surface.prototype.onKeyDown = function( e ) { |
147 | 147 | switch ( e.keyCode ) { |
| 148 | + case 36: // Home |
| 149 | + this.initialHorizontalCursorPosition = null; |
| 150 | + var line = this.location.block.getLineFromOffset( this.location.offset ); |
| 151 | + this.location = new es.Location( this.location.block, line.range.start ); |
| 152 | + this.cursor.show( |
| 153 | + this.location.block.getPosition( this.location.offset ), |
| 154 | + this.location.block.$.offset() |
| 155 | + ); |
| 156 | + break; |
| 157 | + case 35: // End |
| 158 | + this.initialHorizontalCursorPosition = null; |
| 159 | + var line = this.location.block.getLineFromOffset( this.location.offset ); |
| 160 | + this.location = new es.Location( this.location.block, line.range.end-1 ); |
| 161 | + this.cursor.show( |
| 162 | + this.location.block.getPosition( this.location.offset ), |
| 163 | + this.location.block.$.offset() |
| 164 | + ); |
| 165 | + break; |
148 | 166 | case 16: // Shift |
149 | 167 | this.keyboard.keys.shift = true; |
150 | 168 | if ( !this.keyboard.selecting ) { |