Browse Source

More resizing fixes. Though it still doesn't work quite right :(

keep-around/43e990ab3f4cc50982f8dbc32e3465ca7c827876
Randolph Chung 24 years ago
parent
commit
6942cc6762
  1. 4
      TODO
  2. 3
      data.c
  3. 5
      macros.h
  4. 21
      slangui.c
  5. 1
      slangui.h
  6. 3
      util.c

4
TODO

@ -1,4 +1,4 @@
$Id: TODO,v 1.2 1999/11/21 22:20:34 tausq Exp $
- fix screen resize code
$Id: TODO,v 1.3 1999/11/23 05:39:27 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

3
data.c

@ -1,4 +1,4 @@
/* $Id: data.c,v 1.1 1999/11/21 22:01:04 tausq Exp $ */
/* $Id: data.c,v 1.2 1999/11/23 05:39:27 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
*/
@ -10,6 +10,7 @@
#include <string.h>
#include <ctype.h>
#include "slangui.h"
#include "util.h"
#include "macros.h"

5
macros.h

@ -1,4 +1,4 @@
/* $Id: macros.h,v 1.1 1999/11/21 22:01:04 tausq Exp $ */
/* $Id: macros.h,v 1.2 1999/11/23 05:39:27 tausq Exp $ */
#ifndef _MACROS_H
#define _MACROS_H
@ -14,6 +14,7 @@
} while (0);
#define ASSERT(cond) \
if (!(cond)) { \
if (ui_running()) ui_shutdown(); \
fprintf(stderr, "ASSERTION FAILED at %s:%d! (%s)\n", __FILE__, __LINE__, #cond); \
exit(255); \
}
@ -35,6 +36,7 @@
/* Do you see a perl influence? :-) */
#define DIE(fmt, arg...) \
do { \
if (ui_running()) ui_shutdown(); \
fprintf(stderr, "Fatal error encountered at %s:%d\r\n\t", __FILE__, __LINE__); \
fprintf(stderr, fmt, ##arg); \
fprintf(stderr, "\r\n"); \
@ -43,6 +45,7 @@
#define PERROR(ctx) \
do { \
if (ui_running()) ui_shutdown(); \
fprintf(stderr, "I/O error at %s:%d\r\n\t", __FILE__, __LINE__); \
fprintf(stderr, "%s: %s\r\n", ctx, strerror(errno)); \
ABORT; \

21
slangui.c

@ -1,4 +1,4 @@
/* $Id: slangui.c,v 1.4 1999/11/23 05:12:43 tausq Exp $ */
/* $Id: slangui.c,v 1.5 1999/11/23 05:39:27 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 */
@ -42,6 +42,8 @@ struct _chooserinfo_t {
/* Module private variables */
static struct _chooserinfo_t _chooserinfo = {3, 3, 0, 0, 0, 0, 0};
static int _resizing = 0;
static int _initialized = 0;
static struct packages_t *_packages = NULL;
static struct packages_t *_taskpackages = NULL;
static struct package_t **_taskpackagesary = NULL;
@ -81,18 +83,26 @@ void ui_init(int argc, char * const argv[], struct packages_t *taskpkgs, struct
SLtt_set_color(BUTTONOBJ, NULL, "white", "red");
ui_resize();
_initialized = 1;
}
int ui_shutdown(void)
{
SLsmg_reset_smg();
SLang_reset_tty();
_initialized = 0;
return 0;
}
int ui_running(void)
{
return _initialized;
}
void ui_resize(void)
{
char buf[160];
_resizing = 1;
/* SIGWINCH handler */
if (-1 == SLang_init_tty(-1, 0, 1)) DIE(_("Unable to initialize the terminal"));
SLtt_get_terminfo();
@ -122,6 +132,7 @@ void ui_resize(void)
write_centered_str(ROWS-1, 0, COLUMNS,
_(" h - Help SPACE - Toggle selection i - Task info q - Exit"));
_resizing = 0;
switch (_chooserinfo.whichwindow) {
case CHOOSERWINDOW: ui_drawscreen(); break;
case HELPWINDOW: ui_showhelp(); break;
@ -268,10 +279,12 @@ void ui_dialog(int row, int col, int height, int width, char *title, char *msg,
ui_button(row+height-2, col+(width-4)/2, " OK ");
SLsmg_refresh();
SLsig_block_signals();
do {
c = SLkp_getkey();
} while (!(c == '\n' || c == '\r' || c == SL_KEY_ENTER || isspace(c)));
c = 0;
if (SLang_input_pending(5)) c = SLkp_getkey();
} while (!(c == '\n' || c == '\r' || c == SL_KEY_ENTER || isspace(c)) && (_resizing == 0));
SLsig_unblock_signals();
if (reflow) FREE(reflowbuf);
}

1
slangui.h

@ -6,6 +6,7 @@ struct packages_t;
void ui_init(int argc, char * const argv[], struct packages_t *taskpkgs, struct packages_t *packages);
int ui_shutdown(void);
int ui_running(void);
void ui_resize(void);
int ui_eventloop(void);

3
util.c

@ -1,9 +1,10 @@
/* $Id: util.c,v 1.1 1999/11/21 22:01:04 tausq Exp $ */
/* $Id: util.c,v 1.2 1999/11/23 05:39:27 tausq Exp $ */
#include "util.h"
#include <string.h>
#include <stdlib.h>
#include "slangui.h"
#include "macros.h"
#ifdef DEBUG

Loading…
Cancel
Save