Mercurial > vim
comparison src/gui_photon.c @ 3054:eb4972982bfe v7.3.299
updated for version 7.3.299
Problem: Source code not in Vim style.
Solution: Adjust the style. (Elias Diem)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 07 Sep 2011 19:09:01 +0200 |
parents | 43b1d031e302 |
children | 51ce22ba89d1 |
comparison
equal
deleted
inserted
replaced
3053:85b03f36f589 | 3054:eb4972982bfe |
---|---|
533 string, | 533 string, |
534 len, | 534 len, |
535 &src_taken, | 535 &src_taken, |
536 buf, | 536 buf, |
537 6, | 537 6, |
538 &dst_made ); | 538 &dst_made); |
539 | 539 |
540 add_to_input_buf( buf, dst_made ); | 540 add_to_input_buf(buf, dst_made); |
541 } | 541 } |
542 else | 542 else |
543 { | 543 { |
544 add_to_input_buf( string, len ); | 544 add_to_input_buf(string, len); |
545 } | 545 } |
546 | 546 |
547 return Pt_CONSUME; | 547 return Pt_CONSUME; |
548 } | 548 } |
549 len = 0; | 549 len = 0; |
550 #endif | 550 #endif |
551 ch = key->key_cap; | 551 ch = key->key_cap; |
552 if( ch < 0xff ) | 552 if (ch < 0xff) |
553 { | 553 { |
554 /* FIXME: is this the right thing to do? */ | 554 /* FIXME: is this the right thing to do? */ |
555 if( modifiers & MOD_MASK_CTRL ) | 555 if (modifiers & MOD_MASK_CTRL) |
556 { | 556 { |
557 modifiers &= ~MOD_MASK_CTRL; | 557 modifiers &= ~MOD_MASK_CTRL; |
558 | 558 |
559 if( ( ch >= 'a' && ch <= 'z' ) || | 559 if ((ch >= 'a' && ch <= 'z') || |
560 ch == '[' || | 560 ch == '[' || |
561 ch == ']' || | 561 ch == ']' || |
562 ch == '\\' ) | 562 ch == '\\') |
563 ch = Ctrl_chr( ch ); | 563 ch = Ctrl_chr(ch); |
564 else if( ch == '2' ) | 564 else if (ch == '2') |
565 ch = NUL; | 565 ch = NUL; |
566 else if( ch == '6' ) | 566 else if (ch == '6') |
567 ch = 0x1e; | 567 ch = 0x1e; |
568 else if( ch == '-' ) | 568 else if (ch == '-') |
569 ch = 0x1f; | 569 ch = 0x1f; |
570 else | 570 else |
571 modifiers |= MOD_MASK_CTRL; | 571 modifiers |= MOD_MASK_CTRL; |
572 } | 572 } |
573 | 573 |
574 if( modifiers & MOD_MASK_ALT ) | 574 if (modifiers & MOD_MASK_ALT) |
575 { | 575 { |
576 ch = Meta( ch ); | 576 ch = Meta(ch); |
577 modifiers &= ~MOD_MASK_ALT; | 577 modifiers &= ~MOD_MASK_ALT; |
578 } | 578 } |
579 } | 579 } |
580 else | 580 else |
581 { | 581 { |
584 } | 584 } |
585 else | 585 else |
586 modifiers &= ~MOD_MASK_SHIFT; | 586 modifiers &= ~MOD_MASK_SHIFT; |
587 } | 587 } |
588 | 588 |
589 ch = simplify_key( ch, &modifiers ); | 589 ch = simplify_key(ch, &modifiers); |
590 if( modifiers ) | 590 if (modifiers) |
591 { | 591 { |
592 string[ len++ ] = CSI; | 592 string[ len++ ] = CSI; |
593 string[ len++ ] = KS_MODIFIER; | 593 string[ len++ ] = KS_MODIFIER; |
594 string[ len++ ] = modifiers; | 594 string[ len++ ] = modifiers; |
595 } | 595 } |
596 | 596 |
597 if( IS_SPECIAL( ch ) ) | 597 if (IS_SPECIAL(ch)) |
598 { | 598 { |
599 string[ len++ ] = CSI; | 599 string[ len++ ] = CSI; |
600 string[ len++ ] = K_SECOND( ch ); | 600 string[ len++ ] = K_SECOND(ch); |
601 string[ len++ ] = K_THIRD( ch ); | 601 string[ len++ ] = K_THIRD(ch); |
602 } | 602 } |
603 else | 603 else |
604 { | 604 { |
605 string[ len++ ] = ch; | 605 string[ len++ ] = ch; |
606 } | 606 } |
617 /* Turn CSI into K_CSI. */ | 617 /* Turn CSI into K_CSI. */ |
618 string[ len++ ] = KS_EXTRA; | 618 string[ len++ ] = KS_EXTRA; |
619 string[ len++ ] = KE_CSI; | 619 string[ len++ ] = KE_CSI; |
620 } | 620 } |
621 | 621 |
622 if( len > 0 ) | 622 if (len > 0) |
623 { | 623 { |
624 add_to_input_buf( string, len ); | 624 add_to_input_buf(string, len); |
625 return Pt_CONSUME; | 625 return Pt_CONSUME; |
626 } | 626 } |
627 } | 627 } |
628 | 628 |
629 return Pt_CONTINUE; | 629 return Pt_CONTINUE; |
630 } | 630 } |
631 | 631 |
632 static int | 632 static int |
633 gui_ph_handle_mouse( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | 633 gui_ph_handle_mouse(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
634 { | 634 { |
635 PhPointerEvent_t *pointer; | 635 PhPointerEvent_t *pointer; |
636 PhRect_t *pos; | 636 PhRect_t *pos; |
637 int button = 0, repeated_click, modifiers = 0x0; | 637 int button = 0, repeated_click, modifiers = 0x0; |
638 short mouse_x, mouse_y; | 638 short mouse_x, mouse_y; |
639 | 639 |
640 pointer = PhGetData( info->event ); | 640 pointer = PhGetData(info->event); |
641 pos = PhGetRects( info->event ); | 641 pos = PhGetRects(info->event); |
642 | 642 |
643 gui_mch_mousehide( MOUSE_SHOW ); | 643 gui_mch_mousehide(MOUSE_SHOW); |
644 | 644 |
645 /* | 645 /* |
646 * Coordinates need to be relative to the base window, | 646 * Coordinates need to be relative to the base window, |
647 * not relative to the vimTextArea widget | 647 * not relative to the vimTextArea widget |
648 */ | 648 */ |
649 mouse_x = pos->ul.x + gui.border_width; | 649 mouse_x = pos->ul.x + gui.border_width; |
650 mouse_y = pos->ul.y + gui.border_width; | 650 mouse_y = pos->ul.y + gui.border_width; |
651 | 651 |
652 if( info->event->type == Ph_EV_PTR_MOTION_NOBUTTON ) | 652 if (info->event->type == Ph_EV_PTR_MOTION_NOBUTTON) |
653 { | 653 { |
654 gui_mouse_moved( mouse_x, mouse_y ); | 654 gui_mouse_moved(mouse_x, mouse_y); |
655 return Pt_CONTINUE; | 655 return Pt_CONTINUE; |
656 } | 656 } |
657 | 657 |
658 if( pointer->key_mods & Pk_KM_Shift ) | 658 if (pointer->key_mods & Pk_KM_Shift) |
659 modifiers |= MOUSE_SHIFT; | 659 modifiers |= MOUSE_SHIFT; |
660 if( pointer->key_mods & Pk_KM_Ctrl ) | 660 if (pointer->key_mods & Pk_KM_Ctrl) |
661 modifiers |= MOUSE_CTRL; | 661 modifiers |= MOUSE_CTRL; |
662 if( pointer->key_mods & Pk_KM_Alt ) | 662 if (pointer->key_mods & Pk_KM_Alt) |
663 modifiers |= MOUSE_ALT; | 663 modifiers |= MOUSE_ALT; |
664 | 664 |
665 /* | 665 /* |
666 * FIXME More than one button may be involved, but for | 666 * FIXME More than one button may be involved, but for |
667 * now just deal with one | 667 * now just deal with one |
668 */ | 668 */ |
669 if( pointer->buttons & Ph_BUTTON_SELECT ) | 669 if (pointer->buttons & Ph_BUTTON_SELECT) |
670 button = MOUSE_LEFT; | 670 button = MOUSE_LEFT; |
671 | 671 |
672 if( pointer->buttons & Ph_BUTTON_MENU ) | 672 if (pointer->buttons & Ph_BUTTON_MENU) |
673 { | 673 { |
674 button = MOUSE_RIGHT; | 674 button = MOUSE_RIGHT; |
675 /* Need the absolute coordinates for the popup menu */ | 675 /* Need the absolute coordinates for the popup menu */ |
676 abs_mouse.x = pointer->pos.x; | 676 abs_mouse.x = pointer->pos.x; |
677 abs_mouse.y = pointer->pos.y; | 677 abs_mouse.y = pointer->pos.y; |
678 } | 678 } |
679 | 679 |
680 if( pointer->buttons & Ph_BUTTON_ADJUST ) | 680 if (pointer->buttons & Ph_BUTTON_ADJUST) |
681 button = MOUSE_MIDDLE; | 681 button = MOUSE_MIDDLE; |
682 | 682 |
683 /* Catch a real release (not phantom or other releases */ | 683 /* Catch a real release (not phantom or other releases */ |
684 if( info->event->type == Ph_EV_BUT_RELEASE ) | 684 if (info->event->type == Ph_EV_BUT_RELEASE) |
685 button = MOUSE_RELEASE; | 685 button = MOUSE_RELEASE; |
686 | 686 |
687 if( info->event->type & Ph_EV_PTR_MOTION_BUTTON ) | 687 if (info->event->type & Ph_EV_PTR_MOTION_BUTTON) |
688 button = MOUSE_DRAG; | 688 button = MOUSE_DRAG; |
689 | 689 |
690 #if 0 | 690 #if 0 |
691 /* Vim doesn't use button repeats */ | 691 /* Vim doesn't use button repeats */ |
692 if( info->event->type & Ph_EV_BUT_REPEAT ) | 692 if (info->event->type & Ph_EV_BUT_REPEAT) |
693 button = MOUSE_DRAG; | 693 button = MOUSE_DRAG; |
694 #endif | 694 #endif |
695 | 695 |
696 /* Don't do anything if it is one of the phantom mouse release events */ | 696 /* Don't do anything if it is one of the phantom mouse release events */ |
697 if( ( button != MOUSE_RELEASE ) || | 697 if ((button != MOUSE_RELEASE) || |
698 ( info->event->subtype == Ph_EV_RELEASE_REAL ) ) | 698 (info->event->subtype == Ph_EV_RELEASE_REAL)) |
699 { | 699 { |
700 repeated_click = (pointer->click_count >= 2) ? TRUE : FALSE; | 700 repeated_click = (pointer->click_count >= 2) ? TRUE : FALSE; |
701 | 701 |
702 gui_send_mouse_event( button , mouse_x, mouse_y, repeated_click, modifiers ); | 702 gui_send_mouse_event(button , mouse_x, mouse_y, repeated_click, modifiers); |
703 } | 703 } |
704 | 704 |
705 return Pt_CONTINUE; | 705 return Pt_CONTINUE; |
706 } | 706 } |
707 | 707 |
708 /* Handle a focus change of the PtRaw widget */ | 708 /* Handle a focus change of the PtRaw widget */ |
709 static int | 709 static int |
710 gui_ph_handle_focus( PtWidget_t *widget, void *data, PtCallbackInfo_t *info ) | 710 gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info) |
711 { | 711 { |
712 if( info->reason == Pt_CB_LOST_FOCUS ) | 712 if (info->reason == Pt_CB_LOST_FOCUS) |
713 { | 713 { |
714 PtRemoveEventHandler( gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, | 714 PtRemoveEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, |
715 gui_ph_handle_mouse, NULL ); | 715 gui_ph_handle_mouse, NULL); |
716 | 716 |
717 gui_mch_mousehide( MOUSE_SHOW ); | 717 gui_mch_mousehide(MOUSE_SHOW); |
718 } | 718 } |
719 else | 719 else |
720 { | 720 { |
721 PtAddEventHandler( gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, | 721 PtAddEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON, |
722 gui_ph_handle_mouse, NULL ); | 722 gui_ph_handle_mouse, NULL); |
723 } | 723 } |
724 return Pt_CONTINUE; | 724 return Pt_CONTINUE; |
725 } | 725 } |
726 | 726 |
727 static void | 727 static void |
728 gui_ph_handle_raw_draw( PtWidget_t *widget, PhTile_t *damage ) | 728 gui_ph_handle_raw_draw(PtWidget_t *widget, PhTile_t *damage) |
729 { | 729 { |
730 PhRect_t *r; | 730 PhRect_t *r; |
731 PhPoint_t offset; | 731 PhPoint_t offset; |
732 PhPoint_t translation; | 732 PhPoint_t translation; |
733 | 733 |
734 if( is_ignore_draw == TRUE ) | 734 if (is_ignore_draw == TRUE) |
735 return; | 735 return; |
736 | 736 |
737 PtSuperClassDraw( PtBasic, widget, damage ); | 737 PtSuperClassDraw(PtBasic, widget, damage); |
738 PgGetTranslation( &translation ); | 738 PgGetTranslation(&translation); |
739 PgClearTranslation(); | 739 PgClearTranslation(); |
740 | 740 |
741 #if 0 | 741 #if 0 |
742 /* | 742 /* |
743 * This causes some weird problems, with drawing being done from | 743 * This causes some weird problems, with drawing being done from |
748 * in places where it shouldn't | 748 * in places where it shouldn't |
749 */ | 749 */ |
750 out_flush(); | 750 out_flush(); |
751 #endif | 751 #endif |
752 | 752 |
753 PtWidgetOffset( widget, &offset ); | 753 PtWidgetOffset(widget, &offset); |
754 PhTranslatePoint( &offset, PtWidgetPos( gui.vimTextArea, NULL ) ); | 754 PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL)); |
755 | 755 |
756 #if 1 | 756 #if 1 |
757 /* Redraw individual damage regions */ | 757 /* Redraw individual damage regions */ |
758 if( damage->next != NULL ) | 758 if (damage->next != NULL) |
759 damage = damage->next; | 759 damage = damage->next; |
760 | 760 |
761 while( damage != NULL ) | 761 while(damage != NULL) |
762 { | 762 { |
763 r = &damage->rect; | 763 r = &damage->rect; |
764 gui_redraw( | 764 gui_redraw( |
765 r->ul.x - offset.x, r->ul.y - offset.y, | 765 r->ul.x - offset.x, r->ul.y - offset.y, |
766 r->lr.x - r->ul.x + 1, | 766 r->lr.x - r->ul.x + 1, |
767 r->lr.y - r->ul.y + 1 ); | 767 r->lr.y - r->ul.y + 1); |
768 damage = damage->next; | 768 damage = damage->next; |
769 } | 769 } |
770 #else | 770 #else |
771 /* Redraw the rectangle that covers all the damaged regions */ | 771 /* Redraw the rectangle that covers all the damaged regions */ |
772 r = &damage->rect; | 772 r = &damage->rect; |
773 gui_redraw( | 773 gui_redraw( |
774 r->ul.x - offset.x, r->ul.y - offset.y, | 774 r->ul.x - offset.x, r->ul.y - offset.y, |
775 r->lr.x - r->ul.x + 1, | 775 r->lr.x - r->ul.x + 1, |
776 r->lr.y - r->ul.y + 1 ); | 776 r->lr.y - r->ul.y + 1); |
777 #endif | 777 #endif |
778 | 778 |
779 PgSetTranslation( &translation, 0 ); | 779 PgSetTranslation(&translation, 0); |
780 } | 780 } |
781 | 781 |
782 static int | 782 static int |
783 gui_ph_handle_pulldown_menu( | 783 gui_ph_handle_pulldown_menu( |
784 PtWidget_t *widget, | 784 PtWidget_t *widget, |
785 void *data, | 785 void *data, |
786 PtCallbackInfo_t *info ) | 786 PtCallbackInfo_t *info) |
787 { | 787 { |
788 if( data != NULL ) | 788 if (data != NULL) |
789 { | 789 { |
790 vimmenu_T *menu = (vimmenu_T *) data; | 790 vimmenu_T *menu = (vimmenu_T *) data; |
791 | 791 |
792 PtPositionMenu( menu->submenu_id, NULL ); | 792 PtPositionMenu(menu->submenu_id, NULL); |
793 PtRealizeWidget( menu->submenu_id ); | 793 PtRealizeWidget(menu->submenu_id); |
794 } | 794 } |
795 | 795 |
796 return Pt_CONTINUE; | 796 return Pt_CONTINUE; |
797 } | 797 } |
798 | 798 |