| 1 |
/* file: mainpick.c |
| 2 |
* Author: Jean Thierry-Mieg ([email protected]) |
| 3 |
* Copyright (C) J Thierry-Mieg and R Durbin, 1991 |
| 4 |
* ------------------------------------------------------------------- |
| 5 |
* Acedb is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License |
| 7 |
* as published by the Free Software Foundation; either version 2 |
| 8 |
* of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt |
| 19 |
* ------------------------------------------------------------------- |
| 20 |
* This file is part of the ACEDB genome database package, written by |
| 21 |
* Richard Durbin (MRC LMB, UK) [email protected], and |
| 22 |
* Jean Thierry-Mieg (CRBM du CNRS, France) [email protected] |
| 23 |
* |
| 24 |
* Description: |
| 25 |
* Exported functions: |
| 26 |
* HISTORY: |
| 27 |
* Last edited: Oct 21 17:23 2005 (edgrif) |
| 28 |
* * May 8 14:41 2000 (edgrif): Added "full reindex" option to Read Models. |
| 29 |
* * Dec 3 14:42 1998 (edgrif): Change calls to new interface to aceversion. |
| 30 |
* * Oct 22 11:45 1998 (edgrif): Remove dec. of pickDraw, put in acedb.h |
| 31 |
* * Jun 11 1:38 1996 (rbrusk): |
| 32 |
* - WIN32 letting double pickPick() do its thing in pickCreate() |
| 33 |
* * Jun 6 17:44 1996 (rd) |
| 34 |
* * Jun 5 1:38 1996 (rbrusk): |
| 35 |
* - TEXT_ENTRY_FUNC_CAST added to classDisplay() and grepDisplay() |
| 36 |
* callback arguments to graphTextScrollEntry() |
| 37 |
* * Jun 5 1:38 1996 (rbrusk): |
| 38 |
* - WIN32 port changes to 4.3 |
| 39 |
* * May 10 21:13 1996 (rd) |
| 40 |
* * Sep 12 17:45 1992 (rd): in classDisplay() added quick check if |
| 41 |
template is a valid object name (Alan's suggestion) |
| 42 |
* * Dec 6 13:28 1991 (mieg): autocompletion system |
| 43 |
* * Dec 2 20:59 1991 (mieg): if(isdisplayBlock) no autoPick |
| 44 |
* because this create a textBound on wrong graphtype somehow ? |
| 45 |
* * Nov 5 18:28 1991 (mieg): call to keySetShow changed |
| 46 |
* Created: Tue Nov 5 18:26:56 1991 (mieg) |
| 47 |
* CVS info: $Id: mainpick.c,v 1.165 2005/10/21 16:31:08 edgrif Exp $ |
| 48 |
*------------------------------------------------------------------- |
| 49 |
*/ |
| 50 |
|
| 51 |
/* #define CHRONO to get Chrono in the admin menu */ |
| 52 |
#include <wh/acelib.h> |
| 53 |
#include <wh/acedb.h> |
| 54 |
#include <wh/display.h> |
| 55 |
#include <wh/main.h> |
| 56 |
#include <wh/bitset.h> |
| 57 |
#include <wh/bindex.h> |
| 58 |
#include <wh/lex.h> |
| 59 |
#include <wh/pick.h> |
| 60 |
#include <wh/client.h> |
| 61 |
#include <wh/pref.h> |
| 62 |
#include <wh/parse.h> |
| 63 |
#include <wh/help.h> |
| 64 |
#include <wh/model.h> |
| 65 |
#include <wh/dna.h> /* for dnaAnalyse */ |
| 66 |
#include <wh/dendrogram.h> /* for readTreeFile et al. */ |
| 67 |
#include <wh/query.h> |
| 68 |
#include <wh/session.h> |
| 69 |
#include <wh/longtext.h> |
| 70 |
#include <wh/dump.h> |
| 71 |
#include <wh/querydisp.h> |
| 72 |
#include <wh/sessiondisp.h> |
| 73 |
#include <wh/tabledisp.h> |
| 74 |
#include <wh/keysetdisp.h> |
| 75 |
#include <wh/layoutdisp.h> |
| 76 |
#include <wh/statusdisp.h> |
| 77 |
#include <whooks/sysclass.h> |
| 78 |
#include <wh/sigsubs.h> |
| 79 |
|
| 80 |
/************************************************************/ |
| 81 |
|
| 82 |
enum {ACTIVITY_LENGTH = 28, /* Max length of activity status |
| 83 |
indicator */ |
| 84 |
TEMPLATE_LENGTH = 256, |
| 85 |
OLD_TEMPLATE_LENGTH = 20} ; /* Must be smaller than TEMPLATE_LENGTH */ |
| 86 |
|
| 87 |
typedef struct PickStruct { |
| 88 |
magic_t *magic ; /* == &Pick_MAGIC */ |
| 89 |
int curr, currBox ; |
| 90 |
KEY currClasse ; |
| 91 |
char template[TEMPLATE_LENGTH] ; |
| 92 |
int templateBox ; |
| 93 |
char* grepText ; |
| 94 |
int grepBox , longGrepBox , m1, m2, m3, modeBox1, modeBox2 ; |
| 95 |
BOOL longGrep ; |
| 96 |
char whatdoIdoText[ACTIVITY_LENGTH] ; |
| 97 |
int whatdoIdoBox, classListBox ; |
| 98 |
Graph mainGraph ; |
| 99 |
Graph ksdisp_graph ; /* graph of KeySet window */ |
| 100 |
KEYSET oblist ; |
| 101 |
KeySetDisp ksdisp_handle ; |
| 102 |
int admin_box ; /* Need to dynamically change the menu. */ |
| 103 |
} *Pick ; |
| 104 |
|
| 105 |
#define PICKGET(myname) Pick pick ;\ |
| 106 |
\ |
| 107 |
if (!graphAssFind (&Pick_MAGIC, &pick)) \ |
| 108 |
messcrash ("%s can't find pointer",myname) ; \ |
| 109 |
if (pick->magic != &Pick_MAGIC) \ |
| 110 |
messcrash ("%s received a wrong pointer",myname) |
| 111 |
|
| 112 |
|
| 113 |
/************************************************************/ |
| 114 |
static void prefMainRedraw(BOOL pref_value) ; |
| 115 |
static void mainStatusDisplay (char *text, void *user_pointer); |
| 116 |
static void mainWindowResize (void); |
| 117 |
static void mainWindowPick (int k, double x, double y, int modifier_unused); |
| 118 |
static void mainWindowDestroy (void) ; |
| 119 |
static void mainWindowReReadClasses (void); /* upon model-change */ |
| 120 |
static void mainWindowCleanUp (void) ; |
| 121 |
|
| 122 |
static int pickClassComplete (char *cp, int len) ; |
| 123 |
static BOOL classListMenuCall (KEY k, int box) ; |
| 124 |
static void pickDoDrawOld (void); |
| 125 |
static void pickDoDrawNew (void) ; |
| 126 |
static void pickModeChoice1 (void) ; |
| 127 |
static void exitButtonAction (void); |
| 128 |
static void oldmenuSaveAction (void); |
| 129 |
static void oldmenuWriteAccess (void); |
| 130 |
|
| 131 |
static void oldmenuReadModels (void); |
| 132 |
static void oldmenuReadModelsAndReindex(void) ; |
| 133 |
static void doReadModels(BOOL complete_reindex) ; |
| 134 |
|
| 135 |
static void obDisplay (Pick pick, BOOL show1, int state); |
| 136 |
static BOOL classDisplay (void); |
| 137 |
static BOOL classDisplayNew (int curr); |
| 138 |
static void grepDisplay (char *entry); |
| 139 |
static void grepDisplayNew (int curr); |
| 140 |
|
| 141 |
static void serverOn (void); |
| 142 |
static void serverOff (void); |
| 143 |
|
| 144 |
static void swopSigCatchMenuText(char *sig_txt, int admin_box) ; |
| 145 |
static void saveAndKeepWriteAccess(void) ; |
| 146 |
|
| 147 |
static void saveCB(void *unused) ; |
| 148 |
static void quitCB(void *unused) ; |
| 149 |
|
| 150 |
|
| 151 |
/* these externs have to be removed and replaced with includes |
| 152 |
that declare the prototypes for these functions */ |
| 153 |
extern void |
| 154 |
oxgridCreate(void), |
| 155 |
alignMaps(void), |
| 156 |
updateData(void), |
| 157 |
addKeys(void), |
| 158 |
editPreferences(void), |
| 159 |
queryCreate(void), |
| 160 |
qbuildCreate(void), |
| 161 |
qbeCreate(void), |
| 162 |
alignMaps(void); |
| 163 |
|
| 164 |
#ifdef ACEMBLY |
| 165 |
extern void blyControl (void); |
| 166 |
#endif /* ACEMBLY */ |
| 167 |
|
| 168 |
#ifdef DEBUG |
| 169 |
extern void acedbtest(void); |
| 170 |
#endif /* DEBUG acedbtest */ |
| 171 |
|
| 172 |
#ifdef CHRONO |
| 173 |
extern void chronoShow(void); |
| 174 |
#endif |
| 175 |
|
| 176 |
#ifndef ACEMBLY |
| 177 |
/* oxgrid not included in acembly */ |
| 178 |
extern void oxgridCreate(void) ; |
| 179 |
extern BOOL oxgridPossible(void) ; |
| 180 |
#endif /* !ACEMBLY */ |
| 181 |
|
| 182 |
/************************************************************/ |
| 183 |
|
| 184 |
static magic_t Pick_MAGIC = "Pick"; |
| 185 |
|
| 186 |
static Pick mainPick = 0 ; |
| 187 |
|
| 188 |
static int firstClassBox = 0 ; |
| 189 |
static Array classList = 0 ; /* Array of FREEOPT */ |
| 190 |
static Array classLayout = 0 ; /* Array of LAYOUT */ |
| 191 |
static BOOL isNewLayout = TRUE ; /* mieg: new layout */ |
| 192 |
static VoidRoutine mainWindowQuitRoutine = 0; |
| 193 |
|
| 194 |
static char *pickFirstClass = 0; |
| 195 |
static int pickFirstBox = 0; |
| 196 |
static char *pickFirstTemplate = 0; |
| 197 |
|
| 198 |
|
| 199 |
/* long main menu for old-style main-window */ |
| 200 |
|
| 201 |
static MENU mainMenu ; |
| 202 |
|
| 203 |
MENUOPT mainMenuSpec[] = { |
| 204 |
{ exitButtonAction, "Quit"}, |
| 205 |
{ help , "Help"}, |
| 206 |
{ graphCleanUp, "Clean up"}, |
| 207 |
{ statusDisplayCreate,"Program status"}, |
| 208 |
#ifdef ACEMBLY |
| 209 |
{ blyControl, "Acembly"}, |
| 210 |
#else |
| 211 |
{ updateData, "Add Update File"}, |
| 212 |
{ editPreferences, "Preferences"}, |
| 213 |
#endif |
| 214 |
{ menuSpacer, ""}, |
| 215 |
#if defined(WIN32) |
| 216 |
{ 0, "Query"}, |
| 217 |
#endif |
| 218 |
{ queryCreate, "Query"}, |
| 219 |
#if !defined(MACINTOSH) |
| 220 |
{ qbeCreate, "Query by Examples"}, |
| 221 |
#endif |
| 222 |
{ qbuildCreate, "Query builder"}, |
| 223 |
{ tableMaker, "Table Maker"}, |
| 224 |
{ aqlDisplayCreate, "AQL Query"}, |
| 225 |
#if defined(WIN32) |
| 226 |
{ 0, 0}, /* submenu trailer */ |
| 227 |
#endif |
| 228 |
{ dnaAnalyse, "DNA Analysis"}, |
| 229 |
{ menuSpacer, ""}, |
| 230 |
#ifndef ACEMBLY |
| 231 |
#if defined(WIN32) |
| 232 |
/* (rbrusk) July 17, 1998 - Dendrogram functions */ |
| 233 |
{ 0, "Phylogenetic Trees"}, |
| 234 |
#endif |
| 235 |
{ readTaxonomicTree, "Read Taxonomy File"}, |
| 236 |
{ readDNATree, "Read DNA Tree File"}, |
| 237 |
{ readProteinTree, "Read Protein Tree File"}, |
| 238 |
#if defined(WIN32) |
| 239 |
{ 0, 0}, /* submenu trailer */ |
| 240 |
#endif |
| 241 |
/* option below added by jld */ |
| 242 |
{ oxgridCreate, "Comparative Maps"}, |
| 243 |
#endif /* !ACEMBLY */ |
| 244 |
{ menuSpacer, ""}, |
| 245 |
{ addKeys, "Add-Alias-Rename"}, |
| 246 |
{ parseControl, "Read .ace files"}, |
| 247 |
{ alignMaps, "Align maps"}, |
| 248 |
{ oldmenuReadModels, "Read models"}, |
| 249 |
{ oldmenuReadModelsAndReindex, "Read models and full reindex"}, |
| 250 |
|
| 251 |
{ dumpAll, "Dump"}, |
| 252 |
{ dumpReadAll, "Read Dump Files"}, |
| 253 |
|
| 254 |
{ sessionControl, "Session control"}, |
| 255 |
|
| 256 |
#ifdef CHRONO |
| 257 |
{ menuSpacer, ""}, |
| 258 |
{ chronoShow, "Chronometer"}, |
| 259 |
#endif /* CHRONO */ |
| 260 |
|
| 261 |
#ifdef DEBUG |
| 262 |
{ menuSpacer, ""}, |
| 263 |
{ acedbtest, "Test subroutine"}, |
| 264 |
#endif /* DEBUG acedbtest */ |
| 265 |
|
| 266 |
{ menuSpacer , ""}, |
| 267 |
{ oldmenuWriteAccess, "Write Access"} , |
| 268 |
{ menuSpacer , "" }, |
| 269 |
{ oldmenuSaveAction, "Save" }, |
| 270 |
{ 0, 0 } /* end of menu marker */ |
| 271 |
}; |
| 272 |
|
| 273 |
/************************************************************/ |
| 274 |
|
| 275 |
static MENUOPT pickNewMenu[] = { |
| 276 |
{ help, "Help"}, |
| 277 |
{ graphPrint, "Print"}, |
| 278 |
#ifdef ACEMBLY |
| 279 |
{ menuSpacer, ""}, |
| 280 |
{ blyControl, "Acembly"}, |
| 281 |
#endif |
| 282 |
{ graphDestroy,"Exit"}, |
| 283 |
{ 0,0} |
| 284 |
} ; |
| 285 |
|
| 286 |
#ifndef ACEMBLY |
| 287 |
/* OXGRIDs not included in Acembly */ |
| 288 |
static MENUOPT pickNewOxMenu[] = |
| 289 |
{ |
| 290 |
{ graphDestroy, "Exit"}, |
| 291 |
{ help, "Help"}, |
| 292 |
{ graphPrint, "Print"}, |
| 293 |
{ menuSpacer, ""}, |
| 294 |
{ oxgridCreate, "Ox Grids"}, |
| 295 |
{ 0,0 } |
| 296 |
} ; |
| 297 |
#endif |
| 298 |
|
| 299 |
/*************************************/ |
| 300 |
|
| 301 |
static FREEOPT queryButtonFreeMenu[] = |
| 302 |
{ |
| 303 |
{8,"Query menu"}, |
| 304 |
{'h', "Help on Query"}, |
| 305 |
{0, ""}, |
| 306 |
{ 'q', "Query"}, |
| 307 |
#if !defined(MACINTOSH) |
| 308 |
{ 'b', "Query by Examples"}, |
| 309 |
#else /* always keep same number of lines */ |
| 310 |
{0, ""}, |
| 311 |
#endif |
| 312 |
{ 'u', "Query builder"}, |
| 313 |
{ 's', "Table Maker"}, |
| 314 |
{ 'a', "AQL Query"}, |
| 315 |
{ 'd', "DNA Analysis"}, |
| 316 |
} ; |
| 317 |
|
| 318 |
/*************************************/ |
| 319 |
|
| 320 |
/* Stuff for toggling signal catching, default is to catch signals so that */ |
| 321 |
/* acedb clear up is done. */ |
| 322 |
#define SIG_ON_TEXT "Turn Signal Catching On" |
| 323 |
#define SIG_OFF_TEXT "Turn Signal Catching Off" |
| 324 |
|
| 325 |
|
| 326 |
static FREEOPT adminButtonFreeMenu[] = |
| 327 |
{ |
| 328 |
#if (defined CHRONO && defined DEBUG) |
| 329 |
{11, "Admin menu"}, |
| 330 |
#elif (defined CHRONO || defined DEBUG) |
| 331 |
{9, "Admin menu"}, |
| 332 |
#else |
| 333 |
{7, "Admin menu"}, |
| 334 |
#endif /* !CHRONO !DEBUG */ |
| 335 |
{'s', "Program Status"}, |
| 336 |
{'S', "Session Control"}, |
| 337 |
{'p', "Preferences"}, |
| 338 |
{'x', SIG_OFF_TEXT}, |
| 339 |
{ 0, ""}, |
| 340 |
{'d', "Dump All"}, |
| 341 |
{'D', "Read Dump Files"}, |
| 342 |
|
| 343 |
#ifdef CHRONO |
| 344 |
{0,""}, |
| 345 |
{'c', "Chronometer"}, |
| 346 |
#endif /* CHRONO */ |
| 347 |
|
| 348 |
#ifdef DEBUG |
| 349 |
{0,""} |
| 350 |
{'t', "Test subroutine"}, |
| 351 |
#endif /* DEBUG acedbtest */ |
| 352 |
} ; |
| 353 |
|
| 354 |
/*************************************/ |
| 355 |
|
| 356 |
/* this menu is only displayed if write access is possible */ |
| 357 |
/* NOTE: |
| 358 |
* (1) if you change the number of items adjust the |
| 359 |
* integer in the first line to hold the new number of lines |
| 360 |
* (2) if you change the order of items be sure to adjust the |
| 361 |
* code which fiddles the menu-items 'Gain write access' |
| 362 |
* in pickDoDrawNew()! */ |
| 363 |
static FREEOPT editButtonFreeMenu[] = |
| 364 |
{ |
| 365 |
{12, "Edit menu"}, |
| 366 |
{'u', "Add Update"}, |
| 367 |
{'A', "Align maps"}, |
| 368 |
{0,""}, |
| 369 |
{'r', "Read .ace file"}, |
| 370 |
{'a', "Add/Delete/Rename/Alias objects"}, |
| 371 |
{0,""}, |
| 372 |
{'T', "Create New Dendrogram"}, |
| 373 |
{'O', "Comparative Maps"}, |
| 374 |
{0,""}, |
| 375 |
{'m', "Read Models"}, |
| 376 |
{'M', "Read Models and full reindex"}, |
| 377 |
{'w', "Gain write access"} |
| 378 |
} ; |
| 379 |
|
| 380 |
/*************************************/ |
| 381 |
|
| 382 |
static FREEOPT saveButtonFreeMenu[] = |
| 383 |
{ |
| 384 |
{3, "Save menu"}, |
| 385 |
{'s', "Save session and keep write access"}, |
| 386 |
{'t', "Save session and lose write access"}, |
| 387 |
{'d', "Drop write access (no save)"}, |
| 388 |
} ; |
| 389 |
|
| 390 |
|
| 391 |
/****************************************************************** |
| 392 |
************************* public functions *********************** |
| 393 |
******************************************************************/ |
| 394 |
|
| 395 |
void mainSetInitClass (char *initclass) |
| 396 |
{ |
| 397 |
pickFirstClass = strnew (initclass, 0); |
| 398 |
|
| 399 |
return; |
| 400 |
} /* mainSetInitClass */ |
| 401 |
|
| 402 |
void mainSetInitTemplate (char *inittemplate) |
| 403 |
{ |
| 404 |
pickFirstTemplate = strnew (inittemplate, 0); |
| 405 |
|
| 406 |
return; |
| 407 |
} /* mainSetInitTemplate */ |
| 408 |
|
| 409 |
/************************************************************/ |
| 410 |
|
| 411 |
VoidRoutine mainWindowQuitRegister (VoidRoutine func) |
| 412 |
{ |
| 413 |
VoidRoutine old = mainWindowQuitRoutine; |
| 414 |
|
| 415 |
if (func) |
| 416 |
mainWindowQuitRoutine = func; |
| 417 |
|
| 418 |
return old; |
| 419 |
} /* mainWindowQuitRegister */ |
| 420 |
|
| 421 |
/****************************************************************/ |
| 422 |
|
| 423 |
/* These two short functions are application wide callbacks that get registered with graph |
| 424 |
* and are called from any window when the user presses Cntl-S for save or Cntl-Q for quit. |
| 425 |
* They get registered by pickCreate() and don't actually use the pointer passed in at the |
| 426 |
* moment. */ |
| 427 |
static void saveCB(void *unused) |
| 428 |
{ |
| 429 |
saveAndKeepWriteAccess() ; |
| 430 |
|
| 431 |
return ; |
| 432 |
} |
| 433 |
|
| 434 |
static void quitCB(void *unused) |
| 435 |
{ |
| 436 |
exitButtonAction() ; |
| 437 |
|
| 438 |
return ; |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
Graph pickCreate (void) |
| 445 |
{ |
| 446 |
BOOL selectFirst = !isNewLayout ; |
| 447 |
struct messContextStruct statusContext; |
| 448 |
GlobalCallbacksStruct acedb_callbacks = {{saveCB, NULL}, {quitCB, NULL}} ; |
| 449 |
|
| 450 |
writeAccessPossible(); /* establish access status, get |
| 451 |
possible warning message out of the way */ |
| 452 |
|
| 453 |
mainPick = (Pick) messalloc (sizeof(struct PickStruct)); |
| 454 |
mainPick->magic = &Pick_MAGIC ; |
| 455 |
mainPick->grepText = (char*) messalloc (256) ; /* free'd in mainWindowDestroy */ |
| 456 |
|
| 457 |
|
| 458 |
/* Register a callback with prefsubs so that when user changes main */ |
| 459 |
/* window style we get called. */ |
| 460 |
if (!prefSetFunc("OLD_STYLE_MAIN_WINDOW", (void *)prefMainRedraw)) |
| 461 |
messcrash("Unable to set callback function for preference %s", "OLD_STYLE_MAIN_WINDOW") ; |
| 462 |
|
| 463 |
mainPick->mainGraph = displayCreate ("DtMain"); |
| 464 |
|
| 465 |
graphAssociate (&Pick_MAGIC, mainPick) ; |
| 466 |
graphRegister (PICK, mainWindowPick) ; |
| 467 |
graphRegister (RESIZE, mainWindowResize) ; |
| 468 |
graphRegister (DESTROY, mainWindowDestroy) ; |
| 469 |
graphRegisterGlobalCallbacks(&acedb_callbacks) ; |
| 470 |
|
| 471 |
|
| 472 |
pickFirstBox = 0; /* gets set if pickFirstClass matches a class */ |
| 473 |
pickDraw() ; |
| 474 |
messfree (pickFirstClass); |
| 475 |
messfree (pickFirstTemplate); /* pickDraw gets called again sometimes */ |
| 476 |
|
| 477 |
if (!pickFirstBox) |
| 478 |
pickFirstBox = 1 + firstClassBox ; /* pick the first voc */ |
| 479 |
else |
| 480 |
selectFirst = TRUE; |
| 481 |
|
| 482 |
mainPick->curr = 0 ; |
| 483 |
|
| 484 |
|
| 485 |
if (selectFirst) /* srk - replace this with select if desired behaviour |
| 486 |
is no keyset window _except_ when -initclass |
| 487 |
flag used */ |
| 488 |
{ |
| 489 |
/* fake a double click - call twice to achieve selection */ |
| 490 |
mainWindowPick (pickFirstBox, 0, 0, 0) ; |
| 491 |
mainWindowPick (pickFirstBox, 0, 0, 0) ; |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
/* We have now drawn the mainwindow and the whatdoIdoBox, |
| 496 |
* so we can now register the routine that receives the |
| 497 |
* status strings by messStatus calls anywhare in the code */ |
| 498 |
statusContext.user_func = mainStatusDisplay; |
| 499 |
statusContext.user_pointer = (void*)mainPick; |
| 500 |
messStatusRegister (statusContext); |
| 501 |
|
| 502 |
|
| 503 |
/* We now have a main-window, which we can register to be |
| 504 |
* redrawn if write access changes and the buttons |
| 505 |
* and menus need to be redraw */ |
| 506 |
writeAccessChangeRegister (pickDraw); |
| 507 |
|
| 508 |
/* change class menu when models change -> the new models |
| 509 |
* may have added a new class to the list so we need to update it */ |
| 510 |
modelChangeRegister (mainWindowReReadClasses); |
| 511 |
|
| 512 |
|
| 513 |
graphActivate(mainPick->mainGraph) ; |
| 514 |
|
| 515 |
return mainPick->mainGraph ; |
| 516 |
} /* pickCreate */ |
| 517 |
|
| 518 |
/************************************************************/ |
| 519 |
|
| 520 |
void pickDraw (void) |
| 521 |
{ |
| 522 |
Graph oldGraph = graphActive () ; |
| 523 |
|
| 524 |
if (!graphActivate (mainPick->mainGraph)) |
| 525 |
messcrash ("pickDraw() called before pickCreate() !"); |
| 526 |
|
| 527 |
{ |
| 528 |
BOOL oldLayoutStyle = isNewLayout; |
| 529 |
isNewLayout = !prefValue ("OLD_STYLE_MAIN_WINDOW") ; |
| 530 |
if (oldLayoutStyle != isNewLayout) |
| 531 |
{ |
| 532 |
mainPick->whatdoIdoBox = 0; |
| 533 |
mainPick->currBox = 0 ; |
| 534 |
mainPick->curr = 0 ; |
| 535 |
} |
| 536 |
} |
| 537 |
|
| 538 |
if (thisSession.subDataRelease) |
| 539 |
{ |
| 540 |
char *title = NULL ; |
| 541 |
|
| 542 |
if ((title = sessionDBTitle()) == NULL) |
| 543 |
title = displayGetTitle("DtMain") ; |
| 544 |
|
| 545 |
if (sessionDbName()) |
| 546 |
graphRetitle(messprintf("%s, %s, %s %d-%d", |
| 547 |
aceGetVersionString(), |
| 548 |
title, |
| 549 |
sessionDbName(), |
| 550 |
thisSession.mainDataRelease, |
| 551 |
thisSession.subDataRelease)) ; |
| 552 |
else |
| 553 |
graphRetitle(messprintf("%s, %s, %d-%d", |
| 554 |
aceGetVersionString(), |
| 555 |
title, |
| 556 |
thisSession.mainDataRelease, |
| 557 |
thisSession.subDataRelease)) ; |
| 558 |
} |
| 559 |
else |
| 560 |
{ |
| 561 |
char *title = NULL ; |
| 562 |
|
| 563 |
if ((title = sessionDBTitle()) == NULL) |
| 564 |
title = displayGetTitle("DtMain") ; |
| 565 |
|
| 566 |
if (sessionDbName()) |
| 567 |
graphRetitle(messprintf("%s, %s %s", |
| 568 |
aceGetVersionString(), |
| 569 |
title, |
| 570 |
sessionDbName())) ; |
| 571 |
else |
| 572 |
graphRetitle(messprintf("%s, %s", |
| 573 |
aceGetVersionString(), |
| 574 |
title)) ; |
| 575 |
} |
| 576 |
|
| 577 |
if (!classLayout) |
| 578 |
classLayout = layoutRead (0) ; |
| 579 |
|
| 580 |
classList = classListCreate (classList, TRUE, TRUE, FALSE, TRUE); |
| 581 |
|
| 582 |
if (isNewLayout) |
| 583 |
pickDoDrawNew() ; |
| 584 |
else |
| 585 |
pickDoDrawOld() ; |
| 586 |
|
| 587 |
|
| 588 |
graphActivate (oldGraph) ; |
| 589 |
} /* pickDraw */ |
| 590 |
|
| 591 |
/************************************************************/ |
| 592 |
|
| 593 |
void pickPopMain (void) |
| 594 |
{ |
| 595 |
if(graphActivate(mainPick->mainGraph)) |
| 596 |
graphPop() ; |
| 597 |
} |
| 598 |
|
| 599 |
/************************************************************/ |
| 600 |
|
| 601 |
BOOL checkWriteAccess(void) |
| 602 |
/* interactive way to check, whether we have write access. |
| 603 |
* Used in by functions that need write access, but want to |
| 604 |
* enable the user to grab it, if we don't have it already, |
| 605 |
* and otherwise (when it returns FALSE) return from that func */ |
| 606 |
{ |
| 607 |
if (isWriteAccess()) |
| 608 |
return TRUE; |
| 609 |
|
| 610 |
if (writeAccessPossible()) |
| 611 |
{ |
| 612 |
if (messQuery("You do not have Write Access, " |
| 613 |
"shall I get it for you?")) |
| 614 |
{ |
| 615 |
/* try to get it */ |
| 616 |
if (sessionGainWriteAccess()) |
| 617 |
/* it worked */ |
| 618 |
return TRUE; |
| 619 |
else |
| 620 |
/* we couldn't get it */ |
| 621 |
return FALSE; |
| 622 |
} |
| 623 |
else |
| 624 |
/* didn't want to gain write access */ |
| 625 |
return FALSE; |
| 626 |
} |
| 627 |
|
| 628 |
|
| 629 |
/* impossible to get write access */ |
| 630 |
messout("Sorry, you cannot gain Write Access"); |
| 631 |
return FALSE; |
| 632 |
} /* checkWriteAccess */ |
| 633 |
|
| 634 |
/************************************************************/ |
| 635 |
|
| 636 |
void mainApplyNewLayout (Array newLayout) |
| 637 |
/* accept new layout from layoutEditor and re-draw */ |
| 638 |
{ |
| 639 |
arrayDestroy (classLayout) ; |
| 640 |
classLayout = newLayout; |
| 641 |
|
| 642 |
pickDoDrawNew() ; |
| 643 |
|
| 644 |
return; |
| 645 |
} /* mainApplyNewLayout */ |
| 646 |
|
| 647 |
/************************************************************/ |
| 648 |
|
| 649 |
void mainKeySetComplete (KEYSET ks, char *text, int len) |
| 650 |
/**** Auto completion system *********/ |
| 651 |
{ |
| 652 |
int n, i ; |
| 653 |
char *cp, *cq ; |
| 654 |
KEYSET ks2 ; |
| 655 |
|
| 656 |
if (!keySetMax(ks)) /* no match */ |
| 657 |
{ messbeep() ; |
| 658 |
goto ok ; |
| 659 |
} |
| 660 |
else if (keySetMax(ks) == 1) /* unique match */ |
| 661 |
{ strncpy (text, name(keySet(ks,0)), len-1) ; |
| 662 |
goto ok ; |
| 663 |
} |
| 664 |
/* else multiple matches */ |
| 665 |
n = strlen(text) ; |
| 666 |
for (i = 0 ; i < n ; ++i) |
| 667 |
text[i] = 0 ; |
| 668 |
|
| 669 |
ks2 = keySetAlphaHeap(ks,keySetMax(ks)) ; |
| 670 |
cp = name (keySet (ks2, 0)) ; |
| 671 |
cq = name (keySet (ks2, keySetMax(ks2)-1)) ; |
| 672 |
keySetDestroy(ks2) ; |
| 673 |
|
| 674 |
for (i = 0 ; *cp && *cp == *cq && i < len-1 ; ++i, ++cp, ++cq) |
| 675 |
text[i] = *cp ; |
| 676 |
text[i] = 0 ; |
| 677 |
|
| 678 |
if (i > n) /* length increase */ |
| 679 |
goto ok ; |
| 680 |
|
| 681 |
ok: |
| 682 |
if (mainPick) |
| 683 |
{ Graph oldGraph = graphActive() ; |
| 684 |
|
| 685 |
if (ks != mainPick->oblist) /* probably a useless kludge */ |
| 686 |
{ keySetDestroy (mainPick->oblist) ; |
| 687 |
mainPick->oblist = ks ; |
| 688 |
} |
| 689 |
if (graphActivate (mainPick->mainGraph)) |
| 690 |
obDisplay (mainPick, FALSE, 3) ; /* no automatic display() if 1 */ |
| 691 |
|
| 692 |
graphActivate (oldGraph) ; |
| 693 |
} |
| 694 |
} |
| 695 |
|
| 696 |
/************************************************************/ |
| 697 |
|
| 698 |
int ksetClassComplete (char *text, int len, int classe) |
| 699 |
/* return number of possible completions */ |
| 700 |
{ |
| 701 |
static KEYSET ks = 0 ; |
| 702 |
static int previousClass = 0 ; |
| 703 |
static int myKeySetId = 0 ; |
| 704 |
static char buffer[80] ; |
| 705 |
KEYSET ks2 ; |
| 706 |
char *cp, *cq ; |
| 707 |
int i, j , n ; |
| 708 |
|
| 709 |
if (myKeySetId != keySetExists(ks)) |
| 710 |
ks = 0 ; |
| 711 |
if (!text) |
| 712 |
{ keySetDestroy(ks) ; |
| 713 |
return 0 ; |
| 714 |
} |
| 715 |
|
| 716 |
if (ks) |
| 717 |
{ |
| 718 |
if (previousClass != classe) |
| 719 |
keySetDestroy(ks) ; |
| 720 |
else |
| 721 |
{ /* check if search field just got longer */ |
| 722 |
cp = buffer ; cq = text ; n = 80 ; /* size of buffer */ |
| 723 |
while (--n && *cp && *cq == *cp){cp++; cq++;} |
| 724 |
if (!n || *cp) |
| 725 |
keySetDestroy (ks) ; |
| 726 |
} |
| 727 |
} |
| 728 |
|
| 729 |
strncpy(buffer, text, 79) ; |
| 730 |
if (!ks) |
| 731 |
{ |
| 732 |
if (class(classe) == _VClass) |
| 733 |
ks = query (0, messprintf ("FIND %s IS \"%s*\"", |
| 734 |
name(classe), text)) ; |
| 735 |
else /* assume a true classe */ |
| 736 |
ks = query (0, messprintf ("FIND %s IS \"%s*\"", |
| 737 |
pickClass2Word(classe), text)) ; |
| 738 |
} |
| 739 |
else |
| 740 |
{ |
| 741 |
ks2 = arrayCreate(keySetMax(ks), KEY) ; |
| 742 |
text[len-2] = 0 ; /* prevents running off end */ |
| 743 |
cp = text + strlen(text) ; |
| 744 |
*cp = '*' ; *(cp+1) = 0 ; |
| 745 |
for (i=0, j=0 ; i < keySetMax(ks) ; i++ ) |
| 746 |
if (pickMatch (name(keySet(ks,i)), text)) |
| 747 |
keySet(ks2,j++) = keySet(ks,i) ; |
| 748 |
*cp = 0 ; /* remove * from end */ |
| 749 |
keySetDestroy(ks) ; |
| 750 |
ks = ks2 ; |
| 751 |
} |
| 752 |
|
| 753 |
mainKeySetComplete (ks, text, len) ; |
| 754 |
|
| 755 |
myKeySetId = keySetExists(ks) ; |
| 756 |
previousClass = classe ; |
| 757 |
strncpy(buffer, text, 79) ; |
| 758 |
|
| 759 |
return keySetMax(ks) ; |
| 760 |
} /* ksetClassComplete */ |
| 761 |
|
| 762 |
/************************************************************/ |
| 763 |
|
| 764 |
Array classListCreate (Array oldList, |
| 765 |
BOOL listHidden, |
| 766 |
BOOL listVisible, |
| 767 |
BOOL listBuried, |
| 768 |
BOOL listAllTypes) /* if FALSE must have model */ |
| 769 |
{ int max, i, j ; |
| 770 |
KEYSET ks, ksa ; |
| 771 |
Array newList; |
| 772 |
Stack s = stackCreate(50); |
| 773 |
BOOL arg = FALSE; |
| 774 |
unsigned char mask ; |
| 775 |
KEY key, model, table ; |
| 776 |
|
| 777 |
catText(s, "FIND Class"); |
| 778 |
|
| 779 |
if (listHidden) |
| 780 |
{ catText(s, " HIDDEN"); arg = TRUE; } |
| 781 |
|
| 782 |
if (listVisible) |
| 783 |
{ if (arg) catText(s, " OR"); |
| 784 |
catText(s, " VISIBLE"); arg = TRUE; |
| 785 |
} |
| 786 |
|
| 787 |
if (listBuried) |
| 788 |
{ if (arg) catText(s, " OR"); |
| 789 |
catText(s, " BURIED"); |
| 790 |
} |
| 791 |
|
| 792 |
ks = queryLocalParametrized(0, stackText(s, 0), ""); |
| 793 |
|
| 794 |
stackDestroy(s); |
| 795 |
|
| 796 |
max = keySetMax (ks) ; |
| 797 |
ksa = keySetAlphaHeap (ks, max) ; |
| 798 |
keySetDestroy (ks) ; |
| 799 |
|
| 800 |
if (oldList) |
| 801 |
/* replace old array */ |
| 802 |
newList = arrayReCreate (oldList, max, FREEOPT) ; |
| 803 |
else |
| 804 |
newList = arrayCreate(max, FREEOPT); |
| 805 |
|
| 806 |
j = 1 ; |
| 807 |
for (i = 0 ; i < max ; i++) |
| 808 |
{ |
| 809 |
key = table = keySet(ksa, i) ; |
| 810 |
pickIsA (&table, &mask) ; |
| 811 |
if (listAllTypes || |
| 812 |
(pickList [table].type == 'B' && |
| 813 |
(model = pickList [table].model) && iskey(model) == 2)) |
| 814 |
{ |
| 815 |
arrayp(newList, j, FREEOPT)->key = key ; |
| 816 |
arrayp(newList, j, FREEOPT)->text = name(key) ; |
| 817 |
j++ ; |
| 818 |
} |
| 819 |
} |
| 820 |
|
| 821 |
arrayp(newList, 0, FREEOPT)->key = j - 1 ; |
| 822 |
arrayp(newList, 0, FREEOPT)->text = "Classes" ; |
| 823 |
|
| 824 |
keySetDestroy (ksa) ; |
| 825 |
|
| 826 |
return newList; |
| 827 |
} /* classListCreate */ |
| 828 |
|
| 829 |
|
| 830 |
void mainPickReport (int n) |
| 831 |
{ |
| 832 |
BOOL bb = FALSE ; |
| 833 |
float line = .5 ; |
| 834 |
static int boxOn = 0, boxOff ; |
| 835 |
char *cp = 0 ; |
| 836 |
if (!externalServerState) |
| 837 |
return ; |
| 838 |
|
| 839 |
switch (n) |
| 840 |
{ |
| 841 |
case -1: /* ask and draw */ |
| 842 |
bb = externalServerState (-1) ; /* ask */ |
| 843 |
graphText ("Server:", .5, line) ; |
| 844 |
boxOn = graphButton ("On", serverOn, 8.5, line) ; |
| 845 |
boxOff = graphButton ("Off", serverOff, 12.0, line) ; |
| 846 |
break ; |
| 847 |
case 1: |
| 848 |
bb = TRUE ; |
| 849 |
break ; |
| 850 |
case 0: case 2: |
| 851 |
bb = FALSE ; |
| 852 |
break ; |
| 853 |
default: |
| 854 |
break ; |
| 855 |
} |
| 856 |
if (!boxOn) return ; |
| 857 |
|
| 858 |
if (externalServerName) |
| 859 |
cp = externalServerName () ; |
| 860 |
if (cp) |
| 861 |
graphText(cp, 18, line); |
| 862 |
|
| 863 |
graphBoxDraw(boxOn, BLACK, bb ? PALEBLUE : WHITE) ; |
| 864 |
graphBoxDraw(boxOff, BLACK, !bb ? (n == 2 ? RED : PALEBLUE) : WHITE) ; |
| 865 |
} /* mainPickReport */ |
| 866 |
|
| 867 |
|
| 868 |
/****************************************************************** |
| 869 |
************************ private functions *********************** |
| 870 |
******************************************************************/ |
| 871 |
|
| 872 |
/* Callback function, called from prefsubs when user changes style of main */ |
| 873 |
/* window. */ |
| 874 |
static void prefMainRedraw(BOOL pref_value) |
| 875 |
{ |
| 876 |
pickDraw() ; |
| 877 |
|
| 878 |
return ; |
| 879 |
} |
| 880 |
|
| 881 |
|
| 882 |
static void mainWindowResize (void) |
| 883 |
{ |
| 884 |
isNewLayout = !prefValue ("OLD_STYLE_MAIN_WINDOW") ; |
| 885 |
if (!isNewLayout) |
| 886 |
{ |
| 887 |
arrayDestroy (classLayout) ; |
| 888 |
classLayout = 0; /* force a re-create */ |
| 889 |
} |
| 890 |
pickDraw() ; |
| 891 |
|
| 892 |
return; |
| 893 |
} /* mainWindowResize */ |
| 894 |
|
| 895 |
static void mainWindowDestroy (void) |
| 896 |
{ |
| 897 |
Graph g = graphActive() ; |
| 898 |
struct messContextStruct nullStatusContext = { NULL, NULL }; |
| 899 |
PICKGET("obDestroy") ; |
| 900 |
|
| 901 |
/* prevent any more status display, as this window is dying */ |
| 902 |
messStatusRegister (nullStatusContext); |
| 903 |
|
| 904 |
/* cannot allow any more drawing into the main window */ |
| 905 |
writeAccessChangeUnRegister (); |
| 906 |
|
| 907 |
/*******************************/ |
| 908 |
|
| 909 |
if (graphActivate(pick->ksdisp_graph)) |
| 910 |
graphDestroy () ; |
| 911 |
|
| 912 |
if (graphActivate(pick->mainGraph)) |
| 913 |
graphDestroy () ; |
| 914 |
|
| 915 |
graphActivate (g) ; |
| 916 |
graphAssRemove (&Pick_MAGIC) ; |
| 917 |
|
| 918 |
pick->magic = 0 ; |
| 919 |
if (pick->grepText) |
| 920 |
messfree (pick->grepText); |
| 921 |
|
| 922 |
messfree (pick) ; |
| 923 |
mainPick = 0 ; |
| 924 |
|
| 925 |
return; |
| 926 |
} /* mainWindowDestroy */ |
| 927 |
|
| 928 |
/************************************************************/ |
| 929 |
|
| 930 |
static void mainWindowPick (int k, double x, double y, int modifier_unused) |
| 931 |
{ |
| 932 |
PICKGET("mainWindowPick") ; |
| 933 |
|
| 934 |
if (k == pick->templateBox) |
| 935 |
{ graphCompletionEntry (pickClassComplete, pick->template,0,0,0,0) ; |
| 936 |
return ; |
| 937 |
} |
| 938 |
|
| 939 |
if (!k) |
| 940 |
{ |
| 941 |
if (pick->currBox) |
| 942 |
graphBoxDraw (pick->currBox, BLACK, WHITE) ; |
| 943 |
pick->curr = 0 ; pick->currBox = 0 ; |
| 944 |
return ; |
| 945 |
} |
| 946 |
|
| 947 |
if (k == pick->grepBox) |
| 948 |
{ |
| 949 |
if (pick->currBox) |
| 950 |
graphBoxDraw (pick->currBox, BLACK, WHITE) ; |
| 951 |
pick->curr = 0 ; pick->currBox = 0 ; |
| 952 |
graphTextScrollEntry (pick->grepText,0,0,0,0,0) ; |
| 953 |
} |
| 954 |
else if (k == pick->classListBox) |
| 955 |
{ KEY key ; |
| 956 |
if (graphSelect (&key, arrp (classList, 0, FREEOPT))) |
| 957 |
classListMenuCall (key, 0) ; |
| 958 |
} |
| 959 |
|
| 960 |
if (k > firstClassBox && k <= firstClassBox + arrayMax(classLayout)) |
| 961 |
{ |
| 962 |
|
| 963 |
pickModeChoice1() ; |
| 964 |
if (k != pick->currBox) |
| 965 |
{ if (pick->currBox) |
| 966 |
graphBoxDraw (pick->currBox, BLACK, WHITE) ; |
| 967 |
pick->currBox = k ; |
| 968 |
if (isNewLayout)graphBoxDraw (pick->currBox, BLACK,PALEBLUE) ; |
| 969 |
else graphBoxDraw (pick->currBox, WHITE, BLACK) ; |
| 970 |
pick->curr = k - firstClassBox ; |
| 971 |
graphCompletionEntry (pickClassComplete,pick->template,0,0,0,0) ; |
| 972 |
} |
| 973 |
else if (!classDisplay () && strcmp (pick->template,"*")) |
| 974 |
{ /* inappropriate template - display whole list */ |
| 975 |
strcpy (pick->template,"*") ; |
| 976 |
graphCompletionEntry (pickClassComplete,pick->template,0,0,0,0) ; |
| 977 |
classDisplay () ; |
| 978 |
} |
| 979 |
} |
| 980 |
|
| 981 |
return; |
| 982 |
} /* mainWindowPick */ |
| 983 |
|
| 984 |
static void pickLongGrep (void) |
| 985 |
{ |
| 986 |
PICKGET("pickLong") ; |
| 987 |
|
| 988 |
pick->longGrep = TRUE ; |
| 989 |
grepDisplay("dummy"); |
| 990 |
|
| 991 |
return; |
| 992 |
} /* pickLongGrep */ |
| 993 |
|
| 994 |
/************************************************************/ |
| 995 |
|
| 996 |
static BOOL classListMenuCall (KEY classe, int box) |
| 997 |
{ |
| 998 |
char *cp ; |
| 999 |
KEY key ; |
| 1000 |
KEYSET ob ; |
| 1001 |
BOOL resul ; |
| 1002 |
char *nom ; |
| 1003 |
int n, state = 1, ii , i, j ; |
| 1004 |
PICKGET ("classListMenuCall") ; |
| 1005 |
|
| 1006 |
pick->currClasse = classe ; |
| 1007 |
pick->oblist = keySetCreate() ; j = 0 ; |
| 1008 |
lao: |
| 1009 |
/* classe is a real Classe-key in _VClass */ |
| 1010 |
for (ii = 0 ; ii < 256 ; ii++) |
| 1011 |
{ |
| 1012 |
if (!classe && (pickType(ii) == 'X' || pickList[ii].visible == 'h' || !pickList[ii].name)) |
| 1013 |
continue ; |
| 1014 |
|
| 1015 |
if (classe) |
| 1016 |
{ ii = classe ; nom = name(classe) ; } |
| 1017 |
else |
| 1018 |
nom = className(ii << 24) ; |
| 1019 |
|
| 1020 |
if (!strcmp("*", pick->template)) |
| 1021 |
{ |
| 1022 |
if (classe && lexword2key (pick->template, &key, classe)) |
| 1023 |
{ |
| 1024 |
ob = keySetCreate () ; |
| 1025 |
keySet(ob, 0) = key ; |
| 1026 |
} |
| 1027 |
else |
| 1028 |
{ cp = messprintf( "FIND %s", nom) ; |
| 1029 |
if (externalServer) |
| 1030 |
{ |
| 1031 |
ob = externalServer (200, cp, 0, FALSE) ; |
| 1032 |
if (keySetMax(pick->oblist) == 200) |
| 1033 |
messout("I limited the importation to 200, type ** to get all %s(s)", name(classe)) ; |
| 1034 |
} |
| 1035 |
else |
| 1036 |
ob = query(0, cp) ; |
| 1037 |
} |
| 1038 |
} |
| 1039 |
else |
| 1040 |
ob = query(0, messprintf( "FIND %s IS %s",nom, |
| 1041 |
freeprotect(pick->template))) ; |
| 1042 |
|
| 1043 |
n = keySetMax(ob) ; |
| 1044 |
for (i = 0 ; i < n ; i++) |
| 1045 |
{ |
| 1046 |
keySet(pick->oblist,j++) = keySet(ob,i) ; |
| 1047 |
} |
| 1048 |
|
| 1049 |
if (externalServer && !strcmp("*", pick->template) && j >= 200) |
| 1050 |
{ |
| 1051 |
messout("I limited the importation to 200, type ** to get all %s(s)", nom) ; |
| 1052 |
break ; |
| 1053 |
} |
| 1054 |
|
| 1055 |
if (classe) |
| 1056 |
break ; |
| 1057 |
} |
| 1058 |
|
| 1059 |
if (state == 1 && !keySetMax(pick->oblist)) |
| 1060 |
{ |
| 1061 |
cp = pick->template ; |
| 1062 |
n = strlen(cp) ; |
| 1063 |
if (n == 0 || (*(cp + n - 1) != '*' && n < (OLD_TEMPLATE_LENGTH - 1))) |
| 1064 |
{ |
| 1065 |
strcat (pick->template, "*") ; |
| 1066 |
graphBoxDraw (pick->templateBox, -1, -1) ; |
| 1067 |
state = 2 ; |
| 1068 |
goto lao ; |
| 1069 |
} |
| 1070 |
} |
| 1071 |
resul = (keySetMax(pick->oblist) != 0) ; |
| 1072 |
obDisplay (pick, TRUE, state) ; |
| 1073 |
|
| 1074 |
return resul ; |
| 1075 |
} /* classListMenuCall */ |
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
/***********************************/ |
| 1080 |
|
| 1081 |
static void mainWindowCleanUp (void) |
| 1082 |
{ |
| 1083 |
graphCleanUp() ; |
| 1084 |
pickDraw() ; |
| 1085 |
} |
| 1086 |
|
| 1087 |
/*************************************/ |
| 1088 |
|
| 1089 |
static void queryButtonFreeAction (KEY key, int box) |
| 1090 |
{ |
| 1091 |
switch (key) |
| 1092 |
{ |
| 1093 |
case 0: break ; |
| 1094 |
case 'h': helpOn ("Query") ; break ; |
| 1095 |
case 'q': queryCreate() ; break ; |
| 1096 |
case 'b': qbeCreate() ; break ; |
| 1097 |
case 'u': qbuildCreate() ; break ; |
| 1098 |
case 's': tableMaker() ; break ; |
| 1099 |
case 'a': aqlDisplayCreate() ; break ; |
| 1100 |
case 'd': dnaAnalyse() ; break ; |
| 1101 |
} |
| 1102 |
} |
| 1103 |
|
| 1104 |
static void querySelector (void) |
| 1105 |
{ |
| 1106 |
KEY k ; |
| 1107 |
|
| 1108 |
if (!graphSelect (&k,queryButtonFreeMenu)) |
| 1109 |
return ; |
| 1110 |
queryButtonFreeAction(k,0) ; |
| 1111 |
} |
| 1112 |
|
| 1113 |
/***********************************/ |
| 1114 |
|
| 1115 |
static void adminButtonFreeAction (KEY key, int box) |
| 1116 |
{ |
| 1117 |
PICKGET("adminButtonFreeAction") ; |
| 1118 |
|
| 1119 |
switch (key) |
| 1120 |
{ |
| 1121 |
case 0: break ; |
| 1122 |
case 's': statusDisplayCreate(); break ; |
| 1123 |
case 'S': sessionControl() ; break ; |
| 1124 |
case 'p': editPreferences() ; break ; |
| 1125 |
case 'x': |
| 1126 |
{ |
| 1127 |
/* Toggle signal handling on/off. */ |
| 1128 |
char *sig_txt ; |
| 1129 |
|
| 1130 |
if (signalCatchStatus()) |
| 1131 |
{ |
| 1132 |
sig_txt = SIG_ON_TEXT ; |
| 1133 |
signalCatchOff(FALSE) ; |
| 1134 |
} |
| 1135 |
else |
| 1136 |
{ |
| 1137 |
sig_txt = SIG_OFF_TEXT ; |
| 1138 |
signalCatchOn(FALSE) ; |
| 1139 |
} |
| 1140 |
swopSigCatchMenuText(sig_txt, pick->admin_box) ; |
| 1141 |
|
| 1142 |
break ; |
| 1143 |
} |
| 1144 |
case 'd': dumpAll() ; break ; |
| 1145 |
case 'D': dumpReadAll() ; break ; |
| 1146 |
#ifdef CHRONO |
| 1147 |
case 'c': chronoShow () ; break ; |
| 1148 |
#endif |
| 1149 |
#ifdef DEBUG |
| 1150 |
case 't': acedbtest() ; break ; |
| 1151 |
#endif /* DEBUG acedbtest */ |
| 1152 |
} |
| 1153 |
} /* adminButtonFreeAction */ |
| 1154 |
|
| 1155 |
static void adminSelector(void) |
| 1156 |
{ |
| 1157 |
KEY k ; |
| 1158 |
|
| 1159 |
if (graphSelect(&k,adminButtonFreeMenu)) |
| 1160 |
adminButtonFreeAction(k,0) ; |
| 1161 |
|
| 1162 |
return ; |
| 1163 |
} /* adminSelector */ |
| 1164 |
|
| 1165 |
/***********************************/ |
| 1166 |
|
| 1167 |
static void editButtonFreeAction(KEY key, int box) |
| 1168 |
{ |
| 1169 |
switch (key) |
| 1170 |
{ |
| 1171 |
case 0: break ; |
| 1172 |
case 'r': /* Read .ace file */ |
| 1173 |
if (checkWriteAccess()) |
| 1174 |
parseControl(); |
| 1175 |
break ; |
| 1176 |
|
| 1177 |
case 'a': /* Add/Delete/Rename/Alias */ |
| 1178 |
if (checkWriteAccess()) |
| 1179 |
addKeys() ; |
| 1180 |
break ; |
| 1181 |
|
| 1182 |
case 'A': /* Align maps */ |
| 1183 |
if (checkWriteAccess()) |
| 1184 |
alignMaps() ; |
| 1185 |
break ; |
| 1186 |
|
| 1187 |
case 'w': |
| 1188 |
sessionGainWriteAccess(); /* Gain Write Access */ |
| 1189 |
/* will re-draw if write access status changes */ |
| 1190 |
break; |
| 1191 |
|
| 1192 |
case 'T': /* Dendrogram trees */ |
| 1193 |
dendrogramDisplay (0,0,0, NULL) ; |
| 1194 |
break; |
| 1195 |
|
| 1196 |
case 'O': /* Oxgrid */ |
| 1197 |
oxgridCreate() ; |
| 1198 |
break; |
| 1199 |
|
| 1200 |
case 'm': |
| 1201 |
doReadModels(FALSE) ; /* Just read models. */ |
| 1202 |
break ; |
| 1203 |
case 'M': |
| 1204 |
doReadModels(TRUE) ; /* Read models + full reindex. */ |
| 1205 |
break ; |
| 1206 |
|
| 1207 |
case 'u': |
| 1208 |
updateData() ; |
| 1209 |
break ; |
| 1210 |
} |
| 1211 |
pickDoDrawNew() ; |
| 1212 |
} /* editButtonFreeAction */ |
| 1213 |
|
| 1214 |
static void editSelector(void) |
| 1215 |
{ |
| 1216 |
KEY k ; |
| 1217 |
|
| 1218 |
/* graphEvent (RIGHT_DOWN, 3,3) ; */ |
| 1219 |
if (!graphSelect (&k,editButtonFreeMenu)) |
| 1220 |
return ; |
| 1221 |
editButtonFreeAction(k,0) ; |
| 1222 |
} |
| 1223 |
|
| 1224 |
/***********************************/ |
| 1225 |
|
| 1226 |
static void saveAndKeepWriteAccess(void) |
| 1227 |
/* used by save button freemenu and the save button itself */ |
| 1228 |
{ |
| 1229 |
if (isWriteAccess()) |
| 1230 |
{ |
| 1231 |
|
| 1232 |
|
| 1233 |
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE |
| 1234 |
/* This results in the log file being closed, this is a temporary fix |
| 1235 |
* as the logfile v.s. session close stuff needs sorting out. */ |
| 1236 |
|
| 1237 |
sessionClose (TRUE); /* close and save session, |
| 1238 |
nothing will happen, |
| 1239 |
if we don't have write access */ |
| 1240 |
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ |
| 1241 |
sessionMark (TRUE, 0) ; |
| 1242 |
|
| 1243 |
|
| 1244 |
if (!sessionGainWriteAccess()) /* re-gain write access */ |
| 1245 |
messout ("Sorry, it was not possible to re-gain write access " |
| 1246 |
"after saving the last session."); |
| 1247 |
} |
| 1248 |
else |
| 1249 |
{ |
| 1250 |
messout ("You don't have write access. Nothing to save."); |
| 1251 |
} |
| 1252 |
|
| 1253 |
} /* saveAndKeepWriteAccess */ |
| 1254 |
|
| 1255 |
/***********************************/ |
| 1256 |
|
| 1257 |
static void saveAndLoseWriteAccess(void) |
| 1258 |
/* used by save button freemenu */ |
| 1259 |
{ |
| 1260 |
#ifdef ED_G_NEVER_INCLUDE_THIS_CODE |
| 1261 |
/* This results in the log file being closed, this is a temporary fix |
| 1262 |
* as the logfile v.s. session close stuff needs sorting out. */ |
| 1263 |
|
| 1264 |
sessionClose (TRUE) ; /* close and save session, |
| 1265 |
nothing will happen, |
| 1266 |
if we don't have write access */ |
| 1267 |
#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */ |
| 1268 |
sessionMark (TRUE, 0) ; |
| 1269 |
|
| 1270 |
} /* saveAndLoseWriteAccess */ |
| 1271 |
|
| 1272 |
/***********************************/ |
| 1273 |
|
| 1274 |
static void saveMenuFreeAction(KEY key, int box) |
| 1275 |
{ |
| 1276 |
switch (key) |
| 1277 |
{ |
| 1278 |
case 's': |
| 1279 |
saveAndKeepWriteAccess(); |
| 1280 |
break ; |
| 1281 |
|
| 1282 |
case 't': |
| 1283 |
saveAndLoseWriteAccess(); |
| 1284 |
break ; |
| 1285 |
|
| 1286 |
case 'd': |
| 1287 |
sessionReleaseWriteAccess(); /* don't save, drop write access */ |
| 1288 |
break; |
| 1289 |
|
| 1290 |
default: |
| 1291 |
break; |
| 1292 |
} |
| 1293 |
} /* saveMenuFreeAction */ |
| 1294 |
|
| 1295 |
/***********************************/ |
| 1296 |
|
| 1297 |
static void exitButtonAction (void) |
| 1298 |
{ |
| 1299 |
if (thisSession.session != 1 && |
| 1300 |
!messQuery ("Do you really want to quit acedb?")) |
| 1301 |
return; |
| 1302 |
|
| 1303 |
if (mainWindowQuitRoutine) |
| 1304 |
(*mainWindowQuitRoutine)(); |
| 1305 |
else |
| 1306 |
{ |
| 1307 |
/* default action that needs to be performed when xace exits */ |
| 1308 |
|
| 1309 |
graphCleanUp () ; /* kills all open windows, |
| 1310 |
forces displayed objects to cache */ |
| 1311 |
|
| 1312 |
writeAccessChangeUnRegister(); /* avoid unnecessary re-draws |
| 1313 |
just before exiting */ |
| 1314 |
|
| 1315 |
/* release read/write locks and clean up temp-files |
| 1316 |
is all done by aceQuit() */ |
| 1317 |
if (isWriteAccess() && |
| 1318 |
messQuery ("You did not save your work, should I ?")) |
| 1319 |
sessionClose (TRUE); |
| 1320 |
else |
| 1321 |
sessionClose (FALSE); |
| 1322 |
|
| 1323 |
if (!getenv("ACEDB_NO_BANNER")) |
| 1324 |
printf ("\n\nA bientot !\n") ; |
| 1325 |
} |
| 1326 |
exit (EXIT_SUCCESS); |
| 1327 |
} /* exitButtonAction */ |
| 1328 |
|
| 1329 |
/***********************************/ |
| 1330 |
|
| 1331 |
static void serverOn (void) |
| 1332 |
{ |
| 1333 |
BOOL bb=FALSE; |
| 1334 |
if (externalServerState) |
| 1335 |
bb = externalServerState (1) ; /* set */ |
| 1336 |
mainPickReport (bb ? 1 : 2) ; |
| 1337 |
} |
| 1338 |
|
| 1339 |
static void serverOff (void) |
| 1340 |
{ |
| 1341 |
BOOL bb=FALSE; |
| 1342 |
if (externalServerState) |
| 1343 |
bb = externalServerState (0) ; /* unset */ |
| 1344 |
mainPickReport (bb ? 1 : 0) ; |
| 1345 |
} |
| 1346 |
|
| 1347 |
/************************************************************/ |
| 1348 |
/**************** old main menu ****************************/ |
| 1349 |
/************************************************************/ |
| 1350 |
|
| 1351 |
static void oldmenuSaveAction (void) |
| 1352 |
{ |
| 1353 |
if (isWriteAccess()) |
| 1354 |
{ BOOL reGet = messQuery("Shall I retain Write Access after saving?"); |
| 1355 |
sessionClose (TRUE) ; |
| 1356 |
if (reGet) |
| 1357 |
sessionGainWriteAccess(); |
| 1358 |
} |
| 1359 |
else |
| 1360 |
sessionGainWriteAccess () ; /* try to grab it */ |
| 1361 |
} /* menuSaveAction */ |
| 1362 |
|
| 1363 |
|
| 1364 |
static void oldmenuWriteAccess (void) |
| 1365 |
{ |
| 1366 |
/* can't use this function directly in menu definition, |
| 1367 |
it returns a boolean success value (ignored here) */ |
| 1368 |
sessionGainWriteAccess(); |
| 1369 |
} /* menuWriteAccess */ |
| 1370 |
|
| 1371 |
static void oldmenuReadModels (void) |
| 1372 |
{ |
| 1373 |
doReadModels(FALSE) ; |
| 1374 |
|
| 1375 |
return ; |
| 1376 |
} /* menuReadModels */ |
| 1377 |
|
| 1378 |
static void oldmenuReadModelsAndReindex (void) |
| 1379 |
{ |
| 1380 |
doReadModels(TRUE) ; |
| 1381 |
|
| 1382 |
return ; |
| 1383 |
} /* menuReadModels */ |
| 1384 |
|
| 1385 |
/* Just calling readModels will not do a complete reindex, this sometimes */ |
| 1386 |
/* seems to cause problems because queries start to not work correctly and */ |
| 1387 |
/* do not find everything they should. The problem seems to go away after a */ |
| 1388 |
/* complete reindex which takes longer. This code follows that in command.c */ |
| 1389 |
/* for the "Read-models" command. So now users can do the complete reindex */ |
| 1390 |
/* from xace as well as tace. */ |
| 1391 |
static void doReadModels(BOOL complete_reindex) |
| 1392 |
{ |
| 1393 |
if (complete_reindex) |
| 1394 |
{ |
| 1395 |
if (messQuery("A complete reindex can take a long time for a large database, " |
| 1396 |
"during this time no one else will be able to update the database. " |
| 1397 |
"do you wish to continue ?")) |
| 1398 |
bIndexInit(BINDEX_AFTER_READMODELS) ; |
| 1399 |
} |
| 1400 |
else |
| 1401 |
readModels() ; |
| 1402 |
|
| 1403 |
return ; |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
static void pickDoDrawOld (void) |
| 1408 |
{ |
| 1409 |
int box, i, y ; float line; |
| 1410 |
LAYOUT *z ; |
| 1411 |
|
| 1412 |
if (!graphActivate (mainPick->mainGraph)) |
| 1413 |
return ; |
| 1414 |
graphClear() ; |
| 1415 |
|
| 1416 |
if (!mainMenu) |
| 1417 |
{ |
| 1418 |
mainMenu = menuInitialise ("Main menu", (MENUSPEC*)mainMenuSpec) ; |
| 1419 |
|
| 1420 |
if (!writeAccessPossible()) |
| 1421 |
{ |
| 1422 |
menuSuppress (mainMenu, "Save") ; |
| 1423 |
menuSuppress (mainMenu, "Write Access") ; |
| 1424 |
menuSuppress (mainMenu, "Add-Alias-Rename") ; |
| 1425 |
} |
| 1426 |
} |
| 1427 |
|
| 1428 |
if (writeAccessPossible()) |
| 1429 |
{ |
| 1430 |
if (isWriteAccess()) |
| 1431 |
{ |
| 1432 |
menuSetFlags (menuItem (mainMenu, "Write Access"), MENUFLAG_DISABLED) ; |
| 1433 |
menuUnsetFlags (menuItem (mainMenu, "Save"), MENUFLAG_DISABLED) ; |
| 1434 |
} |
| 1435 |
else |
| 1436 |
{ |
| 1437 |
menuUnsetFlags (menuItem (mainMenu, "Write Access"), MENUFLAG_DISABLED) ; |
| 1438 |
menuSetFlags (menuItem (mainMenu, "Save"), MENUFLAG_DISABLED) ; |
| 1439 |
} |
| 1440 |
} |
| 1441 |
graphNewMenu (mainMenu); |
| 1442 |
|
| 1443 |
|
| 1444 |
/* drawing */ |
| 1445 |
line = 0.5 ; |
| 1446 |
if (externalServerState) |
| 1447 |
{ mainPickReport (-1) ; line += 2 ; } |
| 1448 |
graphText ("Search: ", 0.5, line) ; |
| 1449 |
|
| 1450 |
box = graphButton("Help",help,35.,line) ; |
| 1451 |
graphBoxMenu (box, 0) ; |
| 1452 |
|
| 1453 |
box = graphButton("Exit",exitButtonAction,41.,line) ; |
| 1454 |
graphBoxMenu (box, 0) ; |
| 1455 |
|
| 1456 |
if (pickFirstTemplate) |
| 1457 |
strcpy(mainPick->template, pickFirstTemplate); |
| 1458 |
else |
| 1459 |
strcpy (mainPick->template,"*") ; |
| 1460 |
mainPick->templateBox = graphCompletionEntry(pickClassComplete, mainPick->template, |
| 1461 |
OLD_TEMPLATE_LENGTH, 12.0, line, |
| 1462 |
TEXT_ENTRY_FUNC_CAST classDisplay) ; |
| 1463 |
line += 1.5 ; |
| 1464 |
|
| 1465 |
strcpy(mainPick->whatdoIdoText, ""); |
| 1466 |
mainPick->whatdoIdoBox = graphBoxStart() ; |
| 1467 |
graphTextPtr(mainPick->whatdoIdoText, 18, line, ACTIVITY_LENGTH) ; |
| 1468 |
graphBoxEnd() ; |
| 1469 |
|
| 1470 |
line += .5 ; |
| 1471 |
graphText ("In Class:", 0.5, line) ; |
| 1472 |
mainPick->classListBox = box = graphMenuTriangle(TRUE, 9.7, line) ; |
| 1473 |
graphBoxFreeMenu(box, (FreeMenuFunction) classListMenuCall, |
| 1474 |
arrp (classList, 0, FREEOPT) ) ; |
| 1475 |
line += 1 ; |
| 1476 |
y = 0 ; |
| 1477 |
firstClassBox = graphBoxStart () ; |
| 1478 |
for (i = 0 ; i < arrayMax(classLayout) ; ++i) |
| 1479 |
{ int b = graphBoxStart () ; |
| 1480 |
z = arrp(classLayout, i, LAYOUT) ; |
| 1481 |
if (z->y > y) y = z->y ; |
| 1482 |
graphText (name(z->key), z->x, z->y + line) ; |
| 1483 |
if (pickFirstClass |
| 1484 |
&& (strcasecmp(name(z->key), pickFirstClass) == 0)) |
| 1485 |
{ |
| 1486 |
pickFirstBox = b; |
| 1487 |
} |
| 1488 |
graphBoxEnd () ; |
| 1489 |
} |
| 1490 |
graphBoxEnd () ; |
| 1491 |
graphNewBoxMenu(firstClassBox, mainMenu); |
| 1492 |
|
| 1493 |
line += y + 2 ; |
| 1494 |
|
| 1495 |
graphBoxStart() ; |
| 1496 |
graphText ("Global Search: ", 0.5, line) ; |
| 1497 |
graphBoxEnd () ; |
| 1498 |
|
| 1499 |
strcpy (mainPick->grepText, ""); |
| 1500 |
mainPick->grepBox = graphTextScrollEntry (mainPick->grepText, |
| 1501 |
255, 16, 14.5, line, |
| 1502 |
grepDisplay) ; |
| 1503 |
if (lexMax(_VLongText) > 2) |
| 1504 |
mainPick->longGrepBox = graphButton ("Long Search", |
| 1505 |
pickLongGrep, 32.,line) ; |
| 1506 |
|
| 1507 |
messStatus ("dummy"); /* force redraw of whatdoIdoBox */ |
| 1508 |
|
| 1509 |
graphRedraw () ; |
| 1510 |
} /* pickDoDrawOld */ |
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
static void pickModeChoice (int m1, int m2, int m3) |
| 1515 |
{ |
| 1516 |
int i ; |
| 1517 |
|
| 1518 |
if (!isNewLayout) |
| 1519 |
return; |
| 1520 |
|
| 1521 |
if (m1) |
| 1522 |
{ |
| 1523 |
if (mainPick->m1 == m1) { m1-- ; if (!m1) m1 = 1 ; } |
| 1524 |
if (!m2) |
| 1525 |
{ if (m1 == 1) m2 = 1 ; else m2 = 2 ; } |
| 1526 |
i = 3 ; while (i--) |
| 1527 |
graphBoxDraw (mainPick->modeBox1 + i + 1, BLACK, WHITE) ; |
| 1528 |
mainPick->m1 = m1 ; |
| 1529 |
i = m1 ; while (i--) |
| 1530 |
graphBoxDraw (mainPick->modeBox1 + i + 1, BLACK, PALEBLUE) ; |
| 1531 |
} |
| 1532 |
if (m2) |
| 1533 |
{ |
| 1534 |
graphBoxDraw (mainPick->modeBox2 + mainPick->m2, BLACK, WHITE) ; |
| 1535 |
mainPick->m2 = m2 ; |
| 1536 |
graphBoxDraw (mainPick->modeBox2 + mainPick->m2, BLACK, PALEBLUE) ; |
| 1537 |
if (m2 == 2) |
| 1538 |
mainWindowPick (0, 0, 0, 0) ; |
| 1539 |
} |
| 1540 |
|
| 1541 |
return; |
| 1542 |
} /* pickModeChoice */ |
| 1543 |
|
| 1544 |
static void pickModeChoice10 (void) { pickModeChoice(1,0,1) ; } |
| 1545 |
static void pickModeChoice20(void) { pickModeChoice(2,0,3) ; } |
| 1546 |
static void pickModeChoice30(void) { pickModeChoice(3,0,7) ; } |
| 1547 |
static void pickModeChoice1 (void) { pickModeChoice(0,1,0) ; } |
| 1548 |
static void pickModeChoice2 (void) { pickModeChoice(0,2,0) ; } |
| 1549 |
/* |
| 1550 |
static void pickModeChoice11 (void) { pickModeChoice(1,1,1) ; } |
| 1551 |
static void pickModeChoice12 (void) { pickModeChoice(1,2,2) ; } |
| 1552 |
static void pickModeChoice22 (void) { pickModeChoice(2,2,3) ; } |
| 1553 |
static void pickModeChoice32 (void) { pickModeChoice(3,2,4) ; } |
| 1554 |
*/ |
| 1555 |
|
| 1556 |
static void modeSearchEntry (char *dummy) |
| 1557 |
{ |
| 1558 |
mainPick->longGrep = FALSE ; |
| 1559 |
|
| 1560 |
switch (10 * mainPick->m1 + mainPick->m2) |
| 1561 |
{ |
| 1562 |
case 11: /* names, selected class */ |
| 1563 |
if (!mainPick->curr) |
| 1564 |
{ |
| 1565 |
messout("Please select a class or search \"in all classes\"") ; |
| 1566 |
return ; |
| 1567 |
} |
| 1568 |
classDisplayNew (mainPick->curr) ; |
| 1569 |
break ; |
| 1570 |
case 12: /* names, all classes */ |
| 1571 |
classDisplayNew (0) ; |
| 1572 |
break ; |
| 1573 |
case 21: /* text, selected class */ |
| 1574 |
if (!mainPick->curr) |
| 1575 |
{ |
| 1576 |
messout("Please select a class or search \"in all classes\"") ; |
| 1577 |
return ; |
| 1578 |
} |
| 1579 |
strcpy (mainPick->grepText, mainPick->template) ; |
| 1580 |
grepDisplayNew (mainPick->curr) ; |
| 1581 |
break ; |
| 1582 |
case 22: /* text, all classes */ |
| 1583 |
strcpy (mainPick->grepText, mainPick->template) ; |
| 1584 |
grepDisplayNew (0) ; |
| 1585 |
break ; |
| 1586 |
case 31: |
| 1587 |
case 32: /* long texts */ |
| 1588 |
mainPick->longGrep = TRUE ; |
| 1589 |
strcpy (mainPick->grepText, mainPick->template) ; |
| 1590 |
grepDisplayNew (0) ; |
| 1591 |
break ; |
| 1592 |
} |
| 1593 |
} |
| 1594 |
|
| 1595 |
static void otherClassChoice (void) |
| 1596 |
{ |
| 1597 |
KEY key ; |
| 1598 |
if (graphSelect (&key, arrp (classList, 0, FREEOPT))) |
| 1599 |
classListMenuCall (key, 0) ; |
| 1600 |
} |
| 1601 |
|
| 1602 |
|
| 1603 |
/************************************************************/ |
| 1604 |
|
| 1605 |
|
| 1606 |
static void pickDoDrawNew (void) |
| 1607 |
{ |
| 1608 |
int box, i, y ; |
| 1609 |
float line; |
| 1610 |
LAYOUT *z ; |
| 1611 |
int graphWidth, graphHeight ; |
| 1612 |
|
| 1613 |
if (!graphActivate (mainPick->mainGraph)) |
| 1614 |
return ; |
| 1615 |
graphClear() ; |
| 1616 |
|
| 1617 |
#ifndef ACEMBLY |
| 1618 |
if (oxgridPossible()) |
| 1619 |
graphMenu (pickNewOxMenu) ; |
| 1620 |
else |
| 1621 |
#endif |
| 1622 |
/* background menu */ |
| 1623 |
graphMenu (pickNewMenu) ; |
| 1624 |
|
| 1625 |
graphFitBounds (&graphWidth,&graphHeight) ; |
| 1626 |
|
| 1627 |
/* drawing */ |
| 1628 |
line = 0.5 ; |
| 1629 |
mainPick->curr = 0 ; mainPick->currBox = 0 ; |
| 1630 |
|
| 1631 |
/* server/client */ |
| 1632 |
if (externalServerState) |
| 1633 |
{ mainPickReport (-1) ; line += 2 ; } |
| 1634 |
|
| 1635 |
/* menu bar */ |
| 1636 |
if (writeAccessPossible()) |
| 1637 |
{ |
| 1638 |
if (isWriteAccess()) |
| 1639 |
{ |
| 1640 |
box = graphButton("Save..", saveAndKeepWriteAccess, 1., line) ; |
| 1641 |
graphBoxFreeMenu (box, saveMenuFreeAction, |
| 1642 |
saveButtonFreeMenu) ; |
| 1643 |
|
| 1644 |
/* exclude last menu option "Gain write access" */ |
| 1645 |
editButtonFreeMenu[0].key = 11; |
| 1646 |
} |
| 1647 |
else |
| 1648 |
{ |
| 1649 |
/* include "gain write access" */ |
| 1650 |
editButtonFreeMenu[0].key = 12; |
| 1651 |
} |
| 1652 |
|
| 1653 |
box = graphButton("Edit..", editSelector,9.,line) ; |
| 1654 |
graphBoxFreeMenu (box, editButtonFreeAction, |
| 1655 |
editButtonFreeMenu) ; |
| 1656 |
} |
| 1657 |
|
| 1658 |
box = graphButton("Query..", querySelector,17.,line) ; |
| 1659 |
graphBoxFreeMenu (box, queryButtonFreeAction, queryButtonFreeMenu) ; |
| 1660 |
|
| 1661 |
mainPick->admin_box = box = graphButton("Admin..", adminSelector,26.,line) ; |
| 1662 |
swopSigCatchMenuText((signalCatchStatus() ? SIG_OFF_TEXT : SIG_ON_TEXT), box) ; |
| 1663 |
graphBoxFreeMenu (box, adminButtonFreeAction, adminButtonFreeMenu) ; |
| 1664 |
|
| 1665 |
box = graphButton("Clear", mainWindowCleanUp,37.,line) ; |
| 1666 |
graphBoxMenu(box, 0); |
| 1667 |
|
| 1668 |
box = graphButton("Help", help, 44.,line + 1.4) ; |
| 1669 |
graphBoxMenu(box, 0); |
| 1670 |
|
| 1671 |
box = graphButton("Exit", exitButtonAction, 44.,line) ; |
| 1672 |
graphBoxMenu(box, 0); |
| 1673 |
|
| 1674 |
line += 1.5 ; |
| 1675 |
|
| 1676 |
/* status */ |
| 1677 |
*mainPick->whatdoIdoText = 0 ; |
| 1678 |
graphText ("Status:", 1, line) ; |
| 1679 |
mainPick->whatdoIdoBox = graphBoxStart() ; |
| 1680 |
graphTextPtr(mainPick->whatdoIdoText, 10, line, ACTIVITY_LENGTH) ; |
| 1681 |
graphBoxEnd() ; |
| 1682 |
line += 1.8 ; |
| 1683 |
|
| 1684 |
/* search box */ |
| 1685 |
|
| 1686 |
|
| 1687 |
/* |
| 1688 |
strcpy (mainPick->template,"*") ; |
| 1689 |
mainPick->templateBox = graphCompScrollEntry (pickClassComplete, mainPick->template, |
| 1690 |
250, 28,10.0, line, |
| 1691 |
TEXT_ENTRY_FUNC_CAST modeSearch) ; |
| 1692 |
*/ |
| 1693 |
graphText ("Search", 1, line +.1) ; |
| 1694 |
mainPick->m1 = 1 ; mainPick->m2 = 1 ; mainPick->m3 = 1 ; |
| 1695 |
|
| 1696 |
mainPick->modeBox2 = graphBoxStart () ; |
| 1697 |
box = graphButton ("in the selected class", pickModeChoice1, 8,line) ; |
| 1698 |
graphBoxMenu(box, 0); |
| 1699 |
graphText ("or", 31, line +.1) ; |
| 1700 |
box = graphButton ("in all classes", pickModeChoice2, 34,line) ; |
| 1701 |
graphBoxMenu(box, 0); |
| 1702 |
graphBoxEnd () ; |
| 1703 |
graphBoxDraw (mainPick->modeBox2 + mainPick->m2, BLACK, PALEBLUE) ; |
| 1704 |
|
| 1705 |
line += 1.6 ; |
| 1706 |
mainPick->modeBox1 = graphBoxStart () ; |
| 1707 |
graphText ("objects", .5, line + .1) ; |
| 1708 |
box = graphButton ("named", pickModeChoice10, 8,line) ; |
| 1709 |
graphBoxMenu(box, 0); |
| 1710 |
graphText ("or", 14.9, line + .1) ; |
| 1711 |
box = graphButton ("related to", pickModeChoice20, 17.9,line) ; |
| 1712 |
graphBoxMenu(box, 0); |
| 1713 |
if (lexMax(_VLongText) > 2) |
| 1714 |
{ |
| 1715 |
/* graphText ("+",31.2, line) ; */ |
| 1716 |
box = graphButton ("even in long texts", pickModeChoice30, 30.2,line) ; |
| 1717 |
graphBoxMenu(box, 0); |
| 1718 |
} |
| 1719 |
else { graphBoxStart () ; graphBoxEnd () ;}/* empty box needed for counts */ |
| 1720 |
|
| 1721 |
graphBoxEnd () ; |
| 1722 |
i = mainPick->m1 ; |
| 1723 |
while (i--) |
| 1724 |
graphBoxDraw (mainPick->modeBox1 + i + 1, BLACK, PALEBLUE) ; |
| 1725 |
|
| 1726 |
line += 1.5 ; |
| 1727 |
|
| 1728 |
if (pickFirstTemplate) |
| 1729 |
strcpy(mainPick->template, pickFirstTemplate); |
| 1730 |
else |
| 1731 |
strcpy (mainPick->template,"*") ; |
| 1732 |
mainPick->templateBox = graphCompScrollEntry (pickClassComplete, mainPick->template, |
| 1733 |
250, 30,10.0, line, modeSearchEntry) ; |
| 1734 |
|
| 1735 |
|
| 1736 |
mainPick->grepBox = mainPick->templateBox; /* in new style window both boxes |
| 1737 |
* in one */ |
| 1738 |
mainPick->longGrepBox = 0; /* don't have this box in new style window */ |
| 1739 |
|
| 1740 |
line += 1.5 ; |
| 1741 |
/* class list */ |
| 1742 |
graphLine (0,line, graphWidth, line) ; line += .7 ; |
| 1743 |
|
| 1744 |
graphText ("Select a class:", 0.5, line) ; |
| 1745 |
|
| 1746 |
box = graphButton ("Other class ...", otherClassChoice, 22, line - .1); |
| 1747 |
graphBoxFreeMenu (box,(FreeMenuFunction) classListMenuCall, |
| 1748 |
arrp (classList, 0, FREEOPT)) ; |
| 1749 |
|
| 1750 |
box = graphButton ("Selection", layoutOpenEditor, 39, line - .1) ; |
| 1751 |
graphBoxMenu(box, 0); |
| 1752 |
|
| 1753 |
line += 1.3 ; |
| 1754 |
y = 0 ; |
| 1755 |
firstClassBox = graphBoxStart () ; |
| 1756 |
for (i = 0 ; i < arrayMax(classLayout) ; ++i) |
| 1757 |
{ int b = graphBoxStart () ; |
| 1758 |
z = arrp(classLayout, i, LAYOUT) ; |
| 1759 |
if (z->y > y) y = z->y ; |
| 1760 |
graphText (name(z->key), z->x, z->y + line) ; |
| 1761 |
if (pickFirstClass |
| 1762 |
&& (strcasecmp(name(z->key), pickFirstClass) == 0)) |
| 1763 |
{ |
| 1764 |
pickFirstBox = b; |
| 1765 |
} |
| 1766 |
graphBoxEnd () ; |
| 1767 |
} |
| 1768 |
graphBoxEnd () ; |
| 1769 |
|
| 1770 |
/* the first classbox that contain the class-chooser boxes forms |
| 1771 |
part of the background as well, so attach the bg-menu as well */ |
| 1772 |
#ifndef ACEMBLY |
| 1773 |
if (oxgridPossible()) |
| 1774 |
graphBoxMenu (firstClassBox, pickNewOxMenu) ; |
| 1775 |
else |
| 1776 |
#endif |
| 1777 |
graphBoxMenu (firstClassBox, pickNewMenu) ; |
| 1778 |
|
| 1779 |
line += y + 2 ; |
| 1780 |
|
| 1781 |
*(mainPick->grepText) = 0 ; |
| 1782 |
|
| 1783 |
messStatus ("Ready"); /* force redraw of whatdoIdoBox */ |
| 1784 |
|
| 1785 |
graphRedraw () ; |
| 1786 |
} /* pickDoDrawNew */ |
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
/************************************************************/ |
| 1791 |
|
| 1792 |
static void mainWindowReReadClasses (void) |
| 1793 |
/* called when models change */ |
| 1794 |
{ |
| 1795 |
arrayDestroy (classLayout) ; |
| 1796 |
classLayout = layoutRead (0); |
| 1797 |
|
| 1798 |
classList = classListCreate (classList, |
| 1799 |
TRUE, /* listHidden */ |
| 1800 |
TRUE, /* listVisible */ |
| 1801 |
FALSE, /* !listBuried */ |
| 1802 |
TRUE); /* listAllTypes */ |
| 1803 |
|
| 1804 |
return; |
| 1805 |
} /* mainWindowReReadClasses */ |
| 1806 |
|
| 1807 |
/************************************************************/ |
| 1808 |
|
| 1809 |
static void mainStatusDisplay (char *text, void *user_pointer) |
| 1810 |
/* registered using mainActivityRegister() as soon as the |
| 1811 |
* mainGraph is properly drawn and the whatDoIdoBox is a valid box */ |
| 1812 |
{ |
| 1813 |
#ifndef MACINTOSH |
| 1814 |
/* non-MACINTOSH */ |
| 1815 |
Pick pick = (Pick)user_pointer ; |
| 1816 |
static char *old = "dummy" ; /* some impossible value */ |
| 1817 |
Graph hold ; |
| 1818 |
|
| 1819 |
if (!pick) |
| 1820 |
/* we don't have a mainWindow yet */ |
| 1821 |
return ; |
| 1822 |
|
| 1823 |
if (pick->magic != &Pick_MAGIC) |
| 1824 |
messcrash("messStatus func mainStatusDisplay() - received in valid " |
| 1825 |
"user_pointer"); |
| 1826 |
|
| 1827 |
if (!text && !old) |
| 1828 |
/* we're asking to reset, but it is already in 'Ready' state, |
| 1829 |
* so we have nothing more to do in this function */ |
| 1830 |
return; |
| 1831 |
|
| 1832 |
hold = graphActive() ; |
| 1833 |
graphActivate(pick->mainGraph) ; |
| 1834 |
|
| 1835 |
if (!text) |
| 1836 |
{ old = 0 ; |
| 1837 |
strcpy(pick->whatdoIdoText, "Ready") ; |
| 1838 |
graphBoxDraw(pick->whatdoIdoBox,BLACK,PALEGREEN) ; |
| 1839 |
} |
| 1840 |
else if (text != old) |
| 1841 |
{ old = text ; |
| 1842 |
strncpy(pick->whatdoIdoText, text, ACTIVITY_LENGTH-1) ; |
| 1843 |
if (pick->whatdoIdoBox) |
| 1844 |
graphBoxDraw(pick->whatdoIdoBox,BLACK,RED) ; |
| 1845 |
} |
| 1846 |
|
| 1847 |
graphActivate(hold) ; |
| 1848 |
#else |
| 1849 |
/* MACINTOSH */ |
| 1850 |
extern void StartAsyncSpinning (short period) ; |
| 1851 |
extern void StopAsyncSpinning (void) ; |
| 1852 |
|
| 1853 |
static char *old = "dummy" ; /* some impossible value */ |
| 1854 |
|
| 1855 |
if (old != text ) |
| 1856 |
{ |
| 1857 |
if (!text) |
| 1858 |
{ old = 0 ; |
| 1859 |
StopAsyncSpinning () ; |
| 1860 |
} |
| 1861 |
else if (text != old) |
| 1862 |
{ old = text ; |
| 1863 |
StartAsyncSpinning (8) ; |
| 1864 |
} |
| 1865 |
} |
| 1866 |
#endif /* MACINTOSH */ |
| 1867 |
} /* mainStatusDisplay */ |
| 1868 |
|
| 1869 |
|
| 1870 |
/* state = 1 - template unchanged |
| 1871 |
* 2 - added a star at end |
| 1872 |
* 3 - autocomplete |
| 1873 |
*/ |
| 1874 |
/* then switch to the display graph (make if necessary) */ |
| 1875 |
static void obDisplay (Pick pick, BOOL show1, int state) |
| 1876 |
{ |
| 1877 |
char *message; |
| 1878 |
BOOL auto_display ; |
| 1879 |
|
| 1880 |
/* default message */ |
| 1881 |
if (pick->currClasse) |
| 1882 |
message = messprintf("%s:%s",name(pick->currClasse),pick->template) ; |
| 1883 |
else |
| 1884 |
message = messprintf("All classes:%s",pick->template) ; |
| 1885 |
|
| 1886 |
switch (state) |
| 1887 |
{ |
| 1888 |
case 1: |
| 1889 |
if (!keySetMax(pick->oblist)) |
| 1890 |
{ |
| 1891 |
if (pick->currClasse) |
| 1892 |
message = messprintf("No %s:%s %s", |
| 1893 |
name(pick->currClasse), |
| 1894 |
pick->template, |
| 1895 |
"is the class correct ? ") ; |
| 1896 |
else |
| 1897 |
message = messprintf("No object named %s in any class", |
| 1898 |
pick->template) ; |
| 1899 |
} |
| 1900 |
break ; |
| 1901 |
|
| 1902 |
case 2: |
| 1903 |
if (keySetMax(pick->oblist)) |
| 1904 |
{ |
| 1905 |
if (pick->currClasse) |
| 1906 |
message = messprintf("%s:%s %s", |
| 1907 |
name(pick->currClasse), |
| 1908 |
pick->template, |
| 1909 |
"No exact match, * appended") ; |
| 1910 |
else |
| 1911 |
message = messprintf("%s %s", |
| 1912 |
pick->template, |
| 1913 |
"No exact match in any class, * appended") ; |
| 1914 |
} |
| 1915 |
else |
| 1916 |
{ |
| 1917 |
if (pick->currClasse) |
| 1918 |
message = messprintf("No %s:%s %s", |
| 1919 |
name(pick->currClasse), |
| 1920 |
pick->template, |
| 1921 |
" is the class correct ? ") ; |
| 1922 |
else |
| 1923 |
message = messprintf("No object named %s in any class", |
| 1924 |
pick->template) ; |
| 1925 |
} |
| 1926 |
break ; |
| 1927 |
|
| 1928 |
case 3: |
| 1929 |
if (keySetMax(pick->oblist) == 0) |
| 1930 |
message = "No possible completion in this class" ; |
| 1931 |
break; |
| 1932 |
|
| 1933 |
case 4: |
| 1934 |
message = |
| 1935 |
"To search text please specify a search string \n" |
| 1936 |
" with at least 3 letters or digits.\n" |
| 1937 |
"Authorized wild chars are\n" |
| 1938 |
" * (any string), ? (single char)." ; |
| 1939 |
break; |
| 1940 |
|
| 1941 |
case 5: |
| 1942 |
if (!keySetMax(pick->oblist)) |
| 1943 |
{ state = 4 ; message = messprintf("%s Not found",pick->grepText) ; } |
| 1944 |
else |
| 1945 |
message = messprintf("Search %s",pick->grepText) ; |
| 1946 |
break ; |
| 1947 |
case 6: |
| 1948 |
if (!keySetMax(pick->oblist)) |
| 1949 |
{ |
| 1950 |
state = 4 ; |
| 1951 |
message = messprintf("%s Not found",pick->grepText) ; |
| 1952 |
} |
| 1953 |
else |
| 1954 |
message = messprintf("Long Search %s",pick->grepText) ; |
| 1955 |
break ; |
| 1956 |
|
| 1957 |
case 7: |
| 1958 |
if (!keySetMax(pick->oblist)) |
| 1959 |
{ |
| 1960 |
state = 4 ; |
| 1961 |
message = messprintf("Text %s Not found in any class", |
| 1962 |
pick->grepText) ; } |
| 1963 |
else |
| 1964 |
message = messprintf("Search %s in all classes",pick->grepText) ; |
| 1965 |
break ; |
| 1966 |
|
| 1967 |
case 8: |
| 1968 |
if (!keySetMax(pick->oblist)) |
| 1969 |
{ |
| 1970 |
state = 4 ; |
| 1971 |
message = messprintf("%s Not found in any class", |
| 1972 |
pick->grepText) ; |
| 1973 |
} |
| 1974 |
else |
| 1975 |
message = messprintf("Long Search %s in all classes", |
| 1976 |
pick->grepText) ; |
| 1977 |
break ; |
| 1978 |
|
| 1979 |
case 9: |
| 1980 |
message = messprintf("%s not found hit in selected class, \n" |
| 1981 |
"searched all classes (no hit)", |
| 1982 |
pick->grepText) ; |
| 1983 |
break ; |
| 1984 |
|
| 1985 |
case 10: |
| 1986 |
message = messprintf("%s not found in selected class, \n" |
| 1987 |
"long-searched all classes (no hit)", |
| 1988 |
pick->grepText) ; |
| 1989 |
break ; |
| 1990 |
} |
| 1991 |
|
| 1992 |
switch (state) |
| 1993 |
{ |
| 1994 |
case 5: |
| 1995 |
case 6: |
| 1996 |
case 7: |
| 1997 |
case 8: /* costly search, reply in new window */ |
| 1998 |
displayCreate("DtKeySet"); |
| 1999 |
graphRetitle(message) ; |
| 2000 |
keySetMessageShow (pick->oblist,0,message) ; |
| 2001 |
break ; |
| 2002 |
default: /* fast search, reply in main window */ |
| 2003 |
if (graphExists (pick->ksdisp_graph)) |
| 2004 |
keySetMessageShow (pick->oblist, pick->ksdisp_handle, message) ; |
| 2005 |
else |
| 2006 |
{ |
| 2007 |
pick->ksdisp_graph = displayCreate("DtKeySet"); |
| 2008 |
graphRetitle("Main KeySet") ; |
| 2009 |
pick->ksdisp_handle = keySetMessageShow (pick->oblist,0,message) ; |
| 2010 |
} |
| 2011 |
break ; |
| 2012 |
} |
| 2013 |
|
| 2014 |
|
| 2015 |
/* User can set preference to prevent automatic display of keysets where there is a single |
| 2016 |
* object. This is useful for superlinks/chromosomes and the like where display is v. slow |
| 2017 |
* or impossible due to memory constraints. */ |
| 2018 |
auto_display = prefValue("AUTO_DISPLAY") ; |
| 2019 |
if (auto_display && keySetMax(pick->oblist) == 1 && show1) |
| 2020 |
{ |
| 2021 |
KEY key = keySet(pick->oblist,0) ; |
| 2022 |
|
| 2023 |
display(key, 0, keySetGetShowAs (pick->ksdisp_handle, key)); |
| 2024 |
} |
| 2025 |
|
| 2026 |
pick->oblist = 0 ; /* since given to keySetShow */ |
| 2027 |
|
| 2028 |
#if !defined(WIN32) /* The WIN32 user interface is nicer |
| 2029 |
if I don't do this */ |
| 2030 |
graphActivate (pick->mainGraph) ; |
| 2031 |
#endif |
| 2032 |
} |
| 2033 |
|
| 2034 |
/**************** text action **********************/ |
| 2035 |
|
| 2036 |
static BOOL classDisplay (void) /* displays current option list */ |
| 2037 |
{ |
| 2038 |
char *cp ; |
| 2039 |
PICKGET("classDisplay") ; |
| 2040 |
|
| 2041 |
if (!pick->curr) |
| 2042 |
{ messout("Please pick a class") ; |
| 2043 |
return FALSE ; |
| 2044 |
} |
| 2045 |
|
| 2046 |
cp = pick->template ; |
| 2047 |
while (*cp == ' ') ++cp ; |
| 2048 |
if (!*cp) |
| 2049 |
{ strcpy (pick->template, "*") ; |
| 2050 |
graphBoxDraw (pick->templateBox, -1, -1) ; |
| 2051 |
} |
| 2052 |
|
| 2053 |
graphCompletionEntry (pickClassComplete,pick->template,0,0,0,0) ; |
| 2054 |
|
| 2055 |
return classListMenuCall |
| 2056 |
(arrp(classLayout,pick->curr-1,LAYOUT)->key, 0) ; |
| 2057 |
} /* classDisplay */ |
| 2058 |
|
| 2059 |
/**************** text action **********************/ |
| 2060 |
|
| 2061 |
static BOOL classDisplayNew (int curr) /* displays current option list */ |
| 2062 |
{ |
| 2063 |
char *cp ; |
| 2064 |
PICKGET("classDisplay") ; |
| 2065 |
|
| 2066 |
cp = pick->template ; |
| 2067 |
while (*cp == ' ') ++cp ; |
| 2068 |
if (!*cp) |
| 2069 |
{ strcpy (pick->template, "*") ; |
| 2070 |
graphBoxDraw (pick->templateBox, -1, -1) ; |
| 2071 |
} |
| 2072 |
|
| 2073 |
graphCompletionEntry (pickClassComplete,pick->template,0,0,0,0) ; |
| 2074 |
|
| 2075 |
return classListMenuCall |
| 2076 |
(curr ? arrp(classLayout,curr-1,LAYOUT)->key : 0, 0) ; |
| 2077 |
} /* classDisplayNew */ |
| 2078 |
|
| 2079 |
/*************************************************/ |
| 2080 |
|
| 2081 |
static void grepDisplayNew (int curr) |
| 2082 |
{ |
| 2083 |
KEYSET ob1 = 0, ob2 = 0, ob3 = 0; |
| 2084 |
int n , state ; |
| 2085 |
static int confirm = 0 ; |
| 2086 |
char *cp,*cq ; |
| 2087 |
static char localText[256] , lastText[256] ; |
| 2088 |
PICKGET("grepDisplay") ; |
| 2089 |
|
| 2090 |
/* first check that the search text is non-trivial */ |
| 2091 |
|
| 2092 |
for (n = 0, cp = pick->grepText ; *cp ; ++cp) |
| 2093 |
if (isprint((int)*cp) && *cp != '*' && *cp != '?') |
| 2094 |
++n ; |
| 2095 |
if (n < 3) |
| 2096 |
{ |
| 2097 |
/* |
| 2098 |
messout ("To search text please specify a search string " |
| 2099 |
"with at least 3 letters or digits." |
| 2100 |
" Authorized wild chars are\n" |
| 2101 |
"* (any string), ? (single char).") ; |
| 2102 |
*/ |
| 2103 |
|
| 2104 |
pick->longGrep = FALSE ; |
| 2105 |
if (pick->longGrepBox) |
| 2106 |
graphBoxDraw(pick->longGrepBox, BLACK, WHITE) ; |
| 2107 |
pick->oblist = keySetCreate () ; |
| 2108 |
obDisplay (pick, FALSE, 4) ; |
| 2109 |
return ; |
| 2110 |
} |
| 2111 |
|
| 2112 |
/* make localText with a '*' in front of and behind the grep text */ |
| 2113 |
|
| 2114 |
cp = pick->grepText ; |
| 2115 |
if (*cp == '*') |
| 2116 |
cq = localText ; |
| 2117 |
else |
| 2118 |
{ *localText = '*' ; |
| 2119 |
cq = localText+1 ; |
| 2120 |
} |
| 2121 |
while ((*cq++ = *cp++)) ; |
| 2122 |
if (cq[-2] != '*') |
| 2123 |
{ cq[-1] = '*' ; *cq = 0 ; } |
| 2124 |
|
| 2125 |
/* If the text has not changed, wait for confirmation */ |
| 2126 |
if(!strcmp(localText,lastText)) |
| 2127 |
if(!confirm++) |
| 2128 |
{ |
| 2129 |
if (pick->longGrepBox) |
| 2130 |
graphBoxDraw(pick->longGrepBox, BLACK, WHITE) ; |
| 2131 |
return ; |
| 2132 |
} |
| 2133 |
strncpy(lastText,localText,255) ; |
| 2134 |
strncpy(pick->grepText,localText,255) ; |
| 2135 |
confirm = 0 ; |
| 2136 |
|
| 2137 |
/* then do the search */ |
| 2138 |
graphBoxDraw(pick->grepBox,BLACK,RED) ; |
| 2139 |
if (pick->longGrep && pick->longGrepBox) |
| 2140 |
graphBoxDraw(pick->longGrepBox, BLACK, YELLOW) ; |
| 2141 |
if (externalServer) |
| 2142 |
ob1 = externalServer (0, 0, localText, FALSE) ; |
| 2143 |
else |
| 2144 |
ob1 = queryGrep(0, localText) ; |
| 2145 |
if (pick->longGrep) |
| 2146 |
{ |
| 2147 |
graphBoxDraw(pick->grepBox,BLACK,YELLOW) ; |
| 2148 |
if (pick->longGrepBox) |
| 2149 |
graphBoxDraw(pick->longGrepBox, BLACK, RED) ; |
| 2150 |
ob2 = longGrep(localText) ; |
| 2151 |
ob3 = keySetOR(ob1, ob2) ; |
| 2152 |
} |
| 2153 |
else |
| 2154 |
{ ob3 = ob1 ; ob1 = 0 ; } |
| 2155 |
|
| 2156 |
keySetDestroy(ob1) ; |
| 2157 |
keySetDestroy(ob2) ; |
| 2158 |
|
| 2159 |
graphBoxDraw(pick->grepBox,BLACK,YELLOW) ; |
| 2160 |
state = pick->longGrep ? 6 : 5 ; |
| 2161 |
pick->longGrep = FALSE ; |
| 2162 |
if (pick->longGrepBox) |
| 2163 |
graphBoxDraw(pick->longGrepBox, BLACK, WHITE) ; |
| 2164 |
|
| 2165 |
if (keySetMax(ob3) && curr) /* filter by single class */ |
| 2166 |
{ |
| 2167 |
int n2 = keySetMax(ob3), n3 = 0 ; |
| 2168 |
KEY *kp2, *kp3 ; |
| 2169 |
KEY cc = arrp(classLayout, curr-1, LAYOUT)->key ; |
| 2170 |
|
| 2171 |
/* it is better to filter locally than to query, becausee of client/server */ |
| 2172 |
ob2 = arrayCopy (ob3) ; |
| 2173 |
kp2 = arrp(ob2, 0, KEY) ; kp3 = arrp(ob3, 0, KEY) ; |
| 2174 |
while (n2--) |
| 2175 |
{ |
| 2176 |
if (lexIsInClass(*kp2, cc)) |
| 2177 |
{ *kp3++ = *kp2 ; n3++ ;} |
| 2178 |
kp2++ ; |
| 2179 |
} |
| 2180 |
keySetMax(ob3) = n3 ; |
| 2181 |
if (n3) |
| 2182 |
keySetDestroy (ob2) ; |
| 2183 |
else |
| 2184 |
{ |
| 2185 |
state += 4 ; /* report enlarged search */ |
| 2186 |
keySetDestroy (ob3) ; |
| 2187 |
ob3 = ob2 ; ob2 = 0 ; |
| 2188 |
} |
| 2189 |
} |
| 2190 |
else |
| 2191 |
state += 2 ; /* report general failure */ |
| 2192 |
pick->oblist = ob3 ; |
| 2193 |
obDisplay (pick, FALSE, state) ; |
| 2194 |
} |
| 2195 |
|
| 2196 |
static void grepDisplay (char *entry) |
| 2197 |
{ grepDisplayNew(0) ; } |
| 2198 |
|
| 2199 |
/**************** pick Action ************/ |
| 2200 |
|
| 2201 |
static int pickClassComplete (char *cp, int len) |
| 2202 |
{ |
| 2203 |
int i; |
| 2204 |
PICKGET("pickClassComplete") ; |
| 2205 |
|
| 2206 |
if (!pick->curr) |
| 2207 |
return 0 ; |
| 2208 |
|
| 2209 |
i = ksetClassComplete (cp, len, |
| 2210 |
arrp(classLayout, pick->curr-1, LAYOUT)->key) ; |
| 2211 |
|
| 2212 |
return i; |
| 2213 |
} /* pickClassComplete */ |
| 2214 |
|
| 2215 |
/* disgusting menu stuff...should use the new menu package.... */ |
| 2216 |
static void swopSigCatchMenuText(char *sig_txt, int admin_box) |
| 2217 |
{ |
| 2218 |
int i = 0 ; |
| 2219 |
|
| 2220 |
while (adminButtonFreeMenu[i].key != 'x') |
| 2221 |
i++ ; |
| 2222 |
|
| 2223 |
adminButtonFreeMenu[i].text = sig_txt ; |
| 2224 |
|
| 2225 |
graphBoxFreeMenu(admin_box, adminButtonFreeAction, adminButtonFreeMenu) ; |
| 2226 |
|
| 2227 |
return ; |
| 2228 |
} |
| 2229 |
|
| 2230 |
|
| 2231 |
/****************************************/ |
| 2232 |
/****************************************/ |
| 2233 |
|