about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-24 18:26:19 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-24 18:26:19 -0700
commite648bc9c889978522acb068570d4c87790db9ca1 (patch)
tree1d1dc59d998f08164cadeb54848df215be6acdec /apps/tile
parent1137dd2a997a271761c8da0b7e2be05d977909e1 (diff)
downloadmu-e648bc9c889978522acb068570d4c87790db9ca1.tar.gz
tile: process space in middle of word
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu16
-rw-r--r--apps/tile/gap-buffer.mu6
-rw-r--r--apps/tile/word.mu7
3 files changed, 28 insertions, 1 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 1fc811aa..c60ce3b8 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -434,7 +434,21 @@ $process-sandbox:body: {
       break $process-sandbox:body
     }
     # otherwise split word into two
-    # TODO
+    append-word cursor-word-ah
+    var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path
+    increment-final-element cursor-call-path
+    var next-word-ah/eax: (addr handle word) <- get cursor-word, next
+    var _next-word/eax: (addr word) <- lookup *next-word-ah
+    var next-word/ebx: (addr word) <- copy _next-word
+    {
+      var at-end?/eax: boolean <- cursor-at-end? cursor-word
+      compare at-end?, 0  # false
+      break-if-!=
+      var g/eax: grapheme <- pop-after-cursor cursor-word
+      add-grapheme-to-word next-word, g
+      loop
+    }
+    cursor-to-start next-word
     break $process-sandbox:body
   }
   compare key, 0xe  # ctrl-n
diff --git a/apps/tile/gap-buffer.mu b/apps/tile/gap-buffer.mu
index e694da08..627a6877 100644
--- a/apps/tile/gap-buffer.mu
+++ b/apps/tile/gap-buffer.mu
@@ -216,6 +216,12 @@ fn delete-before-gap _self: (addr gap-buffer) {
   var dummy/eax: grapheme <- pop-grapheme-stack left
 }
 
+fn pop-after-gap _self: (addr gap-buffer) -> result/eax: grapheme {
+  var self/eax: (addr gap-buffer) <- copy _self
+  var right/eax: (addr grapheme-stack) <- get self, right
+  result <- pop-grapheme-stack right
+}
+
 fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> result/eax: boolean {
 $gap-buffer-equal?:body: {
   var self/esi: (addr gap-buffer) <- copy _self
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index 63695ae0..994f3819 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -213,6 +213,13 @@ fn delete-before-cursor _self: (addr word) {
   delete-before-gap data
 }
 
+fn pop-after-cursor _self: (addr word) -> result/eax: grapheme {
+  var self/esi: (addr word) <- copy _self
+  var data-ah/eax: (addr handle gap-buffer) <- get self, scalar-data
+  var data/eax: (addr gap-buffer) <- lookup *data-ah
+  result <- pop-after-gap data
+}
+
 fn delete-next _self: (addr word) {
 $delete-next:body: {
   var self/esi: (addr word) <- copy _self
a id='n260' href='#n260'>260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512