[news.software.anu-news] Idea for SEARCH and imbedded <tab> problems

fac2@dayton.saic.com (Earle Ake) (02/23/90)

>>BUG NOTICE:  Situation:  You do a "SEARCH blahblah" and the word
>>"blahblah" is highlighted.  If a TAB occurs before that word, the
>>wrong part of the screen is highlighted.
>     
>NEWS knows the character offset of the start of the target text, but this may
>not necessarily be the SMG displayed column because of the tabs.
>     
>I must admit that I knew of this problem, but made the decision that it was
>less (and faster) code to assume that offset = display column in all cases.
>     
>Is there code which can get the correct display column without large additional
>code blocks anyone?

I have an idea but since I am not a very good 'C' programmer, I haven't got
it perfected yet.  The idea is to modify NEWSDISPLAY.C such that the line of
text you use to 'search' for the character string is not the string you read 
from the file but is the string that was just written to the screen.  That 
string will NOT have the tabs in it!  I tried to modify your code but it 
doesn'ty work right yet.  I hope you get my idea and finish the modifications.
I did it in FORTRAN and it works just fine!  Here is a code fragment for you
to look at.

From NEWSDISPLAY.C:


  last_screen = smg$cursor_row(&sdid);
  smg$put_with_scroll(&sdid,c$dsc(s),0,0,0,0,0);
  if (str_searching) {
    char *p, str_line[256];

/*
    Now read back the string just output to the virtual display.
    It will be the same string with the <tab> character expanded to spaces
    for us.
*/

    smg$read_from_display(&sdid,&str_line,0,&last_screen);	/* New code */
/*    strcpy(str_line,s); */	/* Original code */
    p = str_line;
    if (!str_case_sensitive) s_to_lower(str_line);
    while (p = strchr(p,*str_target)) {
      if (!strncmp(p,str_target,str_length)) {
        int col = (p - str_line) + 1;

        str_found = 1;
        smg$change_rendition(&sdid,&last_screen,&col,c$rfi(1),&str_length,
                             c$rfi(SMG$M_BOLD),0);

Let me know what you think.

-- 
_____________________________________________________________________________
             ____ ____    ___
Earle Ake   /___ /___/ / /     Science Applications International Corporation
           ____//   / / /__                 Dayton, Ohio
-----------------------------------------------------------------------------
Internet: fac2%dayton.saic.com@uunet.uu.net    uucp: uunet!dayvb!fac2