AmendHub

Download

jcs

/

amend

/

file_list.c

 

(View History)

jcs   browser: Use a custom LDEF for file list to cross out deleted files Latest amendment: 253 on 2023-11-01

1 /*
2 * Copyright (c) 2021, 2023 joshua stein <jcs@jcs.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #include <string.h>
18 #include <stdio.h>
19 #include <time.h>
20 #include "amend.h"
21 #include "browser.h"
22 #include "repo.h"
23 #include "util.h"
24
25 void file_list_draw_cell(ListHandle theList, Cell theCell,
26 short dataLen, Rect *cellRect, Boolean selected);
27
28 pascal void
29 file_list_ldef(short message, Boolean selected, Rect *cellRect,
30 Cell theCell, short dataOffset, short dataLen, ListHandle theList)
31 {
32 switch (message) {
33 case 0:
34 /* init */
35 break;
36 case 1:
37 /* update */
38 /* FALLTHROUGH */
39 case 2:
40 /* hilight */
41 file_list_draw_cell(theList, theCell, dataLen, cellRect, selected);
42 break;
43 case 3:
44 /* close */
45 break;
46 }
47 }
48
49 void
50 file_list_draw_cell(ListHandle theList, Cell theCell, short dataLen,
51 Rect *cellRect, Boolean selected)
52 {
53 static char all_files_text[] = "All Files";
54 Rect textRect;
55 char tmp[50];
56 struct repo_file *file = NULL;
57 struct tm *ttm = NULL;
58 short len;
59
60 textRect.left = cellRect->left;
61 textRect.right = cellRect->right;
62 textRect.top = cellRect->top;
63 textRect.bottom = cellRect->bottom + 1;
64 EraseRect(&textRect);
65 InsetRect(&textRect, 4, 4);
66
67 TextFace(0);
68 TextFont(FILE_LIST_FONT);
69 TextSize(FILE_LIST_FONT_SIZE);
70 MoveTo(textRect.left, textRect.top + 6);
71
72 if (theCell.v == 0) {
73 TextFace(bold);
74 DrawText(all_files_text, 0, strlen(all_files_text));
75 } else {
76 LGetCell(&file, &dataLen, theCell, theList);
77 len = strlen(file->filename);
78 DrawText(file->filename, 0, len);
79
80 if (file->flags & REPO_FILE_DELETED) {
81 MoveTo(textRect.left, textRect.top + 3);
82 LineTo(textRect.left + TextWidth(file->filename, 0, len),
83 textRect.top + 3);
84 }
85 }
86
87 if (selected)
88 InvertRect(cellRect);
89 }