Changeset 21094
- Timestamp:
- 10/11/08 01:45:28 (5 years ago)
- Location:
- lang/javascript/hsp-on-js/trunk/src
- Files:
-
- 5 modified
-
builtin-funcs.js (modified) (2 diffs)
-
evaluator.js (modified) (1 diff)
-
str-buffer.js (modified) (1 diff)
-
str-value.js (modified) (2 diffs)
-
t.hsp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/hsp-on-js/trunk/src/builtin-funcs.js
r21078 r21094 357 357 this.noteStack.push(buf); 358 358 }, 359 0x23: function noteadd(line, lineNumber, overwrite) { 360 this.scanArgs(arguments, 'sNN'); 361 line = line.toStrValue(); 362 lineNumber = lineNumber ? lineNumber.toIntValue()._value : -1; 363 overwrite = (overwrite ? overwrite.toIntValue()._value : 0) != 0; 364 var note = this.getNote(); 365 var index = note.getValue().lineIndex(lineNumber); 366 if(index == null) { 367 if(lineNumber >= 0) return; 368 var str = note.getValue()._value; 369 index = str.length; 370 if(index != 0) { 371 var c = str.charCodeAt(index - 1); 372 if(c != 0x0d && c != 0x0a) { 373 note.assign(new StrValue(str + "\r\n")); 374 index += 2; 375 } 376 } 377 } 378 if(!overwrite) { 379 note.splice(index, 0, line._value + "\r\n"); 380 return; 381 } 382 var length = note.getValue().lineLength(index); 383 note.splice(index, length, line._value); 384 }, 385 0x24: function notedel(lineNumber) { 386 this.scanArgs(arguments, 'N'); 387 lineNumber = lineNumber ? lineNumber.toIntValue()._value : 0; 388 var note = this.getNote(); 389 var val = note.getValue(); 390 var index = val.lineIndex(lineNumber); 391 if(index == null) return; 392 var length = val.lineLengthIncludeCR(index); 393 note.splice(index, length, ''); 394 }, 359 395 0x27: function randomize(seed) { 360 396 this.scanArgs(arguments, 'N'); … … 371 407 var str = val._value; 372 408 var index = val.lineIndex(lineNumber); 373 if(index == null) index = str.length; 409 if(index == null) { 410 dest.assign(StrValue.EMPTY_STR); 411 return; 412 } 374 413 var length = val.lineLength(index); 375 if(length >= 1 && str.charCodeAt(index + length - 1) == 0x0a) {376 length --;377 }378 if(length >= 1 && str.charCodeAt(index + length - 1) == 0x0d) {379 length --;380 }381 414 dest.assign(new StrValue(str.substr(index, length))); 382 415 } -
lang/javascript/hsp-on-js/trunk/src/evaluator.js
r20933 r21094 206 206 getNote: function getNote() { 207 207 if(this.noteStack.length == 0) { 208 throw new HSPError(ErrorCode.ILLEGAL_FUNCTION );208 throw new HSPError(ErrorCode.ILLEGAL_FUNCTION, 'ノートパッドが選択されていません'); 209 209 } 210 210 return this.noteStack[this.noteStack.length - 1]; -
lang/javascript/hsp-on-js/trunk/src/str-buffer.js
r20926 r21094 56 56 if(this._str.length >= size) return; 57 57 this._str += Utils.strTimes("\0", size - this._str.length); 58 }, 59 splice: function splice(index, length, sub) { 60 var str = this._str; 61 this._str = str.slice(0, index) + sub + str.slice(index + length); 62 this._valCache = null; 58 63 } 59 64 }; -
lang/javascript/hsp-on-js/trunk/src/str-value.js
r21061 r21094 93 93 }, 94 94 lineIndex: function lineIndex(lineNumber) { 95 if(lineNumber < 0) return null; 95 96 var str = this._value; 96 97 var i = 0; … … 112 113 lineLength: function lineLength(index) { 113 114 var str = this._value; 115 return /[\r\n]|$/.exec(str.slice(index)).index; 116 }, 117 lineLengthIncludeCR: function lineLengthIncludeCR(index) { 118 var str = this._value; 114 119 var matched = /\r?\n|\r|$/.exec(str.slice(index)); 115 120 return matched.index + matched[0].length; -
lang/javascript/hsp-on-js/trunk/src/t.hsp
r21078 r21094 1 a = "abcdefg" 2 poke a, 2, "XXX" 3 mes a 4 mes strsize 1 a = "abc\ndefg\nhijkl" 2 notesel a 3 noteadd "123" 4 noteadd "456" 5 noteadd "DEFG", 1, 1 6 notedel 0 7 repeat notemax + 2, -1 8 noteget ln, cnt 9 mes ""+cnt+": <"+ln+">" 10 loop 5 11
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)