Changeset 3804
- Timestamp:
- Jan 11, 2020, 10:05:57 PM (5 years ago)
- Location:
- trunk/src/netlabs/macros
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/netlabs/macros/alt_1.e ¶
r3803 r3804 788 788 endif 789 789 -- Redetermine LeftLineStr 790 n = .col 790 791 if .col <> CurCol then 791 792 LeftLineStr = leftstr( LineStr, .col - 1) 793 n = .col - 1 792 794 endif 793 795 -- End of repositioning cursor when cursor was on search string 794 796 795 if IsLiteral( L eftLineStr, leftstr( RightLineStr, 1)) then797 if IsLiteral( LineStr, n) then 796 798 SeparatorList = "'"||'"' 797 799 else -
TabularUnified trunk/src/netlabs/macros/stdprocs.e ¶
r3803 r3804 1440 1440 1441 1441 ; --------------------------------------------------------------------------- 1442 ; Count quotes in LeftLine, e.g. in part of line before the cursor. 1443 ; If odd, then char at cursor pos. must belong to a string. 1444 ; Syntax: fLiteral = IsLiteral( [<LeftLine>[, <Quotes>]]) 1445 ; fLiteral is 0 | 1. 1446 ; <Quotes> is a space-separated list of quote chars. 1447 ; Default value is " '. 1448 defproc IsLiteral 1449 LeftLineStr = arg( 1) 1450 if LeftLineStr = '' then 1451 LeftLineStr = leftstr( textline( .line), .col) 1452 endif 1453 CurChar = arg( 2) 1454 if CurChar = '' then 1455 CurChar = substr( textline( .line), .col, 1) 1456 endif 1442 ; Finds quote environment in LineStr around position n. The default quote 1443 ; chars are double quote and single quote. Returns begin and end position 1444 ; of the found quotes. 1445 defproc FindLiteralPos( LineStr, n) 1446 RevLineStr = reverse( LineStr) 1447 LineLen = length( LineStr) 1448 pStart = n 1449 pRevStart = LineLen - pStart + 1 1450 1451 DQ = '"' 1452 SQ = "'" 1457 1453 Quotes = arg( 3) 1458 1454 if Quotes = '' then 1459 Quotes = '"' || " '" 1460 endif 1461 1462 1455 Quotes = DQ SQ 1456 endif 1457 1458 pBegin = 0 1459 pEnd = 0 1460 1461 do w = 1 to words( Quotes) 1462 if pStart < 1 then 1463 leave 1464 endif 1465 if pStart > LineLen then 1466 leave 1467 endif 1468 Quote = word( Quotes, w) 1469 1470 -- Handle position pStart on a quote char 1471 if substr( LineStr, pStart, 1) = Quote then 1472 -- Count number of quotes until start position is reached 1473 numQ = 0 1474 pStartQ = 1 1475 do forever 1476 pQ = pos( Quote, LineStr, pStartQ) 1477 if pQ = 0 then 1478 leave 1479 elseif pQ > pStart then 1480 leave 1481 endif 1482 numQ = numQ + 1 1483 pStartQ = pQ + 1 1484 enddo 1485 1486 if numQ // 2 = 0 then 1487 -- Even number: pEnd = pStart, advance pRevStart 1488 pEnd = pStart 1489 pRevStart = pRevStart + 1 1490 else 1491 -- Odd number: pBegin = pStart, advance pStart 1492 pBegin = pStart 1493 pStart = pStart + 1 1494 endif 1495 endif 1496 1497 -- Find begin and end 1498 if pBegin = 0 then 1499 pRevBegin = pos( Quote, RevLineStr, pRevStart) 1500 pBegin = LineLen - pRevBegin + 1 1501 endif 1502 if pEnd = 0 then 1503 pEnd = pos( Quote, LineStr, pStart) 1504 endif 1505 1506 -- Ensure to return 0 0 if quote chars were not found 1507 if pBegin > LineLen | pEnd > LineLen | pBegin = 0 | pEnd = 0 then 1508 pBegin = 0 1509 pEnd = 0 1510 endif 1511 1512 if pBegin <> 0 & pEnd <> 0 then 1513 leave 1514 endif 1515 enddo 1516 1517 return pBegin pEnd 1518 1519 ; --------------------------------------------------------------------------- 1520 ; Checks if position n in LineStr is a literal. LineStr must at least be 1521 ; specified up to the end quote char. Uses cursor position if LineStr and n 1522 ; are not specified. Default quote chars are double quote and single quote. 1523 defproc IsLiteral 1463 1524 fLiteral = 0 1464 do w = 1 to words( Quotes) 1465 Quote = word( Quotes, w) 1466 numQ = 0 1467 pStartQ = 1 1468 1469 if CurChar = Quote then 1470 fLiteral = 1 1471 leave 1472 endif 1473 1474 do forever 1475 pQ = pos( Quote, LeftLineStr, pStartQ) 1476 if pQ = 0 then 1477 leave 1478 endif 1479 numQ = numQ + 1 1480 pStartQ = pQ + 1 1481 enddo 1482 1483 if (numQ // 2 <> 0) then 1484 fLiteral = 1 1485 leave 1486 endif 1487 enddo 1525 LineStr = arg( 1) 1526 if LineStr = '' then 1527 LineStr = textline( .line) 1528 endif 1529 n = arg( 2) 1530 if n = '' then 1531 n = .col 1532 endif 1533 Quotes = arg( 3) 1534 1535 FoundPos = FindLiteralPos( LineStr, n, Quotes) 1536 1537 if FoundPos <> '0 0' then 1538 fLiteral = 1 1539 endif 1488 1540 1489 1541 return fLiteral 1490 1542 1491 1543 ; --------------------------------------------------------------------------- 1492 ; Tests whether the "filename" is actually a printer 1493 ; device, so we'll know whether to test printer readiness first. 1494 ; Called by savefile() in SAVELOAD.E. Returns 0 if not, else printer number. 1544 ; Tests whether the "filename" is actually a printer device, so we'll know 1545 ; whether to test printer readiness first. 1546 ; Returns 0 if not, else printer number. 1547 ; Called by savefile() in SAVELOAD.E. 1495 1548 defproc Check_For_Printer( name) 1496 1549 if not name then -
TabularUnified trunk/src/netlabs/macros/tabsspaces.e ¶
r3803 r3804 570 570 571 571 -- Don't process enquoted string 572 if IsLiteral( TmpLineStr , leftstr( RightPart, 1)) then -- TmpLineStr is here only left part before current doublespace572 if IsLiteral( TmpLineStr''RightPart, Col) then -- TmpLineStr is here only left part before current doublespace 573 573 TmpLineStr = TmpLineStr''copies( ' ', SpaceLen) 574 574 Col = Col + SpaceLen … … 703 703 704 704 -- Don't process enquoted string 705 if IsLiteral( LeftLineStr , leftstr( RightLineStr, 1)) then705 if IsLiteral( LeftLineStr''RightLineStr, .col) then 706 706 .col = .col + length( TwoSpc) 707 707 iterate
Note:
See TracChangeset
for help on using the changeset viewer.