Commit 38887308 authored by Randolph Chung's avatar Randolph Chung

More scroll updates

parent aa7a4047
PROGRAM = tasksel
VERSION=\"0.1\"
CC = gcc
CFLAGS = -g -Os -Wall
CFLAGS = -g -Wall -Os
DEFS = -DVERSION=$(VERSION) -DPACKAGE=\"$(PROGRAM)\" -DLOCALEDIR=\"/usr/share/locale\" #-DDEBUG
LIBS = -lslang #-lccmalloc -ldl
OBJS = tasksel.o slangui.o data.o util.o strutl.o
......
$Id: TODO,v 1.5 2000/01/12 02:45:05 tausq Exp $
$Id: TODO,v 1.6 2000/01/16 02:55:30 tausq Exp $
- fix screen resize code (in dialogs, it doesn't work right)
- add scroll support to the dialogs
- figure out how to fix get the help text i18n'ized
- figure out how to properly install the i18n stuff
- show already installed task packages
/* $Id: data.c,v 1.6 2000/01/07 22:45:09 joeyh Exp $ */
/* $Id: data.c,v 1.7 2000/01/16 02:55:30 tausq Exp $ */
/* data.c - encapsulates functions for reading a package listing like dpkg's available file
* Internally, packages are stored in a binary tree format to faciliate search operations
*/
......@@ -19,7 +19,9 @@
#define RECOMMENDSFIELD "Recommends: "
#define SUGGESTSFIELD "Suggests: "
#define DESCRIPTIONFIELD "Description: "
#define STATUSFIELD "Status: "
#define AVAILABLEFILE "/var/lib/dpkg/available"
#define STATUSFILE "/var/lib/dpkg/status"
#define BUF_SIZE 1024
#define MATCHFIELD(buf, s) (strncmp(buf, s, strlen(s)) == 0)
#define FIELDDATA(buf, s) (buf + strlen(s))
......@@ -103,6 +105,18 @@ static int splitlinkdesc(const char *desc, char ***array)
return elts;
}
static const char *filterdescription(const char *descin)
{
/* !!!!!TODO!!!!!!!!!
* This is a very ugly hack. It exists here until the package descriptions
* are properly fixed. :-(
*/
if (strstr(descin, "Metapackage for ") || strstr(descin, "metapackage for "))
return (descin+16);
else
return descin;
}
static void addpackage(struct packages_t *pkgs,
const char *name, const char *dependsdesc, const char *recommendsdesc,
const char *suggestsdesc, const char *shortdesc, const char *longdesc,
......@@ -246,9 +260,11 @@ void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
}
}
addpackage(pkgs, name, NULL, NULL, NULL, shortdesc, NULL, 0);
addpackage(pkgs, name, NULL, NULL, NULL, shortdesc,
NULL, 0);
if (strncmp(name, "task-", 5) == 0)
addpackage(taskpkgs, name, dependsdesc, recommendsdesc, suggestsdesc, shortdesc, longdesc, 1);
addpackage(taskpkgs, name, dependsdesc, recommendsdesc, suggestsdesc,
filterdescription(shortdesc), longdesc, 1);
if (name != NULL) FREE(name);
if (dependsdesc != NULL) FREE(dependsdesc);
......
tasksel (1.0-4) unstable; urgency=low
* More changes from Joey Hess; adds buttons to clear up main screen;
more consistency changes
* Adds scroll support to dialogs and main menu
-- Randolph Chung <tausq@debian.org> Sat, 15 Jan 2000 14:33:56 -0700
tasksel (1.0-3) unstable; urgency=low
* Lots of changes from Joey Hess: (re bug#54250)
......
/* $Id: slangui.c,v 1.14 2000/01/15 23:03:17 tausq Exp $ */
/* $Id: slangui.c,v 1.15 2000/01/16 02:55:30 tausq Exp $ */
/* slangui.c - SLang user interface routines */
/* TODO: the redraw code is a bit broken, also this module is using way too many
* global vars */
......@@ -332,6 +332,8 @@ int ui_drawscreen(void)
for (i = _chooserinfo.topindex; i < _chooserinfo.topindex + _chooserinfo.height; i++)
if (i < _taskpackages->count) ui_drawchooseritem(i);
ui_vscrollbar(_chooserinfo.rowoffset, _chooserinfo.coloffset + _chooserinfo.width - 1, _chooserinfo.height, 0);
for (i = 0; i <= NUM_BUTTONS; i++)
_drawbutton(i, 0);
......@@ -345,7 +347,9 @@ int ui_drawscreen(void)
void ui_vscrollbar(int row, int col, int height, double percent)
{
int i;
if (percent < 0) percent = 0;
/* fudge the percent a bit -- this makes sure it shows up properly */
percent -= 0.05;
if (percent < 0.01) percent = 0.01;
if (percent > 100.0) percent = 100.0;
SLsmg_set_color(SCROLLBAR);
......@@ -353,7 +357,10 @@ void ui_vscrollbar(int row, int col, int height, double percent)
SLsmg_gotorc(row+i, col);
if (((double)i)/height < percent &&
((double)i+1)/height >= percent) {
SLsmg_write_char('#');
SLsmg_set_char_set(1);
SLsmg_write_char(SLSMG_DIAMOND_CHAR);
SLsmg_set_char_set(0);
/* SLsmg_write_char('#'); */
} else {
SLsmg_set_char_set(1);
SLsmg_write_char(SLSMG_CKBRD_CHAR);
......@@ -365,7 +372,9 @@ void ui_vscrollbar(int row, int col, int height, double percent)
void ui_hscrollbar(int row, int col, int width, double percent)
{
int i;
if (percent < 0) percent = 0;
/* fudge the percent a bit -- this makes sure it shows up properly */
percent -= 0.05;
if (percent < 0.01) percent = 0.01;
if (percent > 100.0) percent = 100.0;
SLsmg_set_color(SCROLLBAR);
......@@ -435,6 +444,7 @@ static void ui_dialog_drawlines(int row, int col, int height, int width,
char **buf, int topline, int leftcol,
int numlines, int scroll)
{
/* helper function for ui_dialog */
int ri;
int hoffset = ((scroll & SCROLLBAR_HORIZ) ? 6 : 4);
int woffset = ((scroll & SCROLLBAR_VERT) ? 5 : 3);
......@@ -447,7 +457,7 @@ static void ui_dialog_drawlines(int row, int col, int height, int width,
if (strlen(buf[ri]) > leftcol)
SLsmg_write_nstring(buf[ri]+leftcol, width - woffset);
}
if (scroll & SCROLLBAR_VERT)
if (scroll & SCROLLBAR_VERT && numlines > height-hoffset)
ui_vscrollbar(row+1, col+width-2, height-hoffset,
((double)topline+1)/numlines);
if (scroll & SCROLLBAR_HORIZ)
......@@ -457,14 +467,15 @@ static void ui_dialog_drawlines(int row, int col, int height, int width,
SLsmg_refresh();
}
void ui_dialog(int row, int col, int height, int width, char *title, char *msg, int reflow, int scroll)
void ui_dialog(int row, int col, int height, int width, char *title,
char *msg, int reflow, int scroll)
{
char *reflowbuf;
int ri, c, topline = 0, leftcol = 0, numlines = 0, done = 0, redraw;
char *line, *txt = NULL, **buf = NULL;
if (reflow)
reflowbuf = reflowtext(width - 2, msg);
reflowbuf = reflowtext(width - 6, msg);
else
reflowbuf = msg;
......@@ -492,6 +503,7 @@ void ui_dialog(int row, int col, int height, int width, char *title, char *msg,
ui_dialog_drawlines(row, col, height, width, buf, topline, leftcol, numlines, scroll);
/* local event loop */
while (!done) {
redraw = 0;
c = SLkp_getkey();
......@@ -512,16 +524,17 @@ void ui_dialog(int row, int col, int height, int width, char *title, char *msg,
redraw = 1;
}
break;
case SL_KEY_LEFT:
if (leftcol > 0) {
leftcol--;
redraw=1;
}
case SL_KEY_PPAGE:
topline -= (height-5);
if (topline < 0) topline = 0;
redraw = 1;
break;
case SL_KEY_RIGHT:
leftcol++;
redraw=1;
case SL_KEY_NPAGE:
topline += (height-5);
if (topline > numlines - 1) topline = numlines-1;
redraw = 1;
break;
}
if (redraw) {
ui_dialog_drawlines(row, col, height, width, buf, topline, leftcol,
......@@ -598,9 +611,13 @@ void ui_redrawcursor(int index)
ui_redrawchooser();
}
ui_vscrollbar(_chooserinfo.rowoffset, _chooserinfo.coloffset +
_chooserinfo.width - 1, _chooserinfo.height,
((double)index+1)/_taskpackages->count);
SLsmg_set_color(CURSOROBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + 2);
SLsmg_write_string(_taskpackagesary[index]->selected == 0 ? " " : "*");
SLsmg_refresh();
}
......@@ -614,7 +631,7 @@ void ui_clearcursor(int index)
void ui_showhelp(void)
{
_chooserinfo.whichwindow = HELPWINDOW;
ui_dialog(3, 3, ROWS - 9, COLUMNS - 10, _("Help"), HELPTXT, 1, SCROLLBAR_VERT);
ui_dialog(3, 3, ROWS - 7, COLUMNS - 10, _("Help"), HELPTXT, 1, SCROLLBAR_VERT);
_chooserinfo.whichwindow = CHOOSERWINDOW;
ui_drawscreen();
}
......@@ -623,7 +640,7 @@ void ui_showpackageinfo(void)
{
struct package_t *pkg, *deppkg;
int i;
int width = COLUMNS - 6;
int width = COLUMNS - 10;
char buf[4096];
char shortbuf[256];
char *desc = NULL;
......
/* $Id: strutl.c,v 1.2 1999/11/23 05:12:43 tausq Exp $ */
/* $Id: strutl.c,v 1.3 2000/01/16 02:55:30 tausq Rel $ */
#include "strutl.h"
#include <string.h>
......@@ -56,6 +56,7 @@ char *reflowtext(int width, char *ptxt)
strncat(buf, begin, end - begin);
strcat(buf, "\n");
begin = end + 1;
if (isspace(*begin)) begin++;
} else {
/* this is where it gets gross.. nowhere to break the line */
end = begin + width - 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment