@@ -8934,7 +8934,6 @@ f_screenchar(typval_T *argvars, typval_T *rettv)
89348934{
89358935 int row ;
89368936 int col ;
8937- int off ;
89388937 int c ;
89398938
89408939 if (in_vim9script ()
@@ -8948,11 +8947,9 @@ f_screenchar(typval_T *argvars, typval_T *rettv)
89488947 c = -1 ;
89498948 else
89508949 {
8951- off = LineOffset [row ] + col ;
8952- if (enc_utf8 && ScreenLinesUC [off ] != 0 )
8953- c = ScreenLinesUC [off ];
8954- else
8955- c = ScreenLines [off ];
8950+ char_u buf [MB_MAXBYTES + 1 ];
8951+ screen_getbytes (row , col , buf , NULL );
8952+ c = (* mb_ptr2char )(buf );
89568953 }
89578954 rettv -> vval .v_number = c ;
89588955}
@@ -8965,7 +8962,6 @@ f_screenchars(typval_T *argvars, typval_T *rettv)
89658962{
89668963 int row ;
89678964 int col ;
8968- int off ;
89698965 int c ;
89708966 int i ;
89718967
@@ -8982,18 +8978,18 @@ f_screenchars(typval_T *argvars, typval_T *rettv)
89828978 if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns )
89838979 return ;
89848980
8985- off = LineOffset [row ] + col ;
8986- if (enc_utf8 && ScreenLinesUC [off ] != 0 )
8987- c = ScreenLinesUC [off ];
8981+ char_u buf [MB_MAXBYTES + 1 ];
8982+ screen_getbytes (row , col , buf , NULL );
8983+ int pcc [MAX_MCO ];
8984+ if (enc_utf8 )
8985+ c = utfc_ptr2char (buf , pcc );
89888986 else
8989- c = ScreenLines [ off ] ;
8987+ c = ( * mb_ptr2char )( buf ) ;
89908988 list_append_number (rettv -> vval .v_list , (varnumber_T )c );
89918989
89928990 if (enc_utf8 )
8993-
8994- for (i = 0 ; i < Screen_mco && ScreenLinesC [i ][off ] != 0 ; ++ i )
8995- list_append_number (rettv -> vval .v_list ,
8996- (varnumber_T )ScreenLinesC [i ][off ]);
8991+ for (i = 0 ; i < Screen_mco && pcc [i ] != 0 ; ++ i )
8992+ list_append_number (rettv -> vval .v_list , (varnumber_T )pcc [i ]);
89978993}
89988994
89998995/*
@@ -9024,11 +9020,7 @@ f_screenstring(typval_T *argvars, typval_T *rettv)
90249020{
90259021 int row ;
90269022 int col ;
9027- int off ;
9028- int c ;
9029- int i ;
90309023 char_u buf [MB_MAXBYTES + 1 ];
9031- int buflen = 0 ;
90329024
90339025 rettv -> vval .v_string = NULL ;
90349026 rettv -> v_type = VAR_STRING ;
@@ -9043,18 +9035,7 @@ f_screenstring(typval_T *argvars, typval_T *rettv)
90439035 if (row < 0 || row >= screen_Rows || col < 0 || col >= screen_Columns )
90449036 return ;
90459037
9046- off = LineOffset [row ] + col ;
9047- if (enc_utf8 && ScreenLinesUC [off ] != 0 )
9048- c = ScreenLinesUC [off ];
9049- else
9050- c = ScreenLines [off ];
9051- buflen += mb_char2bytes (c , buf );
9052-
9053- if (enc_utf8 && ScreenLinesUC [off ] != 0 )
9054- for (i = 0 ; i < Screen_mco && ScreenLinesC [i ][off ] != 0 ; ++ i )
9055- buflen += mb_char2bytes (ScreenLinesC [i ][off ], buf + buflen );
9056-
9057- buf [buflen ] = NUL ;
9038+ screen_getbytes (row , col , buf , NULL );
90589039 rettv -> vval .v_string = vim_strsave (buf );
90599040}
90609041
@@ -9433,7 +9414,7 @@ f_searchpos(typval_T *argvars, typval_T *rettv)
94339414
94349415/*
94359416 * Set the cursor or mark position.
9436- * If ' charpos' is TRUE, then use the column number as a character offset.
9417+ * If " charpos" is TRUE, then use the column number as a character offset.
94379418 * Otherwise use the column number as a byte offset.
94389419 */
94399420 static void
0 commit comments