Browse Source

Displays package shortdescs in a seperate column. Auto-calculates the width

of the column of names based on the maximum task package name length. (Added
field to packages_t to hold that.
tags/debian_version_1_0-8
Joey Hess 22 years ago
parent
commit
ddec5b13d5
3 changed files with 33 additions and 22 deletions
  1. +26
    -17
      data.c
  2. +2
    -1
      data.h
  3. +5
    -4
      slangui.c

+ 26
- 17
data.c View File

@@ -1,4 +1,4 @@
/* $Id: data.c,v 1.5 2000/01/07 22:27:48 joeyh Exp $ */
/* $Id: data.c,v 1.6 2000/01/07 22:45:09 joeyh 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
*/
@@ -105,7 +105,8 @@ static int splitlinkdesc(const char *desc, char ***array)

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)
const char *suggestsdesc, const char *shortdesc, const char *longdesc,
const int istask)
{
/* Adds package to the package list binary tree */
struct package_t *node = NEW(struct package_t);
@@ -118,25 +119,33 @@ static void addpackage(struct packages_t *pkgs,
/* DPRINTF("Adding package %s to list\n", name); */
memset(node, 0, sizeof(struct package_t));
node->name = STRDUP(name);
c = node->prettyname = STRDUP(name+5);
while(c[0]) {
if (c[0] == '-') {
c[0] = ' ';
space=1;
}
else if(space) {
c[0] = toupper(c[0]);
space=0;
if (istask) {
c = node->prettyname = STRDUP(name+5);
/* Prettify name */
while (c[0]) {
if (c[0] == '-') {
c[0] = ' ';
space=1;
}
else if (space) {
c[0] = toupper(c[0]);
space=0;
}
c++;
}
c++;
/* Keep track of the longest name. */
if (pkgs->maxnamelen < (c - node->prettyname))
pkgs->maxnamelen = c - node->prettyname;
}
node->shortdesc = STRDUP(shortdesc);
node->longdesc = STRDUP(longdesc);

if (dependsdesc) node->dependscount = splitlinkdesc(dependsdesc, &node->depends);
if (recommendsdesc) node->recommendscount = splitlinkdesc(recommendsdesc, &node->recommends);
if (suggestsdesc) node->suggestscount = splitlinkdesc(suggestsdesc, &node->suggests);
p = tsearch((void *)node, &pkgs->packages, packagecompare);
VERIFY(p != NULL);
pkgs->count++;
@@ -237,10 +246,10 @@ void packages_readlist(struct packages_t *taskpkgs, struct packages_t *pkgs)
}
}

addpackage(pkgs, name, NULL, NULL, NULL, shortdesc, NULL);
if (strncmp(name, "task-", 5) == 0)
addpackage(taskpkgs, name, dependsdesc, recommendsdesc, suggestsdesc, shortdesc, longdesc);
addpackage(pkgs, name, NULL, NULL, NULL, shortdesc, NULL, 0);
if (strncmp(name, "task-", 5) == 0)
addpackage(taskpkgs, name, dependsdesc, recommendsdesc, suggestsdesc, shortdesc, longdesc, 1);
if (name != NULL) FREE(name);
if (dependsdesc != NULL) FREE(dependsdesc);
if (recommendsdesc != NULL) FREE(recommendsdesc);


+ 2
- 1
data.h View File

@@ -1,4 +1,4 @@
/* $Id: data.h,v 1.2 2000/01/07 22:27:48 joeyh Exp $ */
/* $Id: data.h,v 1.3 2000/01/07 22:45:09 joeyh Exp $ */
#ifndef _DATA_H
#define _DATA_H

@@ -18,6 +18,7 @@ struct package_t {

struct packages_t {
int count;
int maxnamelen;
void *packages;
};



+ 5
- 4
slangui.c View File

@@ -1,4 +1,4 @@
/* $Id: slangui.c,v 1.10 2000/01/07 22:27:48 joeyh Exp $ */
/* $Id: slangui.c,v 1.11 2000/01/07 22:45:09 joeyh 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 */
@@ -346,12 +346,13 @@ void ui_drawchooseritem(int index)
SLsmg_set_color(CHOOSEROBJ);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + 1);
snprintf(buf, 1024, "[%c] %s: %s",
snprintf(buf, 1024, "[%c] %s",
(_taskpackagesary[index]->selected == 0 ? ' ' : '*'),
_taskpackagesary[index]->prettyname, _taskpackagesary[index]->shortdesc);
_taskpackagesary[index]->prettyname);
/* I fear the 1 below is an off-by-one error somewhere -- Joeyh */
SLsmg_write_nstring(buf, _chooserinfo.width - 1);
SLsmg_gotorc(_chooserinfo.rowoffset + index - _chooserinfo.topindex, _chooserinfo.coloffset + _taskpackages->maxnamelen + 5);
SLsmg_write_nstring(_taskpackagesary[index]->shortdesc, _chooserinfo.width - _taskpackages->maxnamelen - 5);
}

void ui_toggleselection(int index)


Loading…
Cancel
Save