int gator_light_display(struct onode *onp) { /*gator_light_display */ static char rn[] = "gator_light_display"; /*Routine name */ struct gator_lightobj *light_data; /*Ptr to light obj data */ struct gwin_strparams *label_strparams; /*String-drawing params */ /* * Draw the label, with proper highlighting depending on whether * the light is on. */ light_data = (struct gator_lightobj *)(onp->o_data); label_strparams = (struct gwin_strparams *)(light_data->llrock); if (objects_debug) fprintf(stderr, "[%s:%s] Printing out light label '%s' at (%d, %d)\n", mn, rn, label_strparams->s, label_strparams->x, label_strparams->y); WOP_DRAWSTRING(onp->o_window, label_strparams); return (0); } /*gator_light_display */
int gator_text_display(struct onode *onp) { /*gator_text_display */ static char rn[] = "gator_text_display"; /*Routine name */ struct gator_textobj *text_data; /*Ptr to text obj data */ struct gator_textcb_hdr *cbHdr; /*Ptr to CB header */ struct gwin_strparams strparams; /*String-drawing params */ int currLine; /*Current line being updated */ int currLinesUsed; /*Num screen lines used */ int currIdx; /*Current line index */ int currEnt; /*Current entry being drawn */ struct gator_textcb_entry *curr_ent; /*Ptr to current entry */ if (objects_debug) fprintf(stderr, "[%s:%s] Displaying text object at %p\n", mn, rn, onp); text_data = (struct gator_textobj *)(onp->o_data); cbHdr = text_data->cbHdr; if (objects_debug) fprintf(stderr, "[%s:%s] Displaying text object at %p, object-specific data at %p\n", mn, rn, onp, text_data); /* * Update each line in the screen buffer with its proper contents. */ currEnt = text_data->firstEntShown; currLinesUsed = text_data->lastEntShown - currEnt + 1; currIdx = (cbHdr->oldestEntIdx + (currEnt - cbHdr->oldestEnt)) % cbHdr->maxEntriesStored; curr_ent = cbHdr->entry + currIdx; if (objects_debug) fprintf(stderr, "[%s:%s] Drawing %d populated lines, starting with entry %d (index %d) at %p", mn, rn, currLinesUsed, currEnt, currIdx, curr_ent); strparams.x = onp->o_x; strparams.y = onp->o_y; for (currLine = 0; currLine < text_data->numLines; currLine++) { /* * Draw the current entry. */ if (currLinesUsed > 0) { /* * Drawing a populated line. We need to iterate if there are * inversions (I don't feel like doing this now). */ strparams.s = curr_ent->textp; strparams.highlight = curr_ent->highlight; WOP_DRAWSTRING(onp->o_window, &strparams); currLinesUsed--; currEnt++; currIdx++; if (currIdx >= cbHdr->maxEntriesStored) { currIdx = 0; curr_ent = cbHdr->entry; } else curr_ent++; } else { /* * Draw a blank line. */ strparams.s = cbHdr->blankLine; strparams.highlight = 0; WOP_DRAWSTRING(onp->o_window, &strparams); } /* * Adjust the X and Y locations. */ strparams.x = 0; strparams.y++; } /*Update loop */ /* * Box the window before we leave. */ #if GATOR_TEXTCB_DO_BOX if (objects_debug) fprintf(stderr, "[%s:%s] Boxing window structure at 0x%x\n", mn, rn, onp->o_window); WOP_BOX(onp->o_window); #endif /* GATOR_TEXTCB_DO_BOX */ /* * For now, this is all we do. */ return (0); } /*gator_text_display */