view examples/dsl/query.h @ 15:f5acaf0c8a29

Don't cast through "volatile int". Causes a gcc warning nowadays. XXX: should put something else back here to frighten the optimizer
author David A. Holland
date Tue, 31 May 2022 01:00:55 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*****

 AnaGram Programming Examples

 A Dos Script Language
 Query Table Definitions

 Copyright 1993 Parsifal Software. All Rights Reserved.

 This software is provided 'as-is', without any express or implied
 warranty.  In no event will the authors be held liable for any damages
 arising from the use of this software.

 Permission is granted to anyone to use this software for any purpose,
 including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:

 1. The origin of this software must not be misrepresented; you must not
    claim that you wrote the original software. If you use this software
    in a product, an acknowledgment in the product documentation would be
    appreciated but is not required.
 2. Altered source versions must be plainly marked as such, and must not be
    misrepresented as being the original software.
 3. This notice may not be removed or altered from any source distribution.

*****/

#ifndef QUERY_H
#define QUERY_H

#include "screen.h"
#include "stack.h"
#include <stddef.h>
#include "symbol.h"

struct query_item {
  int  id;
  int *value;
  int *prompt;
  int *explanation;
  action_pointer action;
};

class screen_descriptor {
public:
  int *title;
  unsigned char color, entry_color, highlight_color;
  int height, width;
  pair<int> pos;
  screen_descriptor() {
    screen_rect display = at(0,0);
    title = NULL;
    color = entry_color = highlight_color = 0;
    height = display.size.y;
    width  = display.size.x;
    pos.x = pos.y = -1;
  }
};

class query_table {
public:
  int *title;
  screen_rect window_box;       // window for box
  screen_rect window;           // window for data
  char_cell *previous;          // previous content of window
  int nq;                       // number of query items
  query_item *q;                // query item array
  screen_rect *sr;              // display rectangles
  unsigned char *field_color;
  int nbl;                      // blank lines to insert between entries
  int first_line;               // vertical location of first line
  int title_line;               // vertical location of title line
  int exp_line;                 // vertical location of explanation
  int dx;                       // horizontal location of data field
  int px;                       // horizontal location of prompt field
  int pw;                       // prompt field width
  int dw;                       // data field width
  int current_field;
  unsigned char color, highlight_color, entry_color;
  int height, width;


// Constructor

  query_table(stack<query_item> &qs, screen_descriptor *scd);

// Destructor

  ~query_table();

  query_table &resize(void);
  query_table &refresh(void);
  int edit_line(void);
};

extern stack <query_item> qs;

#endif