Subversion Repositories Kolibri OS

Rev

Rev 9522 | Rev 9671 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. (*
  2.     Copyright 2021, 2022 Anton Krotov
  3.  
  4.     This file is part of CEdit.
  5.  
  6.     CEdit is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     CEdit is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with CEdit. If not, see <http://www.gnu.org/licenses/>.
  18. *)
  19.  
  20. MODULE StatusBar;
  21.  
  22. IMPORT G := Graph, U := Utils, K := KolibriOS;
  23.  
  24. TYPE
  25.  
  26.         tString = ARRAY 32 OF WCHAR;
  27.  
  28.         tStatusBar* = RECORD
  29.  
  30.                 pos, sel, enc: tString;
  31.                 canvas: G.tCanvas
  32.  
  33.         END;
  34.  
  35. VAR
  36.  
  37.         SB: tStatusBar;
  38.         font: G.tFont;
  39.  
  40.  
  41. PROCEDURE setPos* (line, col: INTEGER);
  42. VAR
  43.         s1, s2: tString;
  44. BEGIN
  45.         U.int2str(line, s1);
  46.         U.append(s1, ": ");
  47.         U.int2str(col, s2);
  48.         U.append(s1, s2);
  49.         SB.pos := s1
  50. END setPos;
  51.  
  52.  
  53. PROCEDURE setSel* (chars, lines: INTEGER);
  54. VAR
  55.         s1, s2: tString;
  56. BEGIN
  57.         IF chars # 0 THEN
  58.                 s1 := "sel: ";
  59.                 U.int2str(chars, s2);
  60.                 U.append(s1, s2);
  61.                 U.append(s1, " | ");
  62.                 U.int2str(lines, s2);
  63.                 U.append(s1, s2);
  64.                 SB.sel := s1
  65.         ELSE
  66.                 SB.sel := ""
  67.         END
  68. END setSel;
  69.  
  70.  
  71. PROCEDURE setEnc* (eol, enc: ARRAY OF WCHAR);
  72. BEGIN
  73.         SB.enc := eol;
  74.         U.append(SB.enc, 20X + 20X);
  75.         U.append(SB.enc, enc)
  76. END setEnc;
  77.  
  78.  
  79. PROCEDURE setWidth* (width: INTEGER);
  80. BEGIN
  81.         ASSERT(width > 0);
  82.         IF (SB.canvas = NIL) OR (SB.canvas.width # width) THEN
  83.                 G.destroy(SB.canvas);
  84.                 SB.canvas := G.CreateCanvas(width, 19);
  85.                 G.SetFont(SB.canvas, font)
  86.         END
  87. END setWidth;
  88.  
  89.  
  90. PROCEDURE TextOut (x: INTEGER; s: ARRAY OF WCHAR);
  91. BEGIN
  92.         G.TextOut2(SB.canvas, x, 2, s, LENGTH(s))
  93. END TextOut;
  94.  
  95.  
  96. PROCEDURE draw* (left, top: INTEGER);
  97. BEGIN
  98.         G.SetColor(SB.canvas, K.colors.work);
  99.         G.SetBkColor(SB.canvas, K.colors.work);
  100.         G.SetTextColor(SB.canvas, K.colors.work_text);
  101.         G.clear(SB.canvas);
  102.         TextOut(1, SB.pos);
  103.         TextOut(16*K.fontWidth, SB.sel);
  104.         TextOut(SB.canvas.width - LENGTH(SB.enc)*K.fontWidth - 1, SB.enc);
  105.         G.DrawCanvas(SB.canvas, left, top)
  106. END draw;
  107.  
  108.  
  109. BEGIN
  110.         SB.canvas := NIL;
  111.         font := G.CreateFont(1, "", {})
  112. END StatusBar.