comparison src/if_ruby.c @ 934:e44efb3af0d5 v7.0.060

updated for version 7.0-060
author vimboss
date Wed, 16 Aug 2006 17:35:00 +0000
parents 354ea37841d1
children c82da8beb64a
comparison
equal deleted inserted replaced
933:56609cdae088 934:e44efb3af0d5
642 } 642 }
643 643
644 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str) 644 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
645 { 645 {
646 char *line = STR2CSTR(str); 646 char *line = STR2CSTR(str);
647 #ifdef FEAT_AUTOCMD
648 aco_save_T aco; 647 aco_save_T aco;
649 #else
650 buf_T *save_curbuf = curbuf;
651 #endif
652 648
653 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL) 649 if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
654 { 650 {
655 #ifdef FEAT_AUTOCMD
656 /* set curwin/curbuf for "buf" and save some things */ 651 /* set curwin/curbuf for "buf" and save some things */
657 aucmd_prepbuf(&aco, buf); 652 aucmd_prepbuf(&aco, buf);
658 #else
659 curbuf = buf;
660 curwin->w_buffer = buf;
661 #endif
662 653
663 if (u_savesub(n) == OK) { 654 if (u_savesub(n) == OK) {
664 ml_replace(n, (char_u *)line, TRUE); 655 ml_replace(n, (char_u *)line, TRUE);
665 changed(); 656 changed();
666 #ifdef SYNTAX_HL 657 #ifdef SYNTAX_HL
667 syn_changed(n); /* recompute syntax hl. for this line */ 658 syn_changed(n); /* recompute syntax hl. for this line */
668 #endif 659 #endif
669 } 660 }
670 661
671 #ifdef FEAT_AUTOCMD
672 /* restore curwin/curbuf and a few other things */ 662 /* restore curwin/curbuf and a few other things */
673 aucmd_restbuf(&aco); 663 aucmd_restbuf(&aco);
674 /* Careful: autocommands may have made "buf" invalid! */ 664 /* Careful: autocommands may have made "buf" invalid! */
675 #else 665
676 curwin->w_buffer = save_curbuf;
677 curbuf = save_curbuf;
678 #endif
679 update_curbuf(NOT_VALID); 666 update_curbuf(NOT_VALID);
680 } 667 }
681 else 668 else
682 { 669 {
683 rb_raise(rb_eIndexError, "index %d out of buffer", n); 670 rb_raise(rb_eIndexError, "index %d out of buffer", n);
697 684
698 static VALUE buffer_delete(VALUE self, VALUE num) 685 static VALUE buffer_delete(VALUE self, VALUE num)
699 { 686 {
700 buf_T *buf = get_buf(self); 687 buf_T *buf = get_buf(self);
701 long n = NUM2LONG(num); 688 long n = NUM2LONG(num);
702 #ifdef FEAT_AUTOCMD
703 aco_save_T aco; 689 aco_save_T aco;
704 #else
705 buf_T *save_curbuf = curbuf;
706 #endif
707 690
708 if (n > 0 && n <= buf->b_ml.ml_line_count) 691 if (n > 0 && n <= buf->b_ml.ml_line_count)
709 { 692 {
710 #ifdef FEAT_AUTOCMD
711 /* set curwin/curbuf for "buf" and save some things */ 693 /* set curwin/curbuf for "buf" and save some things */
712 aucmd_prepbuf(&aco, buf); 694 aucmd_prepbuf(&aco, buf);
713 #else
714 curbuf = buf;
715 curwin->w_buffer = buf;
716 #endif
717 695
718 if (u_savedel(n, 1) == OK) { 696 if (u_savedel(n, 1) == OK) {
719 ml_delete(n, 0); 697 ml_delete(n, 0);
720 698
721 /* Changes to non-active buffers should properly refresh 699 /* Changes to non-active buffers should properly refresh
723 deleted_lines_mark(n, 1L); 701 deleted_lines_mark(n, 1L);
724 702
725 changed(); 703 changed();
726 } 704 }
727 705
728 #ifdef FEAT_AUTOCMD
729 /* restore curwin/curbuf and a few other things */ 706 /* restore curwin/curbuf and a few other things */
730 aucmd_restbuf(&aco); 707 aucmd_restbuf(&aco);
731 /* Careful: autocommands may have made "buf" invalid! */ 708 /* Careful: autocommands may have made "buf" invalid! */
732 #else 709
733 curwin->w_buffer = save_curbuf;
734 curbuf = save_curbuf;
735 #endif
736 update_curbuf(NOT_VALID); 710 update_curbuf(NOT_VALID);
737 } 711 }
738 else 712 else
739 { 713 {
740 rb_raise(rb_eIndexError, "index %d out of buffer", n); 714 rb_raise(rb_eIndexError, "index %d out of buffer", n);
745 static VALUE buffer_append(VALUE self, VALUE num, VALUE str) 719 static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
746 { 720 {
747 buf_T *buf = get_buf(self); 721 buf_T *buf = get_buf(self);
748 char *line = STR2CSTR(str); 722 char *line = STR2CSTR(str);
749 long n = NUM2LONG(num); 723 long n = NUM2LONG(num);
750 #ifdef FEAT_AUTOCMD
751 aco_save_T aco; 724 aco_save_T aco;
752 #else
753 buf_T *save_curbuf = curbuf;
754 #endif
755 725
756 if (n >= 0 && n <= buf->b_ml.ml_line_count && line != NULL) 726 if (n >= 0 && n <= buf->b_ml.ml_line_count && line != NULL)
757 { 727 {
758 #ifdef FEAT_AUTOCMD
759 /* set curwin/curbuf for "buf" and save some things */ 728 /* set curwin/curbuf for "buf" and save some things */
760 aucmd_prepbuf(&aco, buf); 729 aucmd_prepbuf(&aco, buf);
761 #else
762 curbuf = buf;
763 curwin->w_buffer = buf;
764 #endif
765 730
766 if (u_inssub(n + 1) == OK) { 731 if (u_inssub(n + 1) == OK) {
767 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE); 732 ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
768 733
769 /* Changes to non-active buffers should properly refresh screen 734 /* Changes to non-active buffers should properly refresh screen
771 appended_lines_mark(n, 1L); 736 appended_lines_mark(n, 1L);
772 737
773 changed(); 738 changed();
774 } 739 }
775 740
776 #ifdef FEAT_AUTOCMD
777 /* restore curwin/curbuf and a few other things */ 741 /* restore curwin/curbuf and a few other things */
778 aucmd_restbuf(&aco); 742 aucmd_restbuf(&aco);
779 /* Careful: autocommands may have made "buf" invalid! */ 743 /* Careful: autocommands may have made "buf" invalid! */
780 #else 744
781 curwin->w_buffer = save_curbuf;
782 curbuf = save_curbuf;
783 #endif
784 update_curbuf(NOT_VALID); 745 update_curbuf(NOT_VALID);
785 } 746 }
786 else { 747 else {
787 rb_raise(rb_eIndexError, "index %d out of buffer", n); 748 rb_raise(rb_eIndexError, "index %d out of buffer", n);
788 } 749 }