extern instruction *NeedIndex( instruction *ins ) { /******************************************************* Mark conflicts for any name used in instruction as as segment as NEEDS_SEGMENT, or split out the segment if it is marked as NEEDS_SEGMENT_SPLIT (move the segment operand to a temp and use the temp as the segment override). Also, if any index conflicts are marked as NEEDS_INDEX_SPLIT, split them out into a temp as well. */ name *temp; name *index; conflict_node *conf; name *name; if( ins->num_operands > NumOperands( ins ) ) { name = ins->operands[ins->num_operands - 1]; conf = NameConflict( ins, name ); if( conf != NULL && _Isnt( conf, CST_NEEDS_SEGMENT_SPLIT ) ) { _SetTrue( conf, CST_NEEDS_SEGMENT ); MarkSegment( ins, name ); } else if( name->n.class != N_REGISTER ) { if( conf != NULL ) { _SetFalse( conf, CST_NEEDS_SEGMENT ); _SetTrue( conf, CST_WAS_SEGMENT ); } temp = AllocTemp( U2 ); ins->operands[ins->num_operands - 1] = temp; PrefixIns( ins, MakeMove( name, temp, U2 ) ); MarkSegment( ins, temp ); _SetTrue( NameConflict( ins, temp ), CST_SEGMENT_SPLIT ); ins = ins->head.prev; } }
void WndInvokePopUp( a_window *wnd, gui_point *point, gui_menu_struct *menu ) { int dummy; if( _Isnt( wnd, WSW_ALLOW_POPUP ) ) return; WndMenuItem( wnd, MENU_INITIALIZE, WndMenuRow, WndMenuPiece ); if( menu != NULL && wnd->num_popups == 1 ) { if( menu->style & GUI_GRAYED ) { Ring(); } else { WndMenuItem( wnd, wnd->popupmenu[ 0 ].id, WndMenuRow, WndMenuPiece ); } } else if( wnd->num_popups != 0 ) { if( menu == NULL ) { WndCreateFloatingPopup( wnd, point, wnd->num_popups, wnd->popupmenu, &wnd->last_popup ); } else if( menu->style & GUI_GRAYED ) { Ring(); } else if( menu->child == NULL ) { WndMenuItem( wnd, menu->id, WndMenuRow, WndMenuPiece ); } else { WndCreateFloatingPopup( wnd, point, menu->num_child_menus, menu->child, &dummy ); } } }
extern void WndSelPopPiece( a_window *wnd, bool paint_immed ) { wnd_row row; wnd_coord *start; wnd_coord *end; int piece; int buff_size; char *ptr; int first; int len; wnd_line_piece line; _Clr( wnd, WSW_SELECTING ); _Clr( wnd, WSW_SELECTING_WITH_KEYBOARD ); WndSelEnds( wnd, &start, &end ); if( _Isnt( wnd, WSW_SUBWORD_SELECT ) || ( start->row == end->row && start->piece == end->piece && start->col == end->col ) ) { WndGetLine( wnd, start->row, start->piece, &line ); GoBackward( wnd, start, &line ); WndGetLine( wnd, end->row, end->piece, &line ); GoForward( wnd, end, &line ); if( end->row != start->row ) { GUIWndDirtyRow( wnd->gui, end->row ); GUIWndDirtyRow( wnd->gui, start->row ); } else if( paint_immed ) { GUIWndDirtyRow( wnd->gui, start->row ); } else { WndDirtyScreenRange( wnd, start, end->col ); } } buff_size = 0; for( row = start->row; row <= end->row; ++row ) { for( piece = 0; ; ++piece ) { if( !WndGetLine( wnd, row, piece, &line ) ) break; if( WndSelected( wnd, &line, row, piece, &first, &len ) ) { buff_size += len + 1; } } } WndFree( wnd->popitem ); wnd->popitem = WndMustAlloc( buff_size+2 ); ptr = wnd->popitem; for( row = start->row; row <= end->row; ++row ) { for( piece = 0; ; ++piece ) { if( !WndGetLine( wnd, row, piece, &line ) ) break; if( WndSelected( wnd, &line, row, piece, &first, &len ) ) { if( ptr != wnd->popitem ) *ptr++ = ' '; memcpy( ptr, line.text+first, len ); ptr += len; } } } *ptr = '\0'; }
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 WndDrawCursor( a_window *wnd, wnd_line_piece *line, wnd_row row, int piece ) { const char *p; if( _Is( wnd, WSW_NOT_TO_SCREEN ) ) return; if( _Isnt( wnd, WSW_CHAR_CURSOR ) ) return; if( !line->tabstop ) return; if( wnd->current.row != row ) return; if( wnd->current.piece != piece ) return; if( wnd->current.col < 0 ) return; if( line->length == 0 ) { GUIDrawText( wnd->gui, " ", 1, row, line->indent, WndCursorAttr ); } else if( wnd->current.col < line->length ) { line->indent += GUIGetExtentX( wnd->gui, line->text, wnd->current.col ); p = line->text + wnd->current.col; GUIDrawText( wnd->gui, p, GUICharLen( *p ), row, line->indent, WndCursorAttr ); } }
extern void CalcSavings( conflict_node *conf ) { /**************************************************/ /* NB: <regsave> relies on the fact that "conf" is a parm to this routine*/ save_def block_save; save_def block_cost; save_def cost; save_def save; #undef _InRegAssgn #include "savcache.h" if( ( conf->name->v.usage & USE_IN_ANOTHER_BLOCK ) && ( conf->name->v.usage & ( NEEDS_MEMORY | USE_ADDRESS ) ) ) { CalcLoadStore( conf ); } if( _Is( conf, CONFLICT_ON_HOLD ) ) { conf->savings = 0; } else if( conf->available == 0 && _Isnt( conf, ( NEEDS_INDEX | NEEDS_SEGMENT ) ) ) { conf->savings = 0; } else if( conf->ins_range.first == conf->ins_range.last ) { conf->savings = 0; /* don't try - the world screws up*/ } else { cost = 0; save = 0; block_cost = 0; block_save = 0; opnd = conf->name; #include "savcode.h" if( save <= cost ) { conf->savings = 0; } else if( save - cost < MAX_SAVE ) { conf->savings = save - cost; } else { conf->savings = MAX_SAVE - 1; } } }
static bool WndCursorRightCheck( a_window *wnd ) { wnd_line_piece line; int col; bool got; got = WndGetLine( wnd, wnd->current.row, wnd->current.piece, &line ); if( _Isnt( wnd, WSW_CHAR_CURSOR ) || !WndHasCurrent( wnd ) || !got || wnd->current.col + 1 >= line.length ) { return( WndTabRight( wnd, false ) ); } else { WndDirtyCurrChar( wnd ); col = wnd->current.col; wnd->current.col += GUICharLen( line.text[wnd->current.col] ); WndSetCurrCol( wnd ); WndCurrVisible( wnd ); WndDirtyCurrChar( wnd ); return( col != wnd->current.col ); } }
static bool WndCursorLeftCheck( a_window *wnd ) { int col; wnd_line_piece line; if( _Isnt( wnd, WSW_CHAR_CURSOR )|| !WndHasCurrent( wnd ) || wnd->current.col == 0 ) { if( !WndTabLeft( wnd, false ) ) return( false ); wnd->current.col = WND_MAX_COL; WndSetCurrCol( wnd ); WndCurrVisible( wnd ); WndDirtyCurrChar( wnd ); return( true ); } else { WndGetLine( wnd, wnd->current.row, wnd->current.piece, &line ); WndDirtyCurrChar( wnd ); col = wnd->current.col; wnd->current.col = WndPrevCharCol( line.text, wnd->current.col ); WndSetCurrCol( wnd ); WndCurrVisible( wnd ); WndDirtyCurrChar( wnd ); return( col != wnd->current.col ); } }
static void WndDrawTheLine( a_window *wnd, wnd_line_piece *line, wnd_row row ) { gui_ord extent; gui_point start,end; gui_ord max_y; gui_ord max_x; wnd_bar_info *bar_info; if( _Isnt( wnd, WSW_NOT_TO_SCREEN ) ) { if( line->underline ) { max_y = WndMaxCharY( wnd ); start.x = line->indent; start.y = row * max_y + max_y / 2; end.x = line->indent + line->extent; end.y = start.y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); return; } else if( line->vertical_line ) { max_y = WndMaxCharY( wnd ); max_x = WndAvgCharX( wnd ); start.x = line->indent + max_x / 2; end.x = start.x; start.y = row * max_y; end.y = start.y + max_y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); return; } else if( line->draw_hook | line->draw_line_hook ) { if( GUIIsGUI() ) { max_y = WndMaxCharY( wnd ); max_x = WndAvgCharX( wnd ); start.x = line->indent + max_x / 2; end.x = start.x + max_x; start.y = row * max_y + max_y / 2; end.y = start.y; GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); start.x = line->indent + max_x / 2; end.x = start.x; start.y = row * max_y; end.y = start.y; if( line->draw_hook ) { end.y += max_y / 2; } else { end.y += max_y; } GUIDrawLine( wnd->gui, &start, &end, GUI_PEN_SOLID, 0, line->attr ); } else { char ch[3]; if( line->draw_hook ) { ch[0] = GUIGetCharacter( GUI_INACT_FRAME_LL_CORNER ); } else { ch[0] = GUIGetCharacter( GUI_INACT_RIGHT_TITLE_MARK ); } ch[1] = GUIGetCharacter( GUI_INACT_FRAME_BOTTOM ); ch[2] = '\0'; GUIDrawText( wnd->gui, ch, 2, row, line->indent, line->attr ); } return; } else if( line->draw_bar ) { bar_info = (wnd_bar_info *)line->text; if( bar_info->bar_group ) { GUIDrawBarGroup( wnd->gui, row, line->indent, line->extent - bar_info->bar_size2, bar_info->bar_size2, bar_info->bar_style, bar_info->bar_colour, bar_info->bar_colour2, bar_info->bar_selected ); } else { GUIDrawBar( wnd->gui, row, line->indent, line->extent, bar_info->bar_style, bar_info->bar_colour, bar_info->bar_selected ); } return; } else if( line->bitmap ) { GUIDrawHotSpot( wnd->gui, line->text[0], row, line->indent, line->attr ); return; } else if( line->extent == WND_NO_EXTEND ) { GUIDrawText( wnd->gui, line->text, line->length, row, line->indent, line->attr ); } else { GUIDrawTextExtent( wnd->gui, line->text, line->length, row, line->indent, line->attr, line->extent ); } } extent = GUIGetExtentX( wnd->gui, line->text, line->length ); if( line->extent != WND_MAX_EXTEND ) { if( line->extent > extent ) { extent = line->extent; } } if( line->indent + extent > wnd->max_indent ) { wnd->max_indent = line->indent + extent; } }