void EDirectory::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { char s[1024]; MoveCh(B, ' ', color, Width); if (Files && Line >= 0 && Line < FCount) { int Year, Mon, Day, Hour, Min, Sec; struct tm *t; time_t tim; tim = Files[Line]->MTime(); t = localtime(&tim); if (t) { Year = t->tm_year + 1900; Mon = t->tm_mon + 1; Day = t->tm_mday; Hour = t->tm_hour; Min = t->tm_min; Sec = t->tm_sec; } else { Year = Mon = Day = Hour = Min = Sec = 0; } sprintf(s, " %04d/%02d/%02d %02d:%02d:%02d %8ld ", Year, Mon, Day, Hour, Min, Sec, Files[Line]->Size()); strcat(s, Files[Line]->Name()); s[strlen(s) + 1] = '\0'; s[strlen(s)] = (Files[Line]->Type() == fiDIRECTORY)? SLASH : ' '; if (Col < int(strlen(s))) MoveStr(B, 0, Width, s + Col, color, Width); } }
void EView::SetMsg(const char *msg) { if (CurMsg) free(CurMsg); CurMsg = 0; if (msg && strlen(msg)) CurMsg = strdup(msg); if (CurMsg && msg && MView) { TDrawBuffer B; char SColor; int Cols, Rows; MView->ConQuerySize(&Cols, &Rows); if (MView->IsActive()) SColor = hcStatus_Active; else SColor = hcStatus_Normal; MoveChar(B, 0, Cols, ' ', SColor, Cols); MoveStr(B, 0, Cols, CurMsg, SColor, Cols); if (MView->Win->GetStatusContext() == MView) MView->ConPutBox(0, Rows - 1, Cols, 1, B); //printf("%s\n", Msg); } }
void ESvnBase::DrawLine (PCell B,int Line,int Col,ChColor color,int Width) { if (Line<LineCount) if (Col<(int)strlen (Lines[Line]->Msg)) { char str[1024]; int len; len=UnTabStr (str,sizeof (str),Lines[Line]->Msg,strlen (Lines[Line]->Msg)); if (len>Col) MoveStr (B,0,Width,str+Col,color,Width); } }
void EListPort::RepaintStatus() { TDrawBuffer B; char s[80]; int W, H; char SColor; if (View == 0 || View->MView == 0 || View->MView->Win == 0) return ; View->MView->ConQuerySize(&W, &H); List->UpdateList(); List->FixPos(); if (List->View == View) GetPos(); if (View->MView->Win->GetStatusContext() != View->MView) return; View->MView->Win->SetSbVPos(TopRow, H, List->Count + (WeirdScroll ? H - 1 : 0)); View->MView->Win->SetSbHPos(LeftCol, W, 1024 + (WeirdScroll ? W - 1 : 0)); if (View->MView->IsActive()) // hack SColor = hcStatus_Active; else SColor = hcStatus_Normal; MoveCh(B, ' ', SColor, W); if (View->CurMsg == 0) { if (List->Title) MoveStr(B, 0, W, List->Title, SColor, W); sprintf(s, "%c%d/%d", ConGetDrawChar(DCH_V), Row + 1, List->Count); MoveStr(B, W - strlen(s), W, s, SColor, W); } else { MoveStr(B, 0, W, View->CurMsg, SColor, W); } View->MView->ConPutBox(0, H - 1, W, 1, B); if (View->MView->Win->GetStatusContext() == View->MView && View->MView->Win->IsActive()) View->MView->Win->ConSetCursorPos(0, Row - TopRow); }
void RoutineView::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { if (Buffer->RLine(Buffer->rlst.Lines[Line])->Count > Col) { char str[1024]; int len; len = UnTabStr(str, sizeof(str), Buffer->RLine(Buffer->rlst.Lines[Line])->Chars, Buffer->RLine(Buffer->rlst.Lines[Line])->Count); if (len > Col) MoveStr(B, 0, Width, str + Col, color, len - Col); } }
void ExComplete::RepaintStatus() { TDrawBuffer B; int W, H; // Currently use this fixed colors - maybe there are some better defines?? #define COM_NORM 0x17 #define COM_ORIG 0x1C #define COM_HIGH 0x1E #define COM_MARK 0x2E #define COM_ERR 0x1C ConQuerySize(&W, &H); MoveCh(B, ' ', COM_NORM, W); if ((WordsLast > 0) && (WordBegin != NULL) && (Words != NULL) && ((Words[WordPos]) != NULL)) { const char *sc = STRCOMPLETE; int p = sizeof(STRCOMPLETE) - 1; if (W < 35) { // if the width is quite small sc += p - 1; // jump to last character p = 1; } MoveStr(B, 0, W, sc, COM_NORM, W); // int cur = p; MoveStr(B, p, W, WordBegin, COM_ORIG, W); p += strlen(WordBegin); int l = strlen(Words[WordPos]); if (WordFixed > 0) { MoveStr(B, p, W, Words[WordPos], COM_MARK, W); p += WordFixed; l -= WordFixed; } MoveStr(B, p, W, Words[WordPos] + WordFixed, (WordFixedCount == 1) ? COM_ORIG : COM_HIGH, W); p += l; char s[100]; sprintf(s, "] (T:%d/%d S:%d)", WordPos + 1, WordsLast, (int)WordFixedCount); MoveStr(B, p, W, s, COM_NORM, W); // ConSetCursorPos(cur + WordFixed, H - 1); } else MoveStr(B, 0, W, STRNOCOMPLETE, COM_ERR, W); ConPutBox(0, H - 1, W, 1, B); ConShowCursor(); }
void ExISearch::RepaintStatus() { TDrawBuffer B; char s[MAXISEARCH + 1]; const char *p; int W, H; ConQuerySize(&W, &H); switch (state) { case INoMatch: p = " No Match. "; break; case INoPrev: p = " No Prev Match. "; break; case INoNext: p = " No Next Match. "; break; case IOk: default: p = ""; break; } sprintf(s, "ISearch [%s]%s", ISearchStr, p); MoveCh(B, ' ', 0x17, W); MoveStr(B, 0, W, s, 0x17, W); ConPutBox(0, H - 1, W, 1, B); ConSetCursorPos(strlen(s) - 1, H - 1); ConShowCursor(); }
void EventMapView::DrawLine(PCell B, int Line, int Col, ChColor color, int Width) { if (Line < BCount) if (Col < int(strlen(BList[Line]))) MoveStr(B, 0, Width, BList[Line] + Col, color, Width); }
void ExASCII::HandleEvent(TEvent& Event) { int W, H; ConQuerySize(&W, &H); switch (Event.What) { case evKeyDown: switch (kbCode(Event.Key.Code)) { case kbLeft: Pos--; Event.What = evNone; break; case kbRight: Pos++; Event.What = evNone; break; case kbHome: Pos = 0; Event.What = evNone; break; case kbEnd: Pos = 255; Event.What = evNone; break; case kbLeft + kfCtrl: Pos -= 16; Event.What = evNone; break; case kbRight + kfCtrl: Pos += 16; Event.What = evNone; break; case kbUp: Pos -= W; LPos -= W; Event.What = evNone; break; case kbDown: Pos += W; LPos += W; Event.What = evNone; break; case kbEsc: EndExec(-1); Event.What = evNone; break; case kbEnter: EndExec(Pos); Event.What = evNone; break; } break; #if 0 case evMouseDown: if ((E.Mouse.X < XPos) || (E.Mouse.X >= XPos + 34) || (E.Mouse.Y < YPos) || (E.Mouse.Y >= YPos + 10)) { abort = 2; break; } do { x = E.Mouse.X - XPos - 1; y = E.Mouse.Y - YPos - 1; if ((x >= 0) && (x < 32) && (y >= 0) && (y < 8)) { X = x; Y = y; if (X >= 32) X = 31; if (Y >= 8) Y = 7; if (X < 0) X = 0; if (Y < 0) Y = 0; frames->ConSetCursorPos(X + XPos + 1, Y + YPos + 1); sprintf(s, "0%03o %03d 0x%02X", X + Y * 32, X + Y * 32, X + Y * 32); MoveStr(B, 0, 13, s, hcAsciiStatus, 13); frames->ConPutBox(XPos + 2, YPos + 9, 13, 1, B); } if (E.Mouse.Count == 2) { abort = 1; break; } gui->ConGetEvent(evMouse, &E, -1, 1); if (E.What == evMouseUp) break; } while (1); break; #endif // if 0 } }
void EBuffer::Redraw() { int HilitX; EView *V; EEditPort *W; int Row; TDrawBuffer B; char s[256]; ChColor SColor; int RowA, RowZ; { int W1, H1; if (!(View && View->MView)) return; View->MView->ConQuerySize(&W1, &H1); if ((H1 < 1) || (W1 < 1)) return; } // printf("Redraw\n"); if (CP.Row >= VCount) CP.Row = VCount - 1; if (CP.Row < 0) CP.Row = 0; CheckBlock(); V = View; /* check some window data */ if (!V) { MinRedraw = MaxRedraw = -1; RedrawToEos = 0; return; } if ((View == 0) || (View->MView == 0) || (View->MView->Win == 0)) return; for (; V; V = V->NextView) { // printf("Checking\x7\n"); if (V->Model != this) assert(1 == 0); W = GetViewVPort(V); if ((W->Rows < 1) || (W->Cols < 1)) continue; if (V == View) { int scrollJumpX = Min(ScrollJumpX, W->Cols / 2); int scrollJumpY = Min(ScrollJumpY, W->Rows / 2); int scrollBorderX = Min(ScrollBorderX, W->Cols / 2); int scrollBorderY = Min(ScrollBorderY, W->Rows / 2); W->CP = CP; TP = W->TP; if (W->ReCenter) { W->TP.Row = CP.Row - W->Rows / 2; W->TP.Col = CP.Col - W->Cols + 8; W->ReCenter = 0; } if (W->TP.Row + scrollBorderY > CP.Row) W->TP.Row = CP.Row - scrollJumpY + 1 - scrollBorderY; if (W->TP.Row + W->Rows - scrollBorderY <= CP.Row) W->TP.Row = CP.Row - W->Rows + 1 + scrollJumpY - 1 + scrollBorderY; if (!WeirdScroll) if (W->TP.Row + W->Rows >= VCount) W->TP.Row = VCount - W->Rows; if (W->TP.Row < 0) W->TP.Row = 0; if (W->TP.Col + scrollBorderX > CP.Col) W->TP.Col = CP.Col - scrollJumpX - scrollBorderX; if (W->TP.Col + W->Cols - scrollBorderX <= CP.Col) W->TP.Col = CP.Col - W->Cols + scrollJumpX + scrollBorderX; if (W->TP.Col < 0) W->TP.Col = 0; if ((W->OldTP.Row != -1) && (W->OldTP.Col != -1) && (RedrawToEos == 0)) { if ((W->OldTP.Row != W->TP.Row) || (W->OldTP.Col != W->TP.Col)) { int A, B; int DeltaX, DeltaY; int Rows = W->Rows; int Delta1 = 0, Delta2 = 0; DeltaY = W->TP.Row - W->OldTP.Row; DeltaX = W->TP.Col - W->OldTP.Col; if ((DeltaX == 0) && (-Rows < DeltaY) && (DeltaY < Rows)) { if (DeltaY < 0) { W->ScrollY(DeltaY); A = W->TP.Row; B = W->TP.Row - DeltaY; } else { W->ScrollY(DeltaY); A = W->TP.Row + Rows - DeltaY; B = W->TP.Row + Rows; } } else { A = W->TP.Row; B = W->TP.Row + W->Rows; } if (A >= VCount) { Delta1 = A - VCount + 1; A = VCount - 1; } if (B >= VCount) { Delta2 = B - VCount + 1; B = VCount - 1; } if (A < 0) A = 0; if (B < 0) B = 0; Draw(VToR(A) + Delta1, VToR(B) + Delta2); } } else { int A = W->TP.Row; int B = A + W->Rows; int Delta = 0; if (B > VCount) { Delta += B - VCount; B = VCount; } int LastV = VToR(VCount - 1); int B1 = (B == VCount) ? RCount : VToR(B); if (B1 >= LastV) { Delta += B1 - LastV; B1 = LastV; } if (B1 < 0) B1 = 0; Draw(VToR(A), B1 + Delta); } W->OldTP = W->TP; TP = W->TP; } if (W->CP.Row >= VCount) W->CP.Row = VCount - 1; if (W->CP.Row < 0) W->CP.Row = 0; if (W->TP.Row > W->CP.Row) W->TP.Row = W->CP.Row; if (W->TP.Row < 0) W->TP.Row = 0; if (V->MView->IsActive()) // hack SColor = hcStatus_Active; else SColor = hcStatus_Normal; MoveChar(B, 0, W->Cols, ' ', SColor, W->Cols); if (V->MView->Win->GetViewContext() == V->MView) { V->MView->Win->SetSbVPos(W->TP.Row, W->Rows, VCount + (WeirdScroll ? W->Rows - 1 : 0)); V->MView->Win->SetSbHPos(W->TP.Col, W->Cols, 1024 + (WeirdScroll ? W->Cols - 1 : 0)); } if (V->CurMsg == 0) { { int CurLine = W->CP.Row; int ActLine = VToR(W->CP.Row); int CurColumn = W->CP.Col; int CurPos = CharOffset(RLine(ActLine), CurColumn); int NumLines = RCount; int NumChars = RLine(ActLine)->Count; // int NumColumns = ScreenPos(Line(CurLine), NumChars); char *fName = FileName; unsigned char CurCh = 0xFF; int lf = strlen(fName); char CCharStr[20] = ""; if (lf > 34) fName += lf - 34; if (CurPos < NumChars) { CurCh = VLine(CurLine)->Chars[CurPos]; sprintf(CCharStr, "%3u,%02X", CurCh, CurCh); } else { if (CurPos > NumChars) strcpy(CCharStr, " "); else if (CurLine < NumLines - 1) strcpy(CCharStr, " EOL"); else strcpy(CCharStr, " EOF"); } sprintf(s, "%04d:%02d (%04d:%02d) %c%c%c%c%c %.6s %c", // CurLine + 1, ActLine + 1, CurColumn + 1, NumLines, NumChars, // CurPos + 1, (BFI(this, BFI_Insert)) ? 'I' : ' ', (BFI(this, BFI_AutoIndent)) ? 'A' : ' ', // (BFI(this, BFI_ExpandTabs))?'T':' ', (BFI(this, BFI_MatchCase)) ? 'C' : ' ', AutoExtend ? ( (BlockMode == bmStream) ? 's' : (BlockMode == bmLine) ? 'l' : 'c' ) : ((BlockMode == bmStream) ? 'S' : (BlockMode == bmLine) ? 'L' : 'C' ), (BFI(this, BFI_WordWrap) == 3) ? 't' : (BFI(this, BFI_WordWrap) == 2) ? 'W' : (BFI(this, BFI_WordWrap) == 1) ? 'w' : ' ', // (BFI(this, BFI_Undo))?'U':' ', // (BFI(this, BFI_Trim))?'E':' ', // (Flags.KeepBackups)?'B':' ', Mode->fName, (Modified != 0) ? '*' : (BFI(this, BFI_ReadOnly)) ? '%' : ' ' ); int l = strlen(s); int fw = W->Cols - l; int fl = strlen(FileName); char num[32]; MoveStr(B, 0, W->Cols, s, SColor, W->Cols); sprintf(num, " %s %d", CCharStr, ModelNo); MoveStr(B, W->Cols - strlen(num), W->Cols, num, SColor, W->Cols); fw -= strlen(num); if (fl > fw) { MoveStr(B, l, W->Cols, FileName + fl - fw, SColor, W->Cols); } else { MoveStr(B, l, W->Cols, FileName, SColor, W->Cols); } } } else { MoveStr(B, 0, W->Cols, V->CurMsg, SColor, W->Cols); } if (V->MView->Win->GetStatusContext() == V->MView) { V->MView->ConPutBox(0, W->Rows, W->Cols, 1, B); if (V->MView->IsActive()) { V->MView->ConSetCursorPos(W->CP.Col - W->TP.Col, W->CP.Row - W->TP.Row); V->MView->ConSetInsertState(BFI(this, BFI_Insert)); V->MView->ConShowCursor(); } } } Rehilit(VToR(CP.Row)); if (BFI(this, BFI_AutoHilitParen) == 1) { if ((Match.Row == -1) && (Match.Col == -1)) HilitMatchBracket(); } // if ((Window == WW) && (MinRedraw == -1)) // MaxRedraw = MinRedraw = VToR(CP.Row); // printf("\n\nMinRedraw = %d, MaxRedraw = %d", MinRedraw, MaxRedraw); if (MinRedraw == -1) return; // printf("Will redraw: %d to %d, to eos = %d\n", MinRedraw, MaxRedraw, // RedrawToEos); if (MinRedraw >= VCount) MinRedraw = VCount - 1; if (MinRedraw < 0) MinRedraw = 0; // puts("xxx\x7"); // printf("%d\n", MinRedraw); Row = RowA = RToVN(MinRedraw); // puts("xxx\x7"); RowZ = MaxRedraw; if (MaxRedraw != -1) { int Delta = 0; if (MaxRedraw >= RCount) { Delta = MaxRedraw - RCount + 1; MaxRedraw = RCount - 1; } if (MaxRedraw < 0) MaxRedraw = 0; // printf("%d\n", MaxRedraw); RowZ = RToVN(MaxRedraw) + Delta; } // puts("xxx\x7"); // printf("\nRowA = %d, RowZ = %d", RowA, RowZ); V = View; while (V) { if (V->Model != this) assert(1 == 0); W = GetViewVPort(V); for (int R = W->TP.Row; R < W->TP.Row + W->Rows; R++) { Row = R; if ((Row >= RowA) && (RedrawToEos || (Row <= RowZ))) { DrawLine(B, Row, W->TP.Col, W->Cols, HilitX); W->DrawLine(Row, B); if (HilitX && (Row == RowZ)) RowZ++; } } V = V->NextView; } MinRedraw = MaxRedraw = -1; RedrawToEos = 0; }
void EBuffer::DrawLine(TDrawBuffer B, int VRow, int C, int W, int& HilitX) { hlState State; int StartPos, EndPos; HilitX = 0; MoveChar(B, 0, W, ' ', hcPlain_Background, W); // if ((VRow == VCount - 1) && !BFI(this, BFI_ForceNewLine)) { // if (BFI(this, BFI_ShowMarkers)) // MoveChar(B, 0, W, EOF_MARKER, hcPlain_Markers, W); // } if (VRow < VCount) { int Row = VToR(VRow); PELine L = RLine(Row); int ECol = 0; if (Row > 0) State = RLine(Row - 1)->StateE; else State = 0; if ((BFI(this, BFI_HilitOn) == 1) && (HilitProc != 0)) HilitProc(this, Row, B, C, W, L, State, 0, &ECol); else Hilit_Plain(this, Row, B, C, W, L, State, 0, &ECol); if (L->StateE != State) { HilitX = 1; L->StateE = State; } if (BFI(this, BFI_ShowMarkers)) { MoveChar(B, ECol - C, W, ConGetDrawChar( (Row == RCount - 1) ? DCH_EOF : DCH_EOL), hcPlain_Markers, 1); ECol += 1; } if (Row < RCount) { int f; int Folded = 0; static char fold[20]; int l; f = FindFold(Row); if (f != -1) { int foldColor; if (FF[f].level < 5) foldColor = hcPlain_Folds[FF[f].level]; else foldColor = hcPlain_Folds[4]; if (FF[f].open == 1) { l = sprintf(fold, "[%d]", FF[f].level); MoveStr(B, ECol - C + 1, W, fold, foldColor, 10); ECol += l; } else { if (VRow < VCount - 1) { Folded = Vis(VRow + 1) - Vis(VRow) + 1; } else if (VRow < VCount) { Folded = RCount - (VRow + Vis(VRow)); } l = sprintf(fold, "(%d:%d)", FF[f].level, Folded); MoveStr(B, ECol - C + 1, W, fold, foldColor, 10); ECol += l; MoveAttr(B, 0, W, foldColor, W); } } } if ((BB.Row != -1) && (BE.Row != -1) && (Row >= BB.Row) && (Row <= BE.Row)) { switch (BlockMode) { case bmLine: StartPos = 0; if (Row == BE.Row) EndPos = 0; else EndPos = W; break; case bmColumn: StartPos = BB.Col - C; if (Row == BE.Row) EndPos = BB.Col - C; else EndPos = BE.Col - C; break; case bmStream: if ((Row == BB.Row) && (Row == BE.Row)) { StartPos = BB.Col - C; EndPos = BE.Col - C; } else if (Row == BB.Row) { StartPos = BB.Col - C; EndPos = W; } else if (Row == BE.Row) { StartPos = 0; EndPos = BE.Col - C; } else { StartPos = 0; EndPos = W; } break; default: StartPos = EndPos = 0; break; } if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B, StartPos, W, hcPlain_Selected, EndPos - StartPos); else MoveAttr(B, StartPos, W, hcPlain_Selected, EndPos - StartPos); } if (BFI(this, BFI_ShowBookmarks)) { int i = 0; char *Name; EPoint P; while ((i = GetBookmarkForLine(i, Row, Name, P)) != -1) { if (strncmp(Name, "_BMK", 4) == 0) { // User bookmark, hilite line if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B, 0, W, hcPlain_Bookmark, W); else MoveAttr(B, 0, W, hcPlain_Bookmark, W); break; } } } if ((Match.Row != -1) && (Match.Col != -1)) { if (Row == Match.Row) { if (BFI(this, BFI_SeeThruSel)) MoveBgAttr(B, Match.Col - C, W, hcPlain_Found, MatchLen); else MoveAttr(B, Match.Col - C, W, hcPlain_Found, MatchLen); } } } else if (VRow == VCount) { if (BFI(this, BFI_ShowMarkers)) MoveChar(B, 0, W, ConGetDrawChar( DCH_END), hcPlain_Markers, W); } }