this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

implemented tabs vs spaces

+71 -8
+71 -8
src/studio/editors/code.c
··· 220 220 221 221 s32 count = 0; 222 222 while (count < tab_size) { 223 - drawChar(tic, ' ', x, y, color, code->altFont); 223 + drawChar(tic, '\t', x, y, color, code->altFont); 224 224 count++; 225 225 if (x / getFontWidth(code) % tab_size == 0) 226 226 break; ··· 1449 1449 update(code); 1450 1450 } 1451 1451 1452 + static bool useSpacesForTab(Code* code) { 1453 + enum TabMode tabmode = getConfig(code->studio)->options.tabMode; 1454 + 1455 + 1456 + if (tabmode == TAB_SPACE) 1457 + return true; 1458 + else if (tabmode == TAB_TAB) 1459 + return false; 1460 + else { //auto mode 1461 + tic_mem* tic = code->tic; 1462 + const tic_script_config* config = tic_core_script_config(tic); 1463 + if (config->id == 20 || config->id == 13) //python or moonscript 1464 + return true; 1465 + return false; 1466 + } 1467 + } 1468 + 1469 + 1470 + static s32 insertTab(Code* code, char* line_start, char* pos) { 1471 + if (useSpacesForTab(code)) { 1472 + s32 tab_size = getConfig(code->studio)->options.tabSize; 1473 + s32 count = 0; 1474 + 1475 + while(count < tab_size) { 1476 + insertCode(code, pos++, " "); 1477 + count++; 1478 + if ((pos - line_start) % tab_size == 0) 1479 + break; 1480 + } 1481 + 1482 + return count; 1483 + } else { 1484 + insertCode(code, pos, "\t"); 1485 + return 1; 1486 + } 1487 + } 1488 + 1489 + //has no effect is pos is not a valid tab character 1490 + static s32 removeTab(Code* code, char* line_start, char* pos) { 1491 + if (useSpacesForTab(code)) { 1492 + s32 tab_size = getConfig(code->studio)->options.tabSize; 1493 + s32 count = 0; 1494 + 1495 + while(count < tab_size) { 1496 + if (*pos != ' ') 1497 + break; 1498 + deleteCode(code, pos, pos+1); 1499 + count++; 1500 + } 1501 + 1502 + return count; 1503 + } else if (*pos == '\t' || *pos == ' ') { 1504 + deleteCode(code, pos, pos+1); 1505 + return 1; 1506 + } 1507 + } 1508 + 1452 1509 static void doTab(Code* code, bool shift, bool crtl) 1453 1510 { 1454 1511 char* cursor_position = code->cursor.position; ··· 1479 1536 { 1480 1537 if(*line == '\t' || *line == ' ') 1481 1538 { 1482 - deleteCode(code, line, line + 1); 1483 - end--; 1539 + end -= removeTab(code, line, line); 1484 1540 changed = true; 1485 1541 } 1486 1542 } 1487 1543 else 1488 1544 { 1489 - insertCode(code, line, "\t"); 1490 - end++; 1491 - 1545 + end += insertTab(code, line, line); 1492 1546 changed = true; 1493 1547 } 1494 1548 ··· 1498 1552 1499 1553 if(changed) { 1500 1554 1501 - if(has_selection) { 1555 + if(has_selection) 1556 + { 1502 1557 code->cursor.position = start; 1503 1558 code->cursor.selection = end; 1504 1559 } 1505 1560 else if (start <= end) code->cursor.position = end; 1506 1561 1507 1562 history(code); 1563 + updateColumn(code); 1508 1564 parseSyntaxColor(code); 1509 1565 } 1510 1566 } 1511 - else inputSymbolBase(code, '\t'); 1567 + else 1568 + { 1569 + char* line = getLineByPos(code, code->cursor.position); 1570 + code->cursor.position += insertTab(code, line, code->cursor.position); 1571 + history(code); 1572 + updateColumn(code); 1573 + parseSyntaxColor(code); 1574 + } 1512 1575 } 1513 1576 1514 1577 // Add a block-ending keyword or symbol, and put the cursor in the line between.