Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js |
— | — | @@ -29,7 +29,8 @@ |
30 | 30 | $: $( '<div class="es-surfaceView-cursor"></div>' ).appendTo( this.$ ), |
31 | 31 | interval: null, |
32 | 32 | offset: null, |
33 | | - initialLeft: null |
| 33 | + initialLeft: null, |
| 34 | + initialBias: false |
34 | 35 | }; |
35 | 36 | this.keyboard = { |
36 | 37 | selecting: false, |
— | — | @@ -112,8 +113,6 @@ |
113 | 114 | } ); |
114 | 115 | }; |
115 | 116 | |
116 | | -es.SurfaceView.boundaryTest = /([ \-\t\r\n\f])/; |
117 | | - |
118 | 117 | es.SurfaceView.prototype.onMouseDown = function( e ) { |
119 | 118 | var position = es.Position.newFromEventPagePosition( e ), |
120 | 119 | offset = this.documentView.getOffsetFromEvent( e ), |
— | — | @@ -209,29 +208,19 @@ |
210 | 209 | ); |
211 | 210 | } else if ( instruction === 'up' || instruction === 'down' ) { |
212 | 211 | // ... |
213 | | - } else if ( instruction === 'home' ) { |
214 | | - if ( wasLeftBias ) { |
215 | | - this.showCursor( |
216 | | - this.documentView.getRenderedLineRangeFromOffset( |
217 | | - this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, -1 ) |
218 | | - ).start |
219 | | - ); |
| 212 | + } else if ( instruction === 'home' || instruction === 'end' ) { |
| 213 | + var offset; |
| 214 | + if ( this.cursor.initialBias ) { |
| 215 | + offset = this.documentView.getModel().getRelativeContentOffset( |
| 216 | + this.cursor.offset, -1 ); |
220 | 217 | } else { |
221 | | - this.showCursor( this.documentView.getRenderedLineRangeFromOffset( this.cursor.offset ).start ); |
| 218 | + offset = this.cursor.offset; |
222 | 219 | } |
223 | | - } else if ( instruction === 'end' ) { |
224 | | - if ( !wasLeftBias ) { |
| 220 | + if ( instruction === 'home' ) { |
225 | 221 | this.showCursor( |
226 | | - this.documentView.getRenderedLineRangeFromOffset( this.cursor.offset ).end, |
227 | | - true |
228 | | - ); |
229 | | - } else { |
230 | | - this.showCursor( |
231 | | - this.documentView.getRenderedLineRangeFromOffset( |
232 | | - this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, -1 ) |
233 | | - ).end, |
234 | | - true |
235 | | - ); |
| 222 | + this.documentView.getRenderedLineRangeFromOffset( offset ).start, false ); |
| 223 | + } else { // end |
| 224 | + this.showCursor( this.documentView.getRenderedLineRangeFromOffset( offset ).end, true ); |
236 | 225 | } |
237 | 226 | } |
238 | 227 | }; |
— | — | @@ -242,15 +231,9 @@ |
243 | 232 | * @method |
244 | 233 | * @param offset {Integer} Position to show the cursor at |
245 | 234 | */ |
246 | | -var wasLeftBias = false; |
247 | 235 | es.SurfaceView.prototype.showCursor = function( offset, leftBias ) { |
248 | 236 | if ( typeof offset !== 'undefined' ) { |
249 | | - if ( leftBias ) { |
250 | | - wasLeftBias = true; |
251 | | - } else { |
252 | | - wasLeftBias = false; |
253 | | - } |
254 | | - console.log('showCursor: ' + offset + ' leftBias: ' + leftBias); |
| 237 | + this.cursor.initialBias = leftBias ? true : false; |
255 | 238 | this.cursor.offset = offset; |
256 | 239 | var position = this.documentView.getRenderedPositionFromOffset( |
257 | 240 | this.cursor.offset, leftBias |