539 ]. |
539 ]. |
540 ]. |
540 ]. |
541 ! |
541 ! |
542 |
542 |
543 addTextEntryFieldForCode |
543 addTextEntryFieldForCode |
544 |initial box infoLabel helpButton errMessageField checkCodeAction| |
544 |initial box panel infoLabel helpButton errMessageField checkCodeAction| |
545 |
545 |
546 box := View new. |
546 box := View new. |
547 box extent:(600 @ 200). |
547 box extent:(600 @ 200). |
548 |
548 |
549 codeField := CodeView in:box. |
549 panel := VariableHorizontalPanel in:box. |
550 codeField origin:0.0@0.0 corner:(0.75@1.0). |
550 panel origin:0.0@0.0 corner:(1.0@1.0). |
551 |
551 |
552 infoLabel := Label in:box. |
552 codeField := CodeView in:panel. |
553 infoLabel origin:0.75@0.0 corner:(1.0@1.0). |
553 "/ codeField origin:0.0@0.0 corner:(0.75@1.0). |
|
554 |
|
555 infoLabel := Label in:panel. |
|
556 "/ infoLabel origin:0.75@0.0 corner:(1.0@1.0). |
554 infoLabel font:(codeField font). |
557 infoLabel font:(codeField font). |
|
558 infoLabel adjust:#left. |
555 infoLabel label:'MetaPatterns: |
559 infoLabel label:'MetaPatterns: |
556 |
560 |
557 ' , '`' allBold , ' = meta |
561 ' , '`' allBold , ' = meta |
558 |
562 |
559 ' , '@' allBold , ' = list/any |
563 ' , '@' allBold , ' = list/any |
563 ' , '`#n' allBold , ' any lit |
567 ' , '`#n' allBold , ' any lit |
564 ' , '`v' allBold , ' any var |
568 ' , '`v' allBold , ' any var |
565 ' , '`@e' allBold , ' any expr |
569 ' , '`@e' allBold , ' any expr |
566 '. |
570 '. |
567 |
571 |
568 helpButton := Button label:(resources string:'Pattern Help') in:box. |
572 panel relativeCorners:#(0.6 1.0). |
569 helpButton layout:((LayoutOrigin fractionalFromPoint:0.75@1.0) |
573 |
|
574 helpButton := Button label:(resources string:'Pattern Help') in:infoLabel. |
|
575 helpButton layout:((AlignmentOrigin fractionalFromPoint:0.5@1.0) |
570 leftOffset:2 |
576 leftOffset:2 |
571 topOffset:helpButton preferredExtent y negated). |
577 topOffset:helpButton preferredExtent y negated; |
|
578 leftAlignmentFraction:0.5 topAlignmentFraction:0). |
572 helpButton topInset:0.75@1.0. |
579 helpButton topInset:0.75@1.0. |
573 helpButton action:[self showHelpOnCodePatterns]. |
580 helpButton action:[self showHelpOnCodePatterns]. |
|
581 |
574 |
582 |
575 self addComponent:box tabable:true. |
583 self addComponent:box tabable:true. |
576 errMessageField := (self addTextLabel:'') adjust:#left. |
584 errMessageField := (self addTextLabel:'') adjust:#left. |
577 errMessageField level:-1. |
585 errMessageField level:-1. |
578 self addCheckBox:(resources string:'Method') on:self isMethodHolder. |
586 self addCheckBox:(resources string:'Method') on:self isMethodHolder. |
592 checkCodeIn:codeField notifying:errMessageField |
600 checkCodeIn:codeField notifying:errMessageField |
593 |codeString tree errAction| |
601 |codeString tree errAction| |
594 |
602 |
595 codeString := codeField contents asString string. |
603 codeString := codeField contents asString string. |
596 errAction := [:str :pos | |
604 errAction := [:str :pos | |
597 |line col badLine| |
605 |line col badLine| |
598 |
606 |
599 line := codeField lineOfCharacterPosition:pos. |
607 line := codeField lineOfCharacterPosition:pos. |
600 col := (codeField colOfCharacterPosition:pos) max:1. |
608 col := (codeField colOfCharacterPosition:pos) max:1. |
601 |
609 |
602 badLine := (codeField listAt:line) ? '' |
610 badLine := (codeField listAt:line) ? '' |
603 . col <= badLine size size ifTrue:[ |
611 . col <= badLine size size ifTrue:[ |
604 codeField |
612 codeField |
605 listAt:line |
613 listAt:line |
606 put:(badLine asText |
614 put:(badLine asText |
607 emphasisAt:col |
615 emphasisAt:col |
608 put:(UserPreferences current unknownIdentifierEmphasis)). |
616 put:(UserPreferences current unknownIdentifierEmphasis)). |
609 "/ codeField selectFromCharacterPosition:pos to:pos. |
617 "/ codeField selectFromCharacterPosition:pos to:pos. |
610 ]. |
618 ]. |
611 errMessageField label:('[',line printString,'] ',str). |
619 errMessageField label:('line: ',line printString,' ',str). |
612 codeField requestFocus. |
620 errMessageField backgroundColor:Color red. |
613 nil. |
621 codeField requestFocus. |
614 ]. |
622 nil. |
|
623 ]. |
615 |
624 |
616 isMethodHolder value ifTrue:[ |
625 isMethodHolder value ifTrue:[ |
617 tree := RBParser parseRewriteMethod:codeString onError: errAction. |
626 tree := RBParser parseRewriteMethod:codeString onError: errAction. |
618 ] ifFalse:[ |
627 ] ifFalse:[ |
619 tree := RBParser parseRewriteExpression:codeString onError: errAction. |
628 tree := RBParser parseRewriteExpression:codeString onError: errAction. |
620 ]. |
629 ]. |
621 tree notNil ifTrue:[ errMessageField label:nil ]. |
630 tree notNil ifTrue:[ |
|
631 errMessageField backgroundColor:View defaultViewBackgroundColor. |
|
632 errMessageField label:nil |
|
633 ]. |
622 codeField modifiedChannel setValue:false. |
634 codeField modifiedChannel setValue:false. |
623 ! |
635 ! |
624 |
636 |
625 getClassesAndMethodsFor:where |
637 getClassesAndMethodsFor:where |
626 where == #everywhere ifTrue:[ |
638 where == #everywhere ifTrue:[ |