예제 #1
0
int ECvsDiff::BlockCopy (int Append) {
    if (SSBuffer==0) return ErFAIL;
    if (Append) {
        if (SystemClipboard) GetPMClip(0);
    } else SSBuffer->Clear ();
    SSBuffer->BlockMode=bmLine;
    // How to set these two ?
    BFI (SSBuffer,BFI_TabSize)=8;
    BFI (SSBuffer,BFI_ExpandTabs)=0;
    BFI (SSBuffer,BFI_Undo)=0;
    // Go through list of marked lines
    int last=-1,tl=0;
    for (int i=0;i<LineCount;i++) {
        if (Lines[i]->Status&2) {
            // Marked
            if (last!=i-1&&tl) {
                // Gap between this and last marked line
                SSBuffer->InsLine (tl++,0);
            }
            SSBuffer->InsertLine (tl++,strlen (Lines[i]->Msg+2),Lines[i]->Msg+2);
            last=i;
        }
    }
    if (SystemClipboard) PutPMClip (0);
    return ErOK;
}
예제 #2
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::IndentLine(int Row, int Indent) {
    int I, C;
    int Ind = Indent;

    if (Row < 0) return 0;
    if (Row >= RCount) return 0;
    if (Indent < 0) Indent = 0;
    I = LineIndented(Row);
    if (Indent != I) {
        if (I > 0)
            if (DelText(Row, 0, I) == 0) return 0;
        if (Indent > 0) {
            C = 0;
            if (BFI(this, BFI_IndentWithTabs)) {
                char ch = 9;

                while (BFI(this, BFI_TabSize) <= Indent) {
                    if (InsText(Row, C, 1, &ch) == 0) return 0;
                    Indent -= BFI(this, BFI_TabSize);
                    C += BFI(this, BFI_TabSize);
                }
            }
            if (Indent > 0)
                if (InsText(Row, C, Indent, 0) == 0) return 0;
        }
    }
    return Ind - I;
}
예제 #3
0
static int _LNK_CONV SortProc(const void *A, const void *B) {
    int *AA = (int *)A;
    int *BB = (int *)B;
    ELine *LA = SortBuffer->RLine(*AA);
    ELine *LB = SortBuffer->RLine(*BB);
    int rc;

    if (SortMinCol == -1) {
        int lA = LA->Count;
        int lB = LB->Count;

        if (BFI(SortBuffer, BFI_MatchCase) == 1)
            rc = memcmp(LA->Chars, LB->Chars, (lA < lB) ? lA : lB);
        else
            rc = memicmp(LA->Chars, LB->Chars, (lA < lB) ? lA : lB);
        if (rc == 0) {
            if (lA > lB)
                rc = 1;
            else
                rc = -1;
        }
    } else {
        int lA = LA->Count;
        int lB = LB->Count;
        int PA = SortBuffer->CharOffset(LA, SortMinCol);
        int PB = SortBuffer->CharOffset(LB, SortMinCol);

        lA -= PA;
        lB -= PB;
        if (lA < 0 && lB < 0)
            rc = 0;
        else if (lA < 0 && lB > 0)
            rc = -1;
        else if (lA > 0 && lB < 0)
            rc = 1;
        else {
            if (SortMaxCol != -1) {
                if (lA > SortMaxCol - SortMinCol)
                    lA = SortMaxCol - SortMinCol;
                if (lB > SortMaxCol - SortMinCol)
                    lB = SortMaxCol - SortMinCol;
            }
            if (BFI(SortBuffer, BFI_MatchCase) == 1)
                rc = memcmp(LA->Chars+ PA, LB->Chars + PB, (lA < lB) ? lA : lB);
            else
                rc = memicmp(LA->Chars + PA, LB->Chars + PB, (lA < lB) ? lA : lB);
            if (rc == 0) {
                if (lA > lB)
                    rc = 1;
                else
                    rc = -1;
            }
        }
    }

    if (SortReverse)
        return -rc;
    return rc;
}
예제 #4
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::ToggleWordWrap() {
    BFI(this, BFI_WordWrap) = (BFI(this, BFI_WordWrap) + 1) % 3;
    /*Msg(INFO,
        "WordWrap is now %s.",
        (BFI(this, BFI_WordWrap) == 2) ? "AUTO" :
       (BFI(this, BFI_WordWrap) == 1) ? "ON" : "OFF"); */
    return 1;
}
예제 #5
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::MovePrevTab() {
    int P = CP.Col;

    if (P > 0) {
        P = ((P - 1) / BFI(this, BFI_TabSize)) * BFI(this, BFI_TabSize);
        return SetPos(P, CP.Row);
    } else return 0;
}
예제 #6
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::TypeChar(char aCh) { // does abbrev expansion if appropriate
    if (BFI(this, BFI_InsertKillBlock) == 1)
        if (CheckBlock() == 1)
            if (BlockKill() == 0)
                return 0;
    if (ChClass(aCh) == 0 && BFI(this, BFI_Abbreviations) == 1) {
        PELine L = VLine(CP.Row);
        int C, P, P1, C1, Len, R;
        char Str[256];
        EAbbrev *ab;

        R = VToR(CP.Row);
        C = CP.Col;
        P = CharOffset(L, C);
        if (P >= 0 && P <= L->Count) {
            //fprintf(stderr, "TypeChar 1\n");
            P1 = P;
            C1 = ScreenPos(L, P);
            while ((P > 0) && ((ChClass(L->Chars[P - 1]) == 1) || (L->Chars[P - 1] == '_'))) P--;
            Len = P1 - P;
            C = ScreenPos(L, P);
            assert(C1 - C == Len);
            if (Len > 0 && Len < int (sizeof(Str))) {
                //fprintf(stderr, "TypeChar 2\n");
                memcpy(Str, L->Chars + P, Len);
                Str[Len] = 0;
                ab = Mode->FindAbbrev(Str);
                if (ab) {
                    //fprintf(stderr, "TypeChar 3\n");
                    if (ab->Replace != 0) {
                        //fprintf(stderr, "TypeChar 4\n");
                        if (DelText(R, C, C1 - C) == 0)
                            return 0;
                        if (ab->Replace) {
                            //fprintf(stderr, "TypeChar 5 %s <- %s\n", ab->Replace, ab->Match);
                            Len = strlen(ab->Replace);
                            if (InsText(R, C, Len, ab->Replace) == 0)
                                return 0;
                            if (SetPos(C + Len, CP.Row) == 0)
                                return 0;
                        } else {
                            if (SetPos(C, CP.Row) == 0)
                                return 0;
                        }
                    } else {
                        if (((EGUI *)gui)->ExecMacro(View->MView->Win, ab->Cmd) == 0)
                            return 0;
                    }
                }
            }
        }
    }
    return InsertString(&aCh, 1);
}
예제 #7
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::LineCenter() {
    if (LineTrim() == 0)
        return 0;
    int ind = LineIndented(VToR(CP.Row));
    int left = BFI(this, BFI_LeftMargin);
    int right = BFI(this, BFI_RightMargin);
    int len = LineLen();

    //int chs = len - ind;
    int newind = left + ((right - left) - (len - ind)) / 2;
    if (newind < left)
        newind = left;
    return IndentLine(VToR(CP.Row), newind);
}
예제 #8
0
void EBuffer::Rehilit(int ToRow) {
  hlState State;
  int     HilitX;
  PELine  L;
  int     ECol;

  if (StartHilit == -1)                   // all ok
    return;

  if (BFI(this, BFI_MultiLineHilit) == 0) // everything handled in redisplay
    return;

  if (ToRow <= StartHilit)                // will be handled in redisplay
    return;

  if (ToRow >= RCount) ToRow = RCount;

  HilitX = 1;

  while ((StartHilit < RCount) && ((StartHilit < ToRow) || HilitX)) {
    L = RLine(StartHilit);

    HilitX = 0;

    if (StartHilit > 0) State = RLine(StartHilit - 1)->StateE;
    else State = 0;

    if ((BFI(this, BFI_HilitOn) == 1) && (HilitProc != 0)) {
      HilitProc(this, StartHilit, 0, 0, 0, L, State, 0, &ECol);
    } else {
      Hilit_Plain(this, StartHilit, 0, 0, 0, L, State, 0, &ECol);
    }

    if (L->StateE != State) {
      HilitX    = 1;
      L->StateE = State;
    }
    Draw(StartHilit, StartHilit); // ?

    if (StartHilit > EndHilit) EndHilit = StartHilit;

    if (HilitX == 0) // jump over (can we always do this ?)
      if (StartHilit < EndHilit) {
        StartHilit = EndHilit;
      }
    StartHilit++;
  }
}
예제 #9
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::LineNew() {
    if (SplitLine(VToR(CP.Row), CP.Col) == 0)
        return 0;

    if (!MoveDown())
        return 0;

    if (CP.Col > 0) {

        if (!MoveLineStart())
            return 0;

        //int Indent = LineIndented(VToR(CP.Row));

        if (!LineIndent())
            return 0;

        //if (Indent > 0)
        //  if (InsText(Row, C, Indent, 0) == 0)
        //    return 0;

        if (BFI(this, BFI_Trim))
            if (TrimLine(VToR(CP.Row - 1)) == 0)
                return 0;
    }
    return 1;
}
예제 #10
0
int EBuffer::FoldCreate(int Line) { /*FOLD00*/
  int n;

  if (Modify() == 0) return 0;

  if (FindFold(Line) != -1) return 1;  // already exists

  if (BFI(this, BFI_Undo)) {
    if (PushULong(Line) == 0) return 0;

    if (PushUChar(ucFoldCreate) == 0) return 0;
  }

  n = FindNearFold(Line);
  n++;
  FF = (EFold *)realloc((void *)FF, sizeof(EFold) * ((1 + FCount) | 7));
  assert(FF != 0);
  memmove(FF + n + 1, FF + n, sizeof(EFold) * (FCount - n));
  FCount++;
  FF[n].line  = Line;
  FF[n].level = 0;
  FF[n].open  = 1;
  FF[n].flags = 0;
  Draw(Line, Line);
  return 1;
}
예제 #11
0
int EBuffer::SearchReplace(ExState &State, const char *aString, const char *aReplaceString, int Options) {
    char find[MAXSEARCH+1] = "";
    char replace[MAXSEARCH+1] = "";
    int Case = BFI(this, BFI_MatchCase) ? 0 : SEARCH_NCASE;

    if (aString)
        strcpy(find, aString);
    else
        if (State.GetStrParam(View, find, sizeof(find)) == 0)
            if (View->MView->Win->GetStr("Find", sizeof(find), find, HIST_SEARCH) == 0) return 0;
    if (strlen(find) == 0) return 0;
    if (aReplaceString)
        strcpy(replace, aReplaceString);
    else
        if (State.GetStrParam(View, replace, sizeof(replace)) == 0)
            if (View->MView->Win->GetStr("Replace", sizeof(replace), replace, HIST_SEARCH) == 0) return 0;

    LSearch.ok = 0;
    strcpy(LSearch.strSearch, find);
    strcpy(LSearch.strReplace, replace);
    LSearch.Options = Case | (Options & ~SEARCH_NCASE) | SEARCH_ALL | SEARCH_REPLACE;
    LSearch.ok = 1;
    if (Find(LSearch) == 0) return 0;
    return 1;
}
예제 #12
0
int EBuffer::Search(ExState &State, const char *aString, int Options, int /*CanResume*/) {
    char find[MAXSEARCH+1] = "";
    int Case = BFI(this, BFI_MatchCase) ? 0 : SEARCH_NCASE;
    int Next = 0;
    int erc = 0;
    //int Changed;

    if (aString)
        strcpy(find, aString);
    else
        if (State.GetStrParam(View, find, sizeof(find)) == 0)
            if ((erc = View->MView->Win->GetStr("Find", sizeof(find), find, HIST_SEARCH)) == 0) return 0;
    if (strlen(find) == 0) return 0;

    if (erc == 2)
        Case ^= SEARCH_NCASE;

    //if (Changed == 0 && CanResume)
    //    Next |= SEARCH_NEXT;

    LSearch.ok = 0;
    strcpy(LSearch.strSearch, find);
    LSearch.Options = Case | Next | (Options & ~SEARCH_NCASE);
    LSearch.ok = 1;
    if (Find(LSearch) == 0) return 0;
    return 1;
}
예제 #13
0
int EBuffer::BlockUnTab() {
    EPoint B, E;
    ELine *L;
    int O, C;

    AutoExtend = 0;
    if (CheckBlock() == 0) return 0;
    if (RCount <= 0) return 0;
    B = BB;
    E = BE;
    Draw(B.Row, E.Row);
    for (int i = B.Row; i < E.Row; i++) {
        L = RLine(i);
        O = 0;
        C = 0;
        while (O < L->Count) {
            if (L->Chars[O] == '\t') {
                C = NextTab(C, BFI(this, BFI_TabSize));

                if (DelChars(i, O, 1) != 1)
                    return 0;
                if (InsChars(i, O, C - O, 0) != 1)
                    return 0;
                O = C;
            } else {
                O++;
                C++;
            }
        }
    }
    return 1;
}
예제 #14
0
int EBuffer::GetHilitWord(int len, const char *str, ChColor& clr, int IgnCase) {
  char *p;

  if ((Mode == 0) || (Mode->fColorize == 0)) return 0;

  if (len >= CK_MAXLEN) return 0;

  {
    char s[CK_MAXLEN + 1];
    s[CK_MAXLEN] = 0;
    memcpy(s, str, len);
    s[len] = 0;

    if (HilitFindWord(s)) {
      clr = COUNT_CLR + hcPlain_HilitWord;
      return 1;
    }
  }

  if (len < 1) return 0;

  p = Mode->fColorize->Keywords.key[len];

  if (IgnCase) {
    while (p && *p) {
      if (strnicmp(p, str, len) == 0) {
        clr = COUNT_CLR + ((unsigned char *)p)[len];
        return 1;
      }
      p += len + 1;
    }
  } else {
    while (p && *p) {
      if (memcmp(p, str, len) == 0) {
        clr = COUNT_CLR + ((unsigned char *)p)[len];

        // printf("PLEN %d  %d\n", p[len], COUNT_CLR);
        return 1;
      }
      p += len + 1;
    }
  }

  if (len < 128) {
    char s[128];

    memcpy(s, str, len);
    s[len] = 0;

    if (BFI(this, BFI_HilitTags) && TagDefined(s)) {
      // clr = 0x0A;
      clr = CLR_HexNumber; // Mode->fColorize->Colors[];
      return 1;
    }
  }

  return 0;
}
예제 #15
0
파일: c_hilit.cpp 프로젝트: dmcbride/efte
int EBuffer::HilitFindWord(const char *Word) {
    for (int i = 0; i < WordCount; i++) {
        if (BFI(this, BFI_MatchCase) == 1) {
            if (strcmp(Word, WordList[i]) == 0) return 1;
        } else {
            if (stricmp(Word, WordList[i]) == 0) return 1;
        }
    }
    return 0;
}
예제 #16
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::InsertSpacesToTab(int TSize) {
    int P = CP.Col, P1;

    if (BFI(this, BFI_InsertKillBlock) == 1)
        if (CheckBlock() == 1)
            if (BlockKill() == 0)
                return 0;

    if (TSize <= 0)
        TSize = BFI(this, BFI_TabSize);

    P1 = NextTab(P, TSize);
    if (BFI(this, BFI_Insert) == 0) {
        if (CP.Col < LineLen())
            if (DelText(VToR(CP.Row), CP.Col, P1 - P) == 0) return 0;
    }
    if (InsText(VToR(CP.Row), CP.Col, P1 - P, 0) == 0) return 0;
    if (SetPos(P1, CP.Row) == 0) return 0;
    return 1;
}
예제 #17
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::Delete() {
    int Y = VToR(CP.Row);
    if (CheckBlock() == 1 && BFI(this, BFI_DeleteKillBlock)) {
        if (BlockKill() == 0)
            return 0;
    } else if (CP.Col < LineLen()) {
        if (BFI(this, BFI_DeleteKillTab)) {
            int P;
            int C = CP.Col, C1;

            P = CharOffset(RLine(Y), C);
            C1 = ScreenPos(RLine(Y), P + 1);
            if (DelText(Y, C, C1 - C) == 0) return 0;
        } else {
            ELine *L = RLine(Y);
            int C = CharOffset(L, CP.Col);

            if (L->Count > 0 && L->Chars[C] == '\t') {
                /* We're on top of tab character. Skip over all spaces and
                   tabs so that only the last space/tab gets deleted. */
                while (C < L->Count &&
                        (L->Chars[C+1] == '\t' || L->Chars[C+1] == ' ')) C++;
            }

            if (DelText(Y, ScreenPos(L, C), 1) == 0) return 0;
        }
    } else
        if (LineJoin() == 0) return 0;
    if (BFI(this, BFI_WordWrap) == 2) {
        if (DoWrap(0) == 0) return 0;
        if (CP.Col >= LineLen(Y))
            if (CP.Row < VCount - 1) {
                if (SetPos(BFI(this, BFI_LeftMargin), CP.Row + 1) == 0) return 0;
            }
    }
    if (BFI(this, BFI_Trim))
        if (TrimLine(VToR(CP.Row)) == 0)
            return 0;
    return 1;
}
int main(void)
	{
	static struct
		{
		uint32_t	word ;
		int			lsb ;
		int			width ;
		uint32_t	value ;
		} testcase[] =
		{
		{0xFFFFFFFF,  5, 7,  0},
		{0x00000000, 22, 5, -1}
		} ;
	int k ;

	InitializeHardware(HEADER, PROJECT_NAME) ;

	for (;;)
		{
		for (k = 0; k < ENTRIES(testcase); k++)
			{
			uint32_t	word	= testcase[k].word ;
			int			lsb		= testcase[k].lsb ;
			int			width	= testcase[k].width ;
			uint32_t	value	= testcase[k].value ;
			uint32_t	result, answer	= BFI(word, lsb, width, value) ;
			uint32_t    before, after, cycles ;

            before = GetClockCycleCount() ;
			result = BitFieldInsert(word, lsb, width, value) ;
            after  = GetClockCycleCount() ;
            cycles = after - before ;

			printf("   Test Case %d: %08X,%d,%d,%d\n", k+1,
				(unsigned) word, lsb, width, (int) value) ;

			printf("Correct Result: %08X\n", (unsigned) answer) ;

			printf("   Your Result: %08X", (unsigned) result) ;
			if (result != answer) printf(" %s", ERROR_FLAG) ;
			printf("\n") ;

			printf("  Clock Cycles: %lu\n\n", cycles) ;

			WaitForPushButton() ;
			}

		printf("Press button to start over.\n") ;
		WaitForPushButton() ;
		ClearDisplay() ;
		}
	}
예제 #19
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::MoveFirstNonWhite() {
    int C = 0, P = 0;
    PELine L = VLine(CP.Row);

    while (C < L->Count) {
        if (L->Chars[C] == ' ') P++;
        else if (L->Chars[C] == 9) P = NextTab(P, BFI(this, BFI_TabSize));
        else break;
        C++;
    }
    if (SetPos(P, CP.Row) == 0) return 0;
    return 1;
}
예제 #20
0
int EBuffer::FoldOpen(int Line) { /*FOLD00*/
  int f = FindFold(Line);
  int l;
  int level, toplevel;
  int top;

  if (f == -1) return 0;

  if (FF[f].open == 1) return 1;  // already open

  if (Modify() == 0) return 0;

  if (BFI(this, BFI_Undo)) {
    if (PushULong(Line) == 0) return 0;

    if (PushUChar(ucFoldOpen) == 0) return 0;
  }

  FF[f].open = 1;
  top        = FF[f].line;
  toplevel   = FF[f].level;

  //    printf("Fold starts with %d\n", FF[f].line);
  if (ShowRow(FF[f].line) == 0) return 0;

  while (f < FCount) {
    level = FF[f].level;

    if (FF[f].open == 1) {
      // fold is open
      if (f == FCount - 1) {
        for (l = FF[f].line; l < RCount; l++)
          if (l != top) if (ShowRow(l) == 0) return 0;
      } else {
        for (l = FF[f].line; l < FF[f + 1].line; l++)
          if (l != top) if (ShowRow(l) == 0) return 0;
      }
      f++;
    } else { // fold is closed
      // show head line
      if (ShowRow(FF[f].line) == 0) return 0;

      // skip closed folds
      while ((f < FCount) && (level < FF[f + 1].level)) f++;
      f++;
    }

    if ((f < FCount) && (FF[f].level <= toplevel)) break;
  }
  return 1;
}
예제 #21
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::LineIndent() {
    int rc = 1;

    if (BFI(this, BFI_AutoIndent)) {
        int L = VToR(CP.Row);

        switch (BFI(this, BFI_IndentMode)) {
        case INDENT_C:
            rc = Indent_C(this, L, 1);
            break;

        case INDENT_REXX:
            rc = Indent_REXX(this, L, 1);
            break;

        case INDENT_SIMPLE:
            rc = Indent_SIMPLE(this, L, 1);
            break;

        case INDENT_CONTINUE:
            rc = Indent_Continue(this, L, 1);
            break;

        default:
            rc = Indent_Plain(this, L, 1);
            break;
        }
    }

    if (rc == 0) return 0;

    if (BFI(this, BFI_Trim))
        if (TrimLine(VToR(CP.Row)) == 0) return 0;

    return 1;
}
예제 #22
0
파일: c_hilit.cpp 프로젝트: dmcbride/efte
int EBuffer::HilitRemoveWord(const char *Word) {
    for (int i = 0; i < WordCount; i++) {
        if (BFI(this, BFI_MatchCase) == 1) {
            if (strcmp(Word, WordList[i]) != 0) continue;
        } else {
            if (stricmp(Word, WordList[i]) != 0) continue;
        }
        free(WordList[i]);
        memmove(WordList + i, WordList + i + 1, sizeof(char *) * (WordCount - i - 1));
        WordCount--;
        WordList = (char **)realloc((void *)WordList, WordCount * sizeof(char *));
        FullRedraw();
        return 1;
    }
    return 0;
}
예제 #23
0
int EBuffer::SearchWord(int SearchFlags) {
    char word[MAXSEARCH + 1];
    PELine L = VLine(CP.Row);
    int P, len = 0;
    int Case = BFI(this, BFI_MatchCase) ? 0 : SEARCH_NCASE;

    P = CharOffset(L, CP.Col);
    while ((P > 0) && ((ChClass(L->Chars[P - 1]) == 1) || (L->Chars[P - 1] == '_')))
        P--;
    while (len < int(sizeof(word)) && P < L->Count && (ChClass(L->Chars[P]) == 1 || L->Chars[P] == '_'))
        word[len++] = L->Chars[P++];
    word[len] = 0;
    if (len == 0)
        return 0;

    return FindStr(word, len, Case | SearchFlags | SEARCH_WORD);
}
예제 #24
0
int EBuffer::FoldClose(int Line) { /*FOLD00*/
  int f = FindNearFold(Line);
  int l, top;
  int level;

  if (f == -1) return 0;

  if (FF[f].open == 0) return 1;  // already closed

  if (Modify() == 0) return 0;

  if (SetPosR(CP.Col, FF[f].line, tmLeft) == 0) return 0;

  if (BFI(this, BFI_Undo)) {
    if (PushULong(Line) == 0) return 0;

    if (PushUChar(ucFoldClose) == 0) return 0;
  }

  FF[f].open = 0;
  top        = FF[f].line;
  level      = FF[f].level;

  while ((f < FCount - 1) && (FF[f + 1].level > level)) f++;

  /* performance tweak: do it in reverse (we'll see if it helps) */

  if (f == FCount - 1) {
    for (l = RCount - 1; l > top; l--) if (HideRow(l) == 0) return 0;
  } else {
    for (l = FF[f + 1].line - 1; l > top; l--) if (HideRow(l) == 0) return 0;
  }

  /* yup, it does. try below for a (MUCH!) slower version */

  /*if (f == FCount - 1) {
     for (l = top + 1; l < RCount; l++)
     if (HideRow(l) == 0) return 0;
     } else {
     for (l = top + 1; l < FF[f + 1].line; l++)
     if (HideRow(l) == 0) return 0;
     }*/
  return 1;
}
예제 #25
0
int EBuffer::GetMap(int Row, int *StateLen, hsState **StateMap) {
  hlState State = 0;

  Rehilit(Row);

  *StateLen = LineChars(Row);

  if (Row > 0) State = RLine(Row - 1)->StateE;

  if (*StateLen > 0) {
    PELine L = RLine(Row);
    int    ECol;

    *StateMap = (hsState *)malloc(*StateLen);

    if (*StateMap == 0) return 0;

    if ((BFI(this, BFI_HilitOn) == 1) && (HilitProc != 0)) HilitProc(this,
                                                                     Row,
                                                                     0,
                                                                     0,
                                                                     *StateLen,
                                                                     L,
                                                                     State,
                                                                     *StateMap,
                                                                     &ECol);
    else Hilit_Plain(this, Row, 0, 0, *StateLen, L, State, *StateMap, &ECol);

    //        if (L->StateE != State) {
    //            L->StateE = State;
    //        }
  } else {
    *StateLen = 1;
    *StateMap = (hsState *)malloc(1);

    if (*StateMap == 0) return 0;

    (*StateMap)[0] = (hsState)(State & 0xFF);
  }
  return 1;
}
예제 #26
0
int EBuffer::FoldDestroy(int Line) { /*FOLD00*/
  int f = FindFold(Line);

  if (Modify() == 0) return 0;

  if (f == -1) return 0;

  if (FF[f].open == 0) if (FoldOpen(Line) == 0) return 0;

  if (BFI(this, BFI_Undo)) {
    if (PushULong(FF[f].level) == 0) return 0;

    if (PushULong(Line) == 0) return 0;

    if (PushUChar(ucFoldDestroy) == 0) return 0;
  }

  memmove(FF + f, FF + f + 1, sizeof(EFold) * (FCount - f - 1));
  FCount--;
  FF = (EFold *)realloc((void *)FF, sizeof(EFold) * (FCount | 7));
  Draw(Line, Line);
  return 1;
}
예제 #27
0
int EBuffer::FoldDemote(int Line) { /*FOLD00*/
  int f = FindFold(Line);

  if (Modify() == 0) return 0;

  if (f == -1) return 0;

  if (FF[f].open == 0) return 0;

  if (FF[f].level == 99) return 0;

  if (BFI(this, BFI_Undo)) {
    if (PushULong(Line) == 0) return 0;

    if (PushUChar(ucFoldDemote) == 0) return 0;
  }

  if ((FF[f].line > 0) && (ExposeRow(FF[f].line - 1) == 0)) return 0;

  FF[f].level++;
  Draw(Line, Line);
  return 1;
}
예제 #28
0
void ExISearch::HandleEvent(TEvent &Event) {
    int Case = BFI(Buffer, BFI_MatchCase) ? 0 : SEARCH_NCASE;
    
    ExView::HandleEvent(Event);
    switch (Event.What) {
    case evKeyDown:
        SetState(IOk);
        switch (kbCode(Event.Key.Code)) {
        case kbEsc: 
            Buffer->SetPos(Orig.Col, Orig.Row);
            EndExec(0); 
            break;
        case kbEnter: EndExec(1); break;
        case kbBackSp:
            if (len > 0) {
                if (stacklen > 0) {
                    stacklen--;
                    if (Buffer->CenterPos(stack[stacklen].Col, stack[stacklen].Row) == 0) return;
                }
                len--;
                ISearchStr[len] = 0;
                if (len > 0 && Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) {
                    SetState(INoMatch);
                }
            } else {
                if (Buffer->CenterPos(Orig.Col, Orig.Row) == 0) return;
            }
            break;
        case kbUp:
            Buffer->ScrollDown(1);
            break;
        case kbDown:
            Buffer->ScrollUp(1);
            break;
        case kbLeft:
            Buffer->ScrollRight(8);
            break;
        case kbRight:
            Buffer->ScrollLeft(8);
            break;
        case kbPgDn:
            Buffer->MovePageDown();
            break;
        case kbPgUp:
            Buffer->MovePageUp();
            break;
        case kbPgUp | kfCtrl:
            Buffer->MoveFileStart();
            break;
        case kbPgDn | kfCtrl:
            Buffer->MoveFileEnd();
            break;
        case kbHome:
            Buffer->MoveLineStart();
            break;
        case kbEnd:
            Buffer->MoveLineEnd();
            break;
        case kbTab | kfShift:
            Direction = SEARCH_BACK;
            if (len == 0) {
                strcpy(ISearchStr, PrevISearch);
                len = strlen(ISearchStr);
                if (len == 0)
                    break;
            }
            if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) {
                Buffer->FindStr(ISearchStr, len, Case);
                SetState(INoPrev);
            }
            break;
        case kbTab:
            Direction = 0;
            if (len == 0) {
                strcpy(ISearchStr, PrevISearch);
                len = strlen(ISearchStr);
                if (len == 0)
                    break;
            }
            if (Buffer->FindStr(ISearchStr, len, Case | Direction | SEARCH_NEXT) == 0) {
                Buffer->FindStr(ISearchStr, len, Case);
                SetState(INoNext);
            }
            break;
        case 'Q' | kfCtrl:
            Event.What = evKeyDown;
            Event.Key.Code = Win->GetChar(0);
        default:
            if (isAscii(Event.Key.Code) && (len < MAXISEARCH)) {
                char Ch = (char) Event.Key.Code;
                
                stack[stacklen++] = Buffer->CP;
                ISearchStr[len++] = Ch;
                ISearchStr[len] = 0;
                if (Buffer->FindStr(ISearchStr, len, Case | Direction) == 0) {
                    SetState(INoMatch);
                    len--;
                    stacklen--;
                    ISearchStr[len] = 0;
                    Buffer->FindStr(ISearchStr, len, Case | Direction);
                } else {
                }
            }
            break;
        }
    }
}
예제 #29
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::InsertString(const char *aStr, int aCount) {
    int P;
    int C, L;
    int Y = VToR(CP.Row);

    if (BFI(this, BFI_InsertKillBlock) == 1)
        if (CheckBlock() == 1)
            if (BlockKill() == 0)
                return 0;

    if (BFI(this, BFI_Insert) == 0)
        if (CP.Col < LineLen())
            if (KillChar() == 0)
                return 0;
    if (InsText(Y, CP.Col, aCount, aStr) == 0)
        return 0;
    C = CP.Col;
    L = VToR(CP.Row);
    P = CharOffset(RLine(L), C);
    P += aCount;
    C = ScreenPos(RLine(L), P);
    if (SetPos(C, CP.Row) == 0)
        return 0;
    if (BFI(this, BFI_Trim) && *aStr != '\t')
        if (TrimLine(L) == 0)
            return 0;
    if (BFI(this, BFI_WordWrap) == 2) {
        if (DoWrap(0) == 0) return 0;
    } else if (BFI(this, BFI_WordWrap) == 1) {
        int P, C = CP.Col;
        PELine LP;
        int L;

        if (C > BFI(this, BFI_RightMargin)) {
            L = CP.Row;

            C = BFI(this, BFI_RightMargin);
            P = CharOffset(LP = RLine(L), C);
            while ((C > BFI(this, BFI_LeftMargin)) &&
                    ((LP->Chars[P] != ' ') &&
                     (LP->Chars[P] != 9)))
                C = ScreenPos(LP, --P);

            if (P <= BFI(this, BFI_LeftMargin)) {
                C = BFI(this, BFI_RightMargin);
            } else
                C = ScreenPos(LP, P);
            if (SplitLine(L, C) == 0) return 0;
            IndentLine(L + 1, BFI(this, BFI_LeftMargin));
            if (SetPos(CP.Col - C - 1 + BFI(this, BFI_LeftMargin), CP.Row + 1) == 0) return 0;
        }
    }
    return 1;
}
예제 #30
0
파일: e_cmds.cpp 프로젝트: dmcbride/efte
int EBuffer::LineSplit() {
    if (SplitLine(VToR(CP.Row), CP.Col) == 0) return 0;
    if (BFI(this, BFI_Trim))
        if (TrimLine(VToR(CP.Row)) == 0) return 0;
    return 1;
}