Browse Source

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

tags/adam_release_2-2-2
Randolph Chung 22 years ago
parent
commit
6942cc6762
6 changed files with 28 additions and 9 deletions
  1. +2
    -2
      TODO
  2. +2
    -1
      data.c
  3. +4
    -1
      macros.h
  4. +17
    -4
      slangui.c
  5. +1
    -0
      slangui.h
  6. +2
    -1
      util.c

+ 2
- 2
TODO View File

@@ -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

+ 2
- 1
data.c View File

@@ -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"



+ 4
- 1
macros.h View File

@@ -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; \


+ 17
- 4
slangui.c View File

@@ -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
- 0
slangui.h View File

@@ -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);



+ 2
- 1
util.c View File

@@ -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