Example #1
0
//删除工具行
BOOL RingDockSite::DelLine(LPRINGBARLINEINFO lpline)
{
	if(lpline)
	{
		LinkLine(GetPrevLine(lpline),lpline->m_nextline);
		SetLineEmpty(lpline);
		return TRUE;
	}	
	return FALSE;
}
Example #2
0
/// mSearch()
IPTR mSearch(UNUSED struct IClass *cl, Object *obj, struct MUIP_TextEditor_Search *msg)
{
  struct InstData *data = INST_DATA(cl, obj);
  STRPTR str = msg->SearchString;
  LONG len = strlen(str), step = 0;

  ENTER();

  if(len > 0 && len <= 120)
  {
    BYTE map[256];
    LONG (*StrCmp)(STRPTR, STRPTR, LONG);
    LONG cursor;
    struct line_node *line;

    // if the FromTop flag is set we start the search right from the top
    if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_FromTop))
    {
      cursor = 0;
      line = GetFirstLine(&data->linelist);
    }
    else
    {
      cursor = data->CPos_X;
      line = data->actualline;
    }

    memset(map, len, 256);

    // if a casesensitive search is requested we use a different
    // compare function.
    if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_CaseSensitive))
    {
      StrCmp = Native_strncmp;

      while(*str)
        map[(int)*str++] = step--;
    }
    else
    {
      StrCmp = Utility_strnicmp;
      while(*str)
      {
        map[ToLower(*str)] = step;
        map[ToUpper(*str++)] = step--;
      }
    }

    if(isFlagSet(msg->Flags, MUIF_TextEditor_Search_Backwards))
    {
//D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards  search=%s\n", msg->SearchString);
      if(Enabled(data))
        cursor -= len;

      while(line != NULL)
      {
        LONG lenTmp  = len;
        STRPTR contents = line->line.Contents + cursor - lenTmp+1;
        STRPTR lower = line->line.Contents;

        while(contents >= lower)
        {
//D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards  previous=%ld, contents=%s\n",line, contents);
          if(!StrCmp(contents, msg->SearchString, len))
          {
            LONG startx = contents - line->line.Contents;

//D(DBF_STARTUP, "MUIF_TextEditor_Search_Backwards found\n");

            SimpleMarkText(data, startx, line, startx+len, line);

            RETURN(TRUE);
            return TRUE;
          }
          contents -= 1;
          lenTmp += 1;
        }

        line = GetPrevLine(line);

        if(line != NULL)
          cursor = line->line.Length;
      }
    }
    else
    {
      while(line)
      {
        LONG skip;
        STRPTR contents = line->line.Contents + cursor + len-1;
        STRPTR upper = line->line.Contents + line->line.Length;

        while(contents < upper)
        {
          skip = map[(int)(*contents)];
          contents += skip;

          if(skip <= 0)
          {
            if(!StrCmp(contents, msg->SearchString, len))
            {
              LONG startx = contents - line->line.Contents;

              SimpleMarkText(data, startx, line, startx+len, line);

              RETURN(TRUE);
              return TRUE;
            }
            contents += len;
          }
        }

        cursor = 0;

        line = GetNextLine(line);
      }
    }

  }

  RETURN(FALSE);
  return FALSE;
}