static void CallInit( a_window *wnd ) { int row; call_window *call = WndCall( wnd ); traceback *curr,*prev; call_chain *chain; int i; UpdateTraceBack( &call->tb ); curr = call->tb.curr; prev = call->tb.prev; WndNoSelect( wnd ); if( curr->clean_size == 0 || curr->total_depth < prev->total_depth ) { WndRepaint( wnd ); } else { row = curr->total_depth; if( prev->total_depth > row ) { row = prev->total_depth; } while( --row >= curr->clean_size ) { WndRowDirty( wnd, row ); } } call->max_sym_len = 0; chain = curr->chain; for( i = 0; i < curr->current_depth; ++i ) { if( chain[ i ].sym_len == 0 ) { chain[ i ].sym_len = WndExtentX( wnd, chain[ i ].symbol ); } if( chain[ i ].sym_len > call->max_sym_len ) { call->max_sym_len = chain[ i ].sym_len; } } }
extern void AsmMoveDot( a_window *wnd, address addr ) { int row; asm_window *asw; DIPHDL( cue, ch1 ); DIPHDL( cue, ch2 ); if( wnd == NULL ) return; asw = WndAsm( wnd ); if( DeAliasAddrCue( asw->mod, addr, ch1 ) != SR_NONE && DeAliasAddrCue( asw->mod, asw->dotaddr, ch2 ) != SR_NONE ) { if( CueMod( ch1 ) == CueMod( ch2 ) && CueFileId( ch1 ) == CueFileId( ch2 ) && CueLine( ch1 ) == CueLine( ch2 ) ) { return; } } WndNoSelect( wnd ); row = AsmAddrRow( wnd, addr ); if( row == WndRows( wnd ) ) { AsmSetFirst( wnd, addr, TRUE ); row = AsmAddrRow( wnd, addr ); WndDirtyCurr( wnd ); WndNewCurrent( wnd, row, PIECE_CURRENT ); WndRepaint( wnd ); row = 0; } else { WndDirtyCurr( wnd ); WndNewCurrent( wnd, row, PIECE_CURRENT ); } AsmSetDotAddr( wnd, addr ); }
static void BrkInit( a_window *wnd ) { gui_ord length, max; break_window *wndbreak; brkp *bp; int count; wndbreak = WndBreak( wnd ); max = 0; count = 0; for( bp = BrkList; bp != NULL; bp = bp->next ) { GetBPAddr( bp, TxtBuff ); length = WndExtentX( wnd, TxtBuff ); if( max < length ) max = length; ++count; } length = MaxGadgetLength + WndAvgCharX( wnd ); #ifdef OPENER_GADGET length += length; #endif wndbreak->addr_indent = length; length += max + 2 * WndMaxCharX( wnd ); wndbreak->source_indent = length; if( wndbreak->toggled_break ) { wndbreak->toggled_break = false; return; } WndNoSelect( wnd ); WndRepaint( wnd ); }
static void VarRepaint( a_window *wnd ) { var_window *var = WndVar( wnd ); VarAllNodesInvalid( &var->i ); VarKillExprSPCache( &var->i ); WndSetThumb( wnd ); WndNoSelect( wnd ); WndRepaint( wnd ); WndResetScroll( wnd ); }
void WPDoPopUp( a_window * wnd, gui_menu_struct * gui_menu ) /**********************************************************/ { sio_data * curr_sio; WndPopUp( wnd, gui_menu ); WndNoSelect( wnd ); curr_sio = WndExtra( wnd ); curr_sio->curr_proc_row = -WND_MAX_ROW; curr_sio->curr_display_row = -WND_MAX_ROW; }
void AccelMenuItem( gui_menu_struct *menu, bool is_main ) { a_window *wnd = WndFindActive(); if( is_main ) { WndMainMenuProc( wnd, menu->id ); } else { WndKeyPopUp( wnd, menu ); WndNoSelect( wnd ); } }
extern void WndKeyPopItem( a_window *wnd, bool paint_immed ) { if( !WndHasCurrent( wnd ) || _Isnt( wnd, WSW_CHAR_CURSOR ) ) { WndNullPopItem( wnd ); return; } if( wnd->sel_start.row == WND_NO_ROW ) { WndNoSelect( wnd ); wnd->sel_start = wnd->current; } if( wnd->sel_end.row == WND_NO_ROW ) { wnd->sel_end = wnd->current; } WndSelPopPiece( wnd, paint_immed ); }
static void TrdRefresh( a_window *wnd ) { thread_state *thd; int row; row = 0; for( thd = HeadThd; thd != NULL; thd = thd->link ) { if( IsThdCurr( thd ) ) { WndMoveCurrent( wnd, row, PIECE_ID ); break; } ++row; } WndNoSelect( wnd ); WndRepaint( wnd ); }
static void ModCalcIndent( a_window *wnd ) { gui_ord extent,max_extent; int i,size; mod_window *mod = WndMod( wnd ); size = ModListNumRows( ModList( mod ) ); max_extent = 0; for( i = 0; i < size; ++i ) { ModListName( ModList( mod ), i, TxtBuff ); extent = WndExtentX( wnd, TxtBuff ); if( extent > max_extent ) max_extent = extent; } mod->max_modlen = max_extent + WndMidCharX( wnd ); WndNoSelect( wnd ); WndRepaint( wnd ); }
extern void WndPopUp( a_window *wnd, gui_menu_struct *menu ) { gui_point point; point.x = 0; point.y = 0; wnd->sel_end.row = 0; if( !WndHasCurrent( wnd ) ) { WndFirstCurrent( wnd ); } if( WndHasCurrent( wnd ) ) { WndNoSelect( wnd ); wnd->current.col = 0; // just to be sure WndCurrToGUIPoint( wnd, &point ); wnd->sel_end = wnd->current; wnd->sel_start = wnd->current; } WndNullPopItem( wnd ); SetWndMenuRow( wnd ); WndInvokePopUp( wnd, &point, menu ); }
static a_window *WndCreateWithStructBody( wnd_create_struct *info, gui_create_info *init ) { a_window *wnd; gui_window *gui; char buff[256]; int size; if( info->title == NULL ) { buff[0] = '\0'; } else { // might be clobbered by create strcpy( buff, info->title ); } if( info->title != NULL ) strcpy( buff, info->title ); // might be clobbered by create size = sizeof( *wnd ) + ( WndMaxDirtyRects - 1 ) * sizeof( wnd->dirty ); // wnd = WndAlloc( size ); if( wnd == NULL ) { WndFree( info->extra ); WndNoMemory(); } memset( wnd, 0, size ); wnd->u.button_down.row = (char)-1; wnd->gui = NULL; wnd->info = info->info; wnd->wndclass = info->wndclass; wnd->extra = info->extra; wnd->title_size = info->title_size; wnd->rows = 1; // just so it's not zero in init code WndNoSelect( wnd ); WndNoCurrent( wnd ); WndSetCurrCol( wnd ); WndNullPopItem( wnd ); wnd->dirtyrects= 0; // wndnoselect changes this! wnd->vscroll_pending = 0; wnd->hscroll_pending = -1; wnd->keypiece = WND_NO_PIECE; wnd->switches = WSW_SELECT_IN_TABSTOP | WSW_MUST_CLICK_ON_PIECE | WSW_ALLOW_POPUP | WSW_SEARCH_WRAP | WSW_HIGHLIGHT_CURRENT | WSW_ONLY_MODIFY_TABSTOP | WSW_MENU_ACCURATE_ROW; if( info->rect.width == 0 || info->rect.height == 0 ) { init->rect.x = 0; init->rect.y = 0; init->rect.width = WndMax.x; init->rect.height = WndMax.y; } else { init->rect.x = info->rect.x; init->rect.y = info->rect.y; init->rect.width = info->rect.width; init->rect.height = info->rect.height; } init->scroll = info->scroll; init->style = info->style; init->style |= GUI_VSCROLL_EVENTS; init->style &= ~GUI_HSCROLL_EVENTS; init->title = ( info->title == NULL ) ? NULL : ""; if( WndMain != NULL ) { init->style |= GUI_VISIBLE; init->parent = WndMain->gui; init->num_menus = 0; init->menu = NULL; } else { init->style &= ~GUI_VISIBLE; init->scroll = GUI_NOSCROLL; init->num_menus = WndNumMenus; init->menu = WndMainMenu; init->parent = NULL; } if( init->style & GUI_POPUP ) { init->parent = NULL; } init->num_attrs = WndNumColours; init->colours = info->colour; init->call_back = WndMainEventProc; init->extra = wnd; _Set( wnd, WSW_ACTIVE ); gui = GUICreateWindow( init ); if( gui == NULL ) { WndFree( info->extra ); WndFree( wnd ); WndNoMemory(); return( NULL ); } else { if( buff[0] != '\0' ) { WndSetTitle( wnd, buff ); } } ++NumWindows; return( wnd ); }
OVL_EXTERN void IORefresh( a_window wnd ) { WndNoSelect( wnd ); WndSetRepaint( wnd ); }
OVL_EXTERN void IOMenuItem( a_window wnd, gui_ctl_id id, wnd_row row, wnd_piece piece ) { io_window *io = WndIO( wnd ); address addr; bool ok; item_mach item; io_location *curr; mad_radix old_radix; /* unused parameters */ (void)piece; if( row < io->num_rows && row >= 0 ) { curr = &io->list[row]; } else { curr = NULL; } switch( id ) { case MENU_INITIALIZE: if( curr == NULL ) { WndMenuGrayAll( wnd ); } else { WndMenuEnableAll( wnd ); } WndMenuEnable( wnd, MENU_IO_NEW_ADDRESS, true ); break; case MENU_IO_DELETE: io->num_rows--; memcpy( &io->list[row], &io->list[row + 1], ( io->num_rows - row ) * sizeof( io_location ) ); WndNoSelect( wnd ); WndSetRepaint( wnd ); break; case MENU_IO_NEW_ADDRESS: addr = NilAddr; if( !DlgGivenAddr( LIT_DUI( New_Port_Addr ), &addr ) ) return; WndRowDirty( wnd, io->num_rows ); IOAddNewAddr( wnd, &addr, MENU_IO_FIRST_TYPE ); WndScrollBottom( wnd ); break; case MENU_IO_MODIFY: if( row >= io->num_rows || row < 0 ) break; if( piece == PIECE_VALUE ) { old_radix = NewCurrRadix( IOData.info[curr->type].piece_radix ); item.ud = curr->value_known ? curr->value.ud : 0; ok = DlgMadTypeExpr( TxtBuff, &item, IOData.info[curr->type].mth ); if( ok ) { curr->value = item; curr->value_known = true; } NewCurrRadix( old_radix ); } else { addr = curr->addr; if( !DlgGivenAddr( LIT_DUI( New_Port_Addr ), &addr ) ) return; curr->addr = addr; curr->value_known = false; } WndRowDirty( wnd, row ); break; case MENU_IO_READ: curr->value_known = true; if( ItemGetMAD( &curr->addr, &curr->value, IT_IO, IOData.info[curr->type].mth ) == IT_NIL ) { curr->value_known = false; } WndPieceDirty( wnd, row, PIECE_VALUE ); break; case MENU_IO_WRITE: if( curr->value_known ) { ItemPutMAD( &curr->addr, &curr->value, IT_IO, IOData.info[curr->type].mth ); } break; default: curr->type = PIECE_TYPE( id ); WndZapped( wnd ); break; } }
extern bool WndSearch( a_window *wnd, bool from_top, int direction ) { wnd_line_piece line; regexp *rx; char *pos; char *endpos; bool wrap; int rows; bool rc; bool had_cache; char *not_found; char *top_of_window; char *end_of_window; char *search_wrapped; wnd_subpiece next_occurence; wnd_subpiece prev_occurence; wnd_subpiece curr; wnd_coord starting_pos; if( direction == 0 ) return( FALSE ); if( wnd == NULL ) return( FALSE ); if( wnd->searchitem == NULL ) return( FALSE ); rx = WndCompileRX( wnd->searchitem ); if( rx == NULL ) return( FALSE ); not_found = WndLoadString( LITERAL_Not_Found ); top_of_window = WndLoadString( LITERAL_Top_Of_Window ); end_of_window = WndLoadString( LITERAL_End_Of_Window ); search_wrapped = WndLoadString( LITERAL_Search_Wrapped ); wrap = FALSE; starting_pos.piece = 0; starting_pos.col = direction > 0 ? -1 : WND_MAX_COL; if( from_top ) { curr.row = 0; } else if( WndHasCurrent( wnd ) ) { curr.row = WndVirtualRow( wnd, wnd->current.row ); starting_pos.piece = wnd->current.piece; starting_pos.col = wnd->current.col; } else { curr.row = WndVirtualTop( wnd ); } starting_pos.row = curr.row; WndNextRow( wnd, WND_NO_ROW, WND_SAVE_ROW ); WndStatusText( "" ); WndDoingSearch = TRUE; had_cache = WndSetCache( wnd, FALSE ); for( ;; ) { if( curr.row < 0 ) { if( wrap ) { NotFound( wnd, rx, not_found ); rc = FALSE; goto done; } else if( _Is( wnd, WSW_SEARCH_WRAP ) ) { rows = WndNumRows( wnd ); if( rows == -1 ) { WndRepaint( wnd ); WndScrollAbs( wnd, -wnd->title_size ); rows = WndScrollAbs( wnd, WND_MAX_ROW ) + WndRows( wnd ); } curr.row = rows - 1; curr.col = 0; curr.piece = -1; wrap = TRUE; continue; } else { NotFound( wnd, rx, top_of_window ); rc = FALSE; goto done; } } next_occurence.col = -1; prev_occurence.col = -1; for( curr.piece = 0;; ++curr.piece ) { // look for both next and prev match if( !WndGetLineAbs( wnd, curr.row, curr.piece, &line ) ) { if( curr.piece != 0 ) break; if( wrap ) { NotFound( wnd, rx, not_found ); rc = FALSE; goto done; } else if( _Is( wnd, WSW_SEARCH_WRAP ) ) { curr.row = 0; curr.col = 0; curr.piece = -1; wrap = TRUE; continue; } else { NotFound( wnd, rx, end_of_window ); rc = FALSE; goto done; } } if( line.bitmap ) continue; pos = line.text; endpos = NULL; while( WndRXFind( rx, &pos, &endpos ) ) { curr.end = endpos - line.text; curr.col = pos - line.text; if( curr.piece < starting_pos.piece ) { prev_occurence = curr; } else if( curr.piece > starting_pos.piece ) { if( next_occurence.col == -1 ) { next_occurence = curr; } } else if( curr.col > starting_pos.col ) { if( next_occurence.col == -1 ) { next_occurence = curr; } } else if( curr.col < starting_pos.col ) { prev_occurence = curr; } ++pos; } } if( direction < 0 ) { next_occurence = prev_occurence; } if( next_occurence.col != -1 ) { WndDoingSearch = FALSE; WndKillCacheLines( wnd ); WndDirtyCurr( wnd ); WndNoSelect( wnd ); WndNoCurrent( wnd ); if( curr.row < WndVirtualTop( wnd ) ) { if( curr.row > wnd->rows / 2 ) { WndRepaint( wnd ); WndScrollAbs( wnd, curr.row - wnd->rows / 2 ); } else { WndRepaint( wnd ); WndScrollAbs( wnd, -wnd->title_size ); } } else if( curr.row >= WndVirtualBottom( wnd ) ) { WndRepaint( wnd ); WndScrollAbs( wnd, curr.row - wnd->rows / 2 ); } wnd->sel_start.row = WndScreenRow( wnd, curr.row ); wnd->sel_start.piece = next_occurence.piece; wnd->sel_start.col = next_occurence.col; wnd->sel_end = wnd->sel_start; wnd->sel_end.col = next_occurence.end - 1; wnd->current.col = wnd->sel_end.col; wnd->current = wnd->sel_start; WndSetCurrCol( wnd ); WndCurrVisible( wnd ); WndDirtyCurr( wnd ); WndFreeRX( rx ); if( wrap ) WndStatusText( search_wrapped ); rc = TRUE; goto done; } if( direction > 0 ) { if( wrap && curr.row > starting_pos.row ) { NotFound( wnd, rx, not_found ); rc = FALSE; goto done; } starting_pos.col = -1; starting_pos.piece = 0; curr.row = WndNextRow( wnd, curr.row, 1 ); } else { starting_pos.col = WND_MAX_COL; starting_pos.piece = WND_MAX_COL; curr.row = WndNextRow( wnd, curr.row, -1 ); } curr.piece = 0; } done:; WndSetCache( wnd, had_cache ); WndFree( not_found ); WndFree( top_of_window ); WndFree( end_of_window ); WndFree( search_wrapped ); return( rc ); }
void WndCursorDown( a_window *wnd ) { WndNoSelect( wnd ); WndMoveDown( wnd ); }
void WndCursorUp( a_window *wnd ) { WndNoSelect( wnd ); WndMoveUp( wnd ); }