/* * Copyright (c) 2021, 2023 joshua stein * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include "amend.h" #include "browser.h" #include "repo.h" #include "util.h" void file_list_draw_cell(ListHandle theList, Cell theCell, short dataLen, Rect *cellRect, Boolean selected); pascal void file_list_ldef(short message, Boolean selected, Rect *cellRect, Cell theCell, short dataOffset, short dataLen, ListHandle theList) { switch (message) { case 0: /* init */ break; case 1: /* update */ /* FALLTHROUGH */ case 2: /* hilight */ file_list_draw_cell(theList, theCell, dataLen, cellRect, selected); break; case 3: /* close */ break; } } void file_list_draw_cell(ListHandle theList, Cell theCell, short dataLen, Rect *cellRect, Boolean selected) { static char all_files_text[] = "All Files"; Rect textRect; char tmp[50]; struct repo_file *file = NULL; struct tm *ttm = NULL; short len; textRect.left = cellRect->left; textRect.right = cellRect->right; textRect.top = cellRect->top; textRect.bottom = cellRect->bottom + 1; EraseRect(&textRect); InsetRect(&textRect, 4, 4); TextFace(0); TextFont(FILE_LIST_FONT); TextSize(FILE_LIST_FONT_SIZE); MoveTo(textRect.left, textRect.top + 6); if (theCell.v == 0) { TextFace(bold); DrawText(all_files_text, 0, strlen(all_files_text)); } else { LGetCell(&file, &dataLen, theCell, theList); len = strlen(file->filename); DrawText(file->filename, 0, len); if (file->flags & REPO_FILE_DELETED) { MoveTo(textRect.left, textRect.top + 3); LineTo(textRect.left + TextWidth(file->filename, 0, len), textRect.top + 3); } } if (selected) InvertRect(cellRect); }