void build_subsumed(GHashTable *tbl, pred_t *p) { int i; for (i = 0; i < p->hist->pred_n; i++) { if (HAS_FLAG(p->hist->pred[i].flags, CONTEXT) && HAS_FLAG(p->hist->pred[i].flags, HIST_C) && p->hist->pred[i].cond == p->cond) { pair_t *pr = MYmalloc(sizeof(pair_t)); pr->origin = p; pr->produced = p->hist->pred + i; pred_t *pred = g_hash_table_lookup(tbl, p); if (!pred) { g_hash_table_insert(tbl, p, pr); pred = p; } if (!HAS_FLAG(pred->flags, BLACK)) SET_FLAG(pred->flags, RED); } else if (HAS_FLAG(p->hist->pred[i].flags, PRESET)) { pair_t *pr = g_hash_table_lookup(tbl, p->hist->pred + i); if (pr) { CLEAN_FLAG(pr->produced->flags, RED); SET_FLAG(pr->produced->flags, BLACK); } } build_subsumed(tbl, p->hist->pred + i); } }
void CDropTarget::NormalizeDropEffect( DWORD &dwEffect ) const { // switch from move to copy if source object doesn't allow move if ( HAS_FLAG( dwEffect, DROPEFFECT_MOVE ) && !HAS_FLAG( m_dwSourceEffect, DROPEFFECT_MOVE ) ) { dwEffect &= ~DROPEFFECT_MOVE; dwEffect |= DROPEFFECT_COPY; } }
queue_err_t queue_open(void *p, const char *filename, int flags) { int omask; mode_t oldmask; posix_queue_t *q; q = (posix_queue_t *) p; if (HAS_FLAG(flags, QUEUE_FL_SENDER)) { omask = O_WRONLY; } else { omask = O_RDONLY; } if (HAS_FLAG(flags, QUEUE_FL_OWNER)) { omask |= O_CREAT | O_EXCL; oldmask = umask(0); if (NULL == (q->filename = strdup(filename))) { // TODO: error return QUEUE_ERR_GENERAL_FAILURE; } } if (NOT_MQD_T == (q->mq = mq_open(filename, omask, 0660, &q->attr))) { if (HAS_FLAG(flags, QUEUE_FL_OWNER)) { umask(oldmask); #ifdef __FreeBSD__ if (ENOSYS == errno) { // please load mqueuefs module with kldload or recompile your kernel to include "options P1003_1B_MQUEUE" } #endif } // TODO: error return QUEUE_ERR_GENERAL_FAILURE; } if (!HAS_FLAG(flags, QUEUE_FL_SENDER)) { // mq_setattr implies CAP_EVENT? CAP_RIGHTS_LIMIT(__mq_oshandle(q->mq), CAP_READ, CAP_EVENT); #if 0 } else { CAP_RIGHTS_LIMIT(__mq_oshandle(q->mq), CAP_WRITE, CAP_EVENT); #endif } if (HAS_FLAG(flags, QUEUE_FL_OWNER)) { umask(oldmask); } else { if (0 != mq_getattr(q->mq, &q->attr)) { // TODO: error return QUEUE_ERR_GENERAL_FAILURE; } } return QUEUE_ERR_OK; }
//#ifndef RELEASE // Give the megawow powerup! void do_megawow_powerup(int quantity) { int i; powerup_basic(30, 0, 30, 1, "MEGA-WOWIE-ZOWIE!"); Players[Player_num].primary_weapon_flags = 0xffff ^ HAS_FLAG(SUPER_LASER_INDEX); //no super laser Players[Player_num].secondary_weapon_flags = 0xffff; for (i=0; i<MAX_PRIMARY_WEAPONS; i++) Players[Player_num].primary_ammo[i] = VULCAN_AMMO_MAX; for (i=0; i<3; i++) Players[Player_num].secondary_ammo[i] = quantity; for (i=3; i<MAX_SECONDARY_WEAPONS; i++) Players[Player_num].secondary_ammo[i] = quantity/5; if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL); Players[Player_num].energy = F1_0*200; Players[Player_num].shields = F1_0*200; Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS; Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL; if (Game_mode & GM_HOARD) Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12; update_laser_weapon_info(); }
//#ifndef RELEASE // Give the megawow powerup! void DoMegaWowPowerup (int quantity) { int i; PowerupBasic (30, 0, 30, 1, "MEGA-WOWIE-ZOWIE!"); gameData.multi.players [gameData.multi.nLocalPlayer].primary_weapon_flags = 0xffff ^ HAS_FLAG (SUPER_LASER_INDEX); //no super laser gameData.multi.players [gameData.multi.nLocalPlayer].secondary_weapon_flags = 0xffff; for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].primary_ammo[i] = VULCAN_AMMO_MAX; for (i = 0; i < 3; i++) gameData.multi.players [gameData.multi.nLocalPlayer].secondary_ammo[i] = quantity; for (i = 3; i < MAX_SECONDARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].secondary_ammo[i] = quantity/5; if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordLaserLevel (gameData.multi.players [gameData.multi.nLocalPlayer].laser_level, MAX_LASER_LEVEL); gameData.multi.players [gameData.multi.nLocalPlayer].energy = F1_0 * 200; gameData.multi.players [gameData.multi.nLocalPlayer].shields = F1_0 * 200; MultiSendShields (); gameData.multi.players [gameData.multi.nLocalPlayer].flags |= PLAYER_FLAGS_QUAD_LASERS; gameData.multi.players [gameData.multi.nLocalPlayer].laser_level = MAX_SUPER_LASER_LEVEL; if (gameData.app.nGameMode & GM_HOARD) gameData.multi.players [gameData.multi.nLocalPlayer].secondary_ammo[PROXIMITY_INDEX] = 12; else if (gameData.app.nGameMode & GM_ENTROPY) gameData.multi.players [gameData.multi.nLocalPlayer].secondary_ammo[PROXIMITY_INDEX] = 15; UpdateLaserWeaponInfo (); }
BOOL is_alpha( register TCHAR ch ) { #ifdef _UNICODE if ( ( UINT ) ch > 255 ) return ISALPHA_EXPR( ch ); // use expensive version for less used chars else #endif return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_ALPHA ); }
BOOL is_numeric( register TCHAR ch ) { #ifdef _UNICODE if ( ( UINT ) ch > 255 ) return ISNUMERIC_EXPR( ch ); // use expensive version for less used chars else #endif return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_NUMERIC ); }
BOOL is_symbolorpunct( register TCHAR ch ) { #ifdef _UNICODE if ( ( UINT ) ch > 255 ) return ISSYMBOLORPUNCT_EXPR( ch ); // use expensive version for less used chars else #endif return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_SYMBOLORPUNCT ); }
BOOL is_eoln( TCHAR ch ) { #ifdef _UNICODE if ( ( UINT ) ch > 255 ) return ISEOLN_EXPR( ch ); // use expensive version for less used chars else #endif return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_EOLN ); }
void WowieCheat (int bVerbose) { int h, i; if (bVerbose) HUDInitMessage (TXT_WOWIE_ZOWIE); if (gameStates.app.bD1Mission) { LOCALPLAYER.primaryWeaponFlags = (1 << LASER_INDEX | (1 << VULCAN_INDEX) | (1 << SPREADFIRE_INDEX) | (1 << PLASMA_INDEX)) | (1 << FUSION_INDEX); LOCALPLAYER.secondaryWeaponFlags = (1 << CONCUSSION_INDEX) | (1 << HOMING_INDEX) | (1 << PROXMINE_INDEX) | (1 << SMART_INDEX) | (1 << MEGA_INDEX); for (i=0; i < MAX_D1_PRIMARY_WEAPONS; i++) LOCALPLAYER.primaryAmmo [i] = nMaxPrimaryAmmo [i]; for (i=0; i < MAX_D1_SECONDARY_WEAPONS; i++) LOCALPLAYER.secondaryAmmo [i] = nMaxSecondaryAmmo [i]; } else { if (gameData.pig.tex.nHamFileVersion < 3) {// SHAREWARE LOCALPLAYER.primaryWeaponFlags = ~ ((1<<PHOENIX_INDEX) | (1<<OMEGA_INDEX) | (1<<FUSION_INDEX) | HAS_FLAG (SUPER_LASER_INDEX)); LOCALPLAYER.secondaryWeaponFlags = ~ ((1<<MERCURY_INDEX) | (1<<MEGA_INDEX) | (1<<EARTHSHAKER_INDEX)); } else { LOCALPLAYER.primaryWeaponFlags = 0xffff ^ HAS_FLAG (SUPER_LASER_INDEX); //no super laser LOCALPLAYER.secondaryWeaponFlags = 0xffff; } h = (LOCALPLAYER.flags & PLAYER_FLAGS_AMMO_RACK) ? 2 : 1; for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) LOCALPLAYER.primaryAmmo [i] = nMaxPrimaryAmmo [i] * h; for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) LOCALPLAYER.secondaryAmmo [i] = nMaxSecondaryAmmo [i] * h; if (!COMPETITION && EGI_FLAG (bSmokeGrenades, 0, 0, 0)) LOCALPLAYER.secondaryAmmo [PROXMINE_INDEX] = 4; if (gameData.pig.tex.nHamFileVersion < 3) {// SHAREWARE LOCALPLAYER.secondaryAmmo [MERCURY_INDEX] = 0; LOCALPLAYER.secondaryAmmo [EARTHSHAKER_INDEX] = 0; LOCALPLAYER.secondaryAmmo [MEGA_INDEX] = 0; } if (gameData.app.nGameMode & GM_HOARD) LOCALPLAYER.secondaryAmmo [PROXMINE_INDEX] = 12; else if (gameData.app.nGameMode & GM_ENTROPY) { LOCALPLAYER.secondaryAmmo [PROXMINE_INDEX] = 5 * h; LOCALPLAYER.secondaryAmmo [SMARTMINE_INDEX] = 5 * h; } } bLastSecondaryWasSuper [PROXMINE_INDEX] = 1; if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordLaserLevel (LOCALPLAYER.laserLevel, MAX_LASER_LEVEL); LOCALPLAYER.energy = MAX_ENERGY; if (gameStates.app.bD1Mission) LOCALPLAYER.laserLevel = MAX_LASER_LEVEL; else LOCALPLAYER.laserLevel = MAX_SUPER_LASER_LEVEL; LOCALPLAYER.flags |= PLAYER_FLAGS_QUAD_LASERS; UpdateLaserWeaponInfo (); SetLastSuperWeaponStates (); }
void DropCurrentWeapon () { int ammo=0,seed; objnum_t objnum; if (num_objects >= MAX_USED_OBJECTS) return; if (Primary_weapon==0) { HUD_init_message(HM_DEFAULT, "You cannot drop your base weapon!"); return; } HUD_init_message(HM_DEFAULT, "%s dropped!",PRIMARY_WEAPON_NAMES(Primary_weapon)); digi_play_sample (SOUND_DROP_WEAPON,F1_0); seed = d_rand(); objnum = spit_powerup(ConsoleObject,Primary_weapon_to_powerup[Primary_weapon],seed); if (objnum==object_none) return; if (Primary_weapon == VULCAN_INDEX || Primary_weapon == GAUSS_INDEX) { //if it's one of these, drop some ammo with the weapon ammo = Players[Player_num].primary_ammo[VULCAN_INDEX]; if ((Players[Player_num].primary_weapon_flags & HAS_FLAG(VULCAN_INDEX)) && (Players[Player_num].primary_weapon_flags & HAS_FLAG(GAUSS_INDEX))) ammo /= 2; //if both vulcan & gauss, drop half Players[Player_num].primary_ammo[VULCAN_INDEX] -= ammo; if (objnum!=object_none) Objects[objnum].ctype.powerup_info.count = ammo; } if (Primary_weapon == OMEGA_INDEX) { //dropped weapon has current energy if (objnum!=object_none) Objects[objnum].ctype.powerup_info.count = Omega_charge; } #ifdef NETWORK if ((Game_mode & GM_MULTI) && objnum!=object_none) multi_send_drop_weapon(objnum,seed); #endif Players[Player_num].primary_weapon_flags &= (~(1<<Primary_weapon)); auto_select_weapon (0); }
void WowieCheat (void) { int h, i; HUDInitMessage (TXT_WOWIE_ZOWIE); if (gameStates.app.bD1Mission) { gameData.multi.players [gameData.multi.nLocalPlayer].primaryWeaponFlags = (1 << LASER_INDEX | (1 << VULCAN_INDEX) | (1 << SPREADFIRE_INDEX) | (1 << PLASMA_INDEX)) | (1 << FUSION_INDEX); gameData.multi.players [gameData.multi.nLocalPlayer].secondaryWeaponFlags = (1 << CONCUSSION_INDEX) | (1 << HOMING_INDEX) | (1 << PROXIMITY_INDEX) | (1 << SMART_INDEX) | (1 << MEGA_INDEX); for (i=0; i < MAX_D1_PRIMARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].primaryAmmo [i] = nMaxPrimaryAmmo [i]; for (i=0; i < MAX_D1_SECONDARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo[i] = nMaxSecondaryAmmo [i]; } else { if (gameData.pig.tex.nHamFileVersion < 3) {// SHAREWARE gameData.multi.players [gameData.multi.nLocalPlayer].primaryWeaponFlags = ~((1<<PHOENIX_INDEX) | (1<<OMEGA_INDEX) | (1<<FUSION_INDEX) | HAS_FLAG(SUPER_LASER_INDEX)); gameData.multi.players [gameData.multi.nLocalPlayer].secondaryWeaponFlags = ~((1<<SMISSILE4_INDEX) | (1<<MEGA_INDEX) | (1<<SMISSILE5_INDEX)); } else { gameData.multi.players [gameData.multi.nLocalPlayer].primaryWeaponFlags = 0xffff ^ HAS_FLAG (SUPER_LASER_INDEX); //no super laser gameData.multi.players [gameData.multi.nLocalPlayer].secondaryWeaponFlags = 0xffff; } h = (gameData.multi.players [gameData.multi.nLocalPlayer].flags & PLAYER_FLAGS_AMMO_RACK) ? 2 : 1; for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].primaryAmmo [i] = nMaxPrimaryAmmo [i] * h; for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo[i] = nMaxSecondaryAmmo [i] * h; if (gameData.pig.tex.nHamFileVersion < 3) {// SHAREWARE gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [SMISSILE4_INDEX] = 0; gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [SMISSILE5_INDEX] = 0; gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [MEGA_INDEX] = 0; } if (gameData.app.nGameMode & GM_HOARD) gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [PROXIMITY_INDEX] = 12; else if (gameData.app.nGameMode & GM_ENTROPY) { gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [PROXIMITY_INDEX] = 5 * h; gameData.multi.players [gameData.multi.nLocalPlayer].secondaryAmmo [SMART_MINE_INDEX] = 5 * h; } } if (gameData.demo.nState == ND_STATE_RECORDING) NDRecordLaserLevel (gameData.multi.players [gameData.multi.nLocalPlayer].laserLevel, MAX_LASER_LEVEL); gameData.multi.players [gameData.multi.nLocalPlayer].energy = MAX_ENERGY; if (gameStates.app.bD1Mission) gameData.multi.players [gameData.multi.nLocalPlayer].laserLevel = MAX_LASER_LEVEL; else { gameData.multi.players [gameData.multi.nLocalPlayer].laserLevel = MAX_SUPER_LASER_LEVEL; gameData.multi.players [gameData.multi.nLocalPlayer].flags |= PLAYER_FLAGS_QUAD_LASERS; } UpdateLaserWeaponInfo(); SetLastSuperWeaponStates (); }
void dot_history_cleanup(hist_t *h) { if (HAS_FLAG(h->flags, BLACK)) { CLEAN_FLAG(h->flags, BLACK); pred_t *pred = h->pred, *last = h->pred + h->pred_n; while (pred < last) { dot_history_cleanup(pred->hist); ++pred; } } }
void print_dot_history_rec(FILE *stream, hist_t *h) { if (!HAS_FLAG(h->flags, BLACK) && h->e->num!=-1) { SET_FLAG(h->flags, BLACK); fprintf(stream, "%d (%s) ", h->e->num, h->e->origin->name); pred_t *pred = h->pred, *last = h->pred + h->pred_n; while (pred < last) { print_dot_history_rec(stream, pred->hist); ++pred; } } }
/* scopes process */ PROCESS_THREAD(scopes_process, ev, data) { PROCESS_BEGIN(); LOG_L("scopes process started\n"); /* create and start an event timer */ static struct etimer scopes_timer; etimer_set(&scopes_timer, SCOPES_TIMER_DURATION * CLOCK_SECOND); do { /* wait till the timer expires and then reset it immediately */ PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&scopes_timer)); etimer_reset(&scopes_timer); struct scope *s; /* check memberships of dynamic scopes */ // LOG_L("checking dynamic scope memberships\n"); for (s = list_head(scopes); s != NULL; s = s->next) { /* only check scopes not created by the local node */ if (HAS_FLAG(s, SCOPES_FLAG_DYNAMIC) && !HAS_STATUS(s, SCOPES_STATUS_CREATOR)) { /* check membership */ int should_be_member = membership->check(s->specs, s->spec_len); /* decide action */ if (should_be_member && !HAS_STATUS(s, SCOPES_STATUS_MEMBER)) { /* join scope */ join_scope(s); } else if (!should_be_member && HAS_STATUS(s, SCOPES_STATUS_MEMBER)) { /* leave scope */ leave_scope(s); } } } // /* print scopes information */ // LOG_L("known scopes:\n"); // LOG_L("-------------\n"); // for (s = list_head(scopes); s != NULL; s = s->next) { // print_scope(s); // } // LOG_L("-------------\n"); }while(1); PROCESS_END(); }
void CEdit::DoDragDrop() { int nStartCol, nStartRow, nEndCol, nEndRow; ASSERT( !m_Selection.IsEmpty() ); // Drag and drop does not currently support column selection. Convert // the column selection to a paragraph selection as a fallback. if ( m_Selection.IsColumnSel() ) { m_Selection.EnableColumnSel( FALSE ); DamageSelection( TRUE ); } m_Selection.GetNormalizedBufferSelection( nStartCol, nStartRow, nEndCol, nEndRow ); HGLOBAL hGlobal; if ( m_Buffer.GetText( nStartRow, nStartCol, nEndRow, nEndCol, hGlobal, FALSE ) ) { CDataObject DataObj( hGlobal ); CDropSource DropSource; VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) ( LPVOID ) &DataObj, TRUE, FALSE ) ) ); VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) &DropSource, TRUE, FALSE ) ) ); DWORD dwEffect; m_bDroppedHere = FALSE; if ( ::DoDragDrop( &DataObj, &DropSource, DROPEFFECT_COPY | ( m_Buffer.IsReadOnly() ? 0 : DROPEFFECT_MOVE ), &dwEffect ) == DRAGDROP_S_DROP ) { // text was dropped successfully -- The OnDrop() method of the drop target freed the memory // because CDataObject::GetData() set pUnkForRelease = NULL. // if moved text to another window, delete the selection here if ( !m_bDroppedHere && HAS_FLAG( dwEffect, DROPEFFECT_MOVE ) ) { DeleteSelection( FALSE, FALSE ); } } else { // cleanup clip data since target window didn't drop the text GlobalFree( hGlobal ); } VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) &DropSource, FALSE, TRUE ) ) ); VERIFY( SUCCEEDED( CoLockObjectExternal( ( LPUNKNOWN ) ( LPVOID ) &DataObj, FALSE, TRUE ) ) ); DataObj.Release(); } SetMode( eIdle ); }
STDMETHODIMP CDataObject::GetData( LPFORMATETC pFE, LPSTGMEDIUM pSTM ) { switch ( pFE->cfFormat ) { case CLIP_TEXT: { if ( !HAS_FLAG( pFE->tymed, TYMED_HGLOBAL ) ) { return DV_E_TYMED; } pSTM->tymed = TYMED_HGLOBAL; pSTM->hGlobal = m_hGlobal; pSTM->pUnkForRelease = NULL; return S_OK; } } return DATA_E_FORMATETC; }
static GdkFilterReturn xfce_accessibility_helper_event_filter (GdkXEvent *xevent, GdkEvent *gdk_event, gpointer user_data) { XkbEvent *event = xevent; XfceAccessibilityHelper *helper = XFCE_ACCESSIBILITY_HELPER (user_data); const gchar *body; switch (event->any.xkb_type) { case XkbControlsNotify: if (HAS_FLAG (event->ctrls.enabled_ctrl_changes, XkbStickyKeysMask)) { if (HAS_FLAG (event->ctrls.enabled_ctrls, XkbStickyKeysMask)) body = _("Sticky keys are enabled"); else body = _("Sticky keys are disabled"); xfce_accessibility_helper_notification_show (helper, _("Sticky keys"), body); } else if (HAS_FLAG (event->ctrls.enabled_ctrl_changes, XkbSlowKeysMask)) { if (HAS_FLAG (event->ctrls.enabled_ctrls, XkbSlowKeysMask)) body = _("Slow keys are enabled"); else body = _("Slow keys are disabled"); xfce_accessibility_helper_notification_show (helper, _("Slow keys"), body); } else if (HAS_FLAG (event->ctrls.enabled_ctrl_changes, XkbBounceKeysMask)) { if (HAS_FLAG (event->ctrls.enabled_ctrls, XkbBounceKeysMask)) body = _("Bounce keys are enabled"); else body = _("Bounce keys are disabled"); xfce_accessibility_helper_notification_show (helper, _("Bounce keys"), body); } break; default: break; } return GDK_FILTER_CONTINUE; }
DWORD CEdit::GetDropEffect( LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINTL pt, CEditView *&pView, int &nBuffCol, int &nRow ) { DWORD dwEffect = DROPEFFECT_NONE; if ( !m_Buffer.IsReadOnly() ) { POINT ptClient = { pt.x, pt.y }; ScreenToClient( m_hWnd, &ptClient ); int nView; if ( HitTest( ptClient.x, ptClient.y, nView ) == eEditSpace && !PtInSelection( ptClient.x, ptClient.y, FALSE ) ) { FORMATETC fe = { CLIP_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; if ( pIDataSource->QueryGetData( &fe ) == S_OK ) { RECT rcChar; pView = m_Views[ nView ]; pView->GetCharPosFromPoint( ptClient.x, ptClient.y, nBuffCol, nRow, &rcChar ); nBuffCol = m_Buffer.ConvertViewColToBufferCol( nRow, nBuffCol ); if ( !IsRectEmpty( &rcChar ) && ( ptClient.x > ( ( rcChar.left + rcChar.right ) / 2 ) ) ) { // cursor is closer to the next char nBuffCol += m_Buffer.GetCharSize( nRow, nBuffCol ); } dwEffect = ( HAS_FLAG( grfKeyState, MK_CONTROL ) ? DROPEFFECT_COPY : DROPEFFECT_MOVE ); if ( pView->ScrollIfNearBorder( ptClient.x, ptClient.y, TRUE ) ) { dwEffect |= DROPEFFECT_SCROLL; } // make sure the effect is allowed by the source object m_DropTarget.NormalizeDropEffect( dwEffect ); } } } return dwEffect; }
static void xfce_accessibility_helper_set_xkb (XfceAccessibilityHelper *helper, gulong mask) { XkbDescPtr xkb; gint delay, interval, time_to_max; gint max_speed, curve; gdk_error_trap_push (); /* allocate */ xkb = XkbAllocKeyboard (); if (G_LIKELY (xkb)) { /* we always change this, so add it to the mask */ SET_FLAG (mask, XkbControlsEnabledMask); /* if setting sticky keys, we set expiration too */ if (HAS_FLAG (mask, XkbStickyKeysMask) || HAS_FLAG (mask, XkbSlowKeysMask) || HAS_FLAG (mask, XkbBounceKeysMask) || HAS_FLAG (mask, XkbMouseKeysMask) || HAS_FLAG (mask, XkbAccessXKeysMask)) SET_FLAG (mask, XkbAccessXTimeoutMask); /* add the mouse keys values mask if needed */ if (HAS_FLAG (mask, XkbMouseKeysMask)) SET_FLAG (mask, XkbMouseKeysAccelMask); /* load the xkb controls into the structure */ XkbGetControls (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), mask, xkb); /* AccessXKeys */ if (HAS_FLAG (mask, XkbAccessXKeysMask)) { if (xfconf_channel_get_bool (helper->channel, "/AccessXKeys", FALSE)) { SET_FLAG (xkb->ctrls->enabled_ctrls, XkbAccessXKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbAccessXKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbAccessXKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "AccessXKeys enabled"); } else { UNSET_FLAG (xkb->ctrls->enabled_ctrls, XkbAccessXKeysMask); SET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbAccessXKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbAccessXKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "AccessXKeys disabled"); } } /* Sticky keys */ if (HAS_FLAG (mask, XkbStickyKeysMask)) { if (xfconf_channel_get_bool (helper->channel, "/StickyKeys", FALSE)) { SET_FLAG (xkb->ctrls->enabled_ctrls, XkbStickyKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbStickyKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbStickyKeysMask); if (xfconf_channel_get_bool (helper->channel, "/StickyKeys/LatchToLock", FALSE)) SET_FLAG (xkb->ctrls->ax_options, XkbAX_LatchToLockMask); else UNSET_FLAG (xkb->ctrls->ax_options, XkbAX_LatchToLockMask); if (xfconf_channel_get_bool (helper->channel, "/StickyKeys/TwoKeysDisable", FALSE)) SET_FLAG (xkb->ctrls->ax_options, XkbAX_TwoKeysMask); else UNSET_FLAG (xkb->ctrls->ax_options, XkbAX_TwoKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "stickykeys enabled (ax_options=%d)", xkb->ctrls->ax_options); } else { UNSET_FLAG (xkb->ctrls->enabled_ctrls, XkbStickyKeysMask); SET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbStickyKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbStickyKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "stickykeys disabled"); } } /* Slow keys */ if (HAS_FLAG (mask, XkbSlowKeysMask)) { if (xfconf_channel_get_bool (helper->channel, "/SlowKeys", FALSE)) { SET_FLAG (xkb->ctrls->enabled_ctrls, XkbSlowKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbSlowKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbSlowKeysMask); delay = xfconf_channel_get_int (helper->channel, "/SlowKeys/Delay", 100); xkb->ctrls->slow_keys_delay = CLAMP (delay, 1, G_MAXUSHORT); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "slowkeys enabled (delay=%d)", xkb->ctrls->slow_keys_delay); } else { UNSET_FLAG (xkb->ctrls->enabled_ctrls, XkbSlowKeysMask); SET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbSlowKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbSlowKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "slowkeys disabled"); } } /* Bounce keys */ if (HAS_FLAG (mask, XkbBounceKeysMask)) { if (xfconf_channel_get_bool (helper->channel, "/BounceKeys", FALSE)) { SET_FLAG (xkb->ctrls->enabled_ctrls, XkbBounceKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbBounceKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbBounceKeysMask); delay = xfconf_channel_get_int (helper->channel, "/BounceKeys/Delay", 100); xkb->ctrls->debounce_delay = CLAMP (delay, 1, G_MAXUSHORT); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "bouncekeys enabled (delay=%d)", xkb->ctrls->debounce_delay); } else { UNSET_FLAG (xkb->ctrls->enabled_ctrls, XkbBounceKeysMask); SET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbBounceKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbBounceKeysMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "bouncekeys disabled"); } } /* Mouse keys */ if (HAS_FLAG (mask, XkbMouseKeysMask)) { if (xfconf_channel_get_bool (helper->channel, "/MouseKeys", FALSE)) { SET_FLAG (xkb->ctrls->enabled_ctrls, XkbMouseKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbMouseKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbMouseKeysMask); /* get values */ delay = xfconf_channel_get_int (helper->channel, "/MouseKeys/Delay", 160); interval = xfconf_channel_get_int (helper->channel, "/MouseKeys/Interval", 20); time_to_max = xfconf_channel_get_int (helper->channel, "/MouseKeys/TimeToMax", 3000); max_speed = xfconf_channel_get_int (helper->channel, "/MouseKeys/MaxSpeed", 1000); curve = xfconf_channel_get_int (helper->channel, "/MouseKeys/Curve", 0); /* calculate maximum speed and to to reach it */ interval = CLAMP (interval, 1, G_MAXUSHORT); max_speed = (max_speed * interval) / 1000; time_to_max = (time_to_max + interval / 2) / interval; /* set new values, clamp to limits */ xkb->ctrls->mk_delay = CLAMP (delay, 1, G_MAXUSHORT); xkb->ctrls->mk_interval = interval; xkb->ctrls->mk_time_to_max = CLAMP (time_to_max, 1, G_MAXUSHORT); xkb->ctrls->mk_max_speed = CLAMP (max_speed, 1, G_MAXUSHORT); xkb->ctrls->mk_curve = CLAMP (curve, -1000, 1000); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "mousekeys enabled (delay=%d, interval=%d, " "time_to_max=%d, max_speed=%d, curve=%d)", xkb->ctrls->mk_delay, xkb->ctrls->mk_interval, xkb->ctrls->mk_time_to_max, xkb->ctrls->mk_max_speed, xkb->ctrls->mk_curve); } else { UNSET_FLAG (xkb->ctrls->enabled_ctrls, XkbMouseKeysMask); SET_FLAG (xkb->ctrls->axt_ctrls_mask, XkbMouseKeysMask); UNSET_FLAG (xkb->ctrls->axt_ctrls_values, XkbMouseKeysMask); UNSET_FLAG (mask, XkbMouseKeysAccelMask); xfsettings_dbg (XFSD_DEBUG_ACCESSIBILITY, "mousekeys disabled"); } } /* set the modified controls */ if (!XkbSetControls (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), mask, xkb)) g_message ("Setting the xkb controls failed"); /* free the structure */ XkbFreeControls (xkb, mask, True); XFree (xkb); } else { /* warning */ g_critical ("XkbAllocKeyboard() returned a null pointer"); } if (gdk_error_trap_pop () != 0) g_critical ("Failed to set keyboard controls"); }
void DropCurrentWeapon (void) { int nObject = -1, ammo = 0, seed; seed = d_rand (); if (gameData.weapons.nPrimary == 0) { //special laser drop handling if ((LOCALPLAYER.flags & PLAYER_FLAGS_QUAD_LASERS) && !IsBuiltInDevice (PLAYER_FLAGS_QUAD_LASERS)) { LOCALPLAYER.flags &= ~PLAYER_FLAGS_QUAD_LASERS; nObject = SpitPowerup (gameData.objs.consoleP, POW_QUADLASER, seed); if (nObject == -1) { LOCALPLAYER.flags |= PLAYER_FLAGS_QUAD_LASERS; return; } HUDInitMessage(TXT_DROP_QLASER); } else if ((LOCALPLAYER.laserLevel > MAX_LASER_LEVEL) && !IsBuiltInGun (SUPER_LASER_INDEX)) { LOCALPLAYER.laserLevel--; nObject = SpitPowerup (gameData.objs.consoleP, POW_SUPERLASER, seed); if (nObject == -1) { LOCALPLAYER.laserLevel++; return; } HUDInitMessage (TXT_DROP_SLASER); } } else { if ((gameData.weapons.nPrimary == 4) && gameData.weapons.bTripleFusion) gameData.weapons.bTripleFusion = 0; else if (gameData.weapons.nPrimary && !IsBuiltInGun (gameData.weapons.nPrimary)) {//if selected weapon was not the laser LOCALPLAYER.primaryWeaponFlags &= (~(1 << gameData.weapons.nPrimary)); nObject = SpitPowerup (gameData.objs.consoleP, primaryWeaponToPowerup [gameData.weapons.nPrimary], seed); } if (nObject == -1) { if (gameData.weapons.nPrimary) //if selected weapon was not the laser LOCALPLAYER.primaryWeaponFlags |= (1 << gameData.weapons.nPrimary); return; } HUDInitMessage (TXT_DROP_WEAPON, PRIMARY_WEAPON_NAMES (gameData.weapons.nPrimary)); } audio.PlaySound (SOUND_DROP_WEAPON); if ((gameData.weapons.nPrimary == VULCAN_INDEX) || (gameData.weapons.nPrimary == GAUSS_INDEX)) { //if it's one of these, drop some ammo with the weapon ammo = LOCALPLAYER.primaryAmmo [VULCAN_INDEX]; if ((LOCALPLAYER.primaryWeaponFlags & HAS_FLAG(VULCAN_INDEX)) && (gameData.weapons.nPrimary == GAUSS_INDEX)) ammo /= 2; //if both vulcan & gauss, drop half LOCALPLAYER.primaryAmmo [VULCAN_INDEX] -= ammo; if (nObject != -1) OBJECTS [nObject].cType.powerupInfo.nCount = ammo; } if (gameData.weapons.nPrimary == OMEGA_INDEX) { //dropped weapon has current energy if (nObject != -1) OBJECTS [nObject].cType.powerupInfo.nCount = gameData.omega.xCharge [IsMultiGame]; } if (IsMultiGame) { MultiSendDropWeapon (nObject, seed); MultiSendWeapons (1); } if (gameData.weapons.nPrimary) //if selected weapon was not the laser AutoSelectWeapon (0, 0); }
BOOL CUndoAction::IsEndAction() const { return HAS_FLAG( m_fFlags, BIT_END ); }
BOOL CUndoAction::IsInsertAction() const { return HAS_FLAG( m_fFlags, BIT_INSERT ); }
BOOL CUndoAction::IsStartAction() const { return HAS_FLAG( m_fFlags, BIT_START ); }
BOOL CUndoAction::CanAppend() const { return HAS_FLAG( m_fFlags, BIT_APPEND ); }
BOOL is_trailbyte( TCHAR ch ) { return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_TRAILBYTE ); }
BOOL CEdit::OnDrop( LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect ) { CEditView *pView; int nBuffCol, nRow; *pdwEffect = GetDropEffect( pIDataSource, grfKeyState, pt, pView, nBuffCol, nRow ); m_bDroppedHere = TRUE; BOOL bDropped = FALSE; if ( *pdwEffect != DROPEFFECT_NONE ) { FORMATETC fe = { CLIP_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgm; if ( !SUCCEEDED( pIDataSource->GetData( &fe, &stgm ) ) ) { // data could not be retrieved m_Selection.SetEmptySelection( nBuffCol, nRow ); m_Selection.ShowCaret(); return FALSE; } HGLOBAL hMem = stgm.hGlobal; ASSERT( hMem ); LPCTSTR pszText = ( LPCTSTR ) GlobalLock( hMem ); m_Buffer.BeginEdit( m_Selection.GetEndRow(), m_Selection.GetEndCol() ); if ( pszText && IsDragAndDropping() ) { // we are dragging and dropping from within this control -- be careful how // the *current* selection is handled POINT ptClient = { pt.x, pt.y }; ScreenToClient( m_hWnd, &ptClient ); if ( PtInSelection( ptClient.x, ptClient.y, FALSE ) ) { m_Selection.SetEmptySelection( nBuffCol, nRow ); } else { BOOL bMove = HAS_FLAG( *pdwEffect, DROPEFFECT_MOVE ); int nStartRow, nStartCol, nEndRow, nEndCol; m_Selection.GetNormalizedBufferSelection( nStartCol, nStartRow, nEndCol, nEndRow ); if (nRow == nStartRow && nBuffCol == nStartCol) { // nothing really to do -- the source and destination are identical. // We do however need to erase the drag insertion caret. DamageSelection(FALSE); } else if ( ( nRow < nStartRow ) || ( nRow == nStartRow && nBuffCol < nStartCol ) ) { // dragging before the selection -- delete the selection first (if move) if ( bMove ) DeleteSelection( FALSE, FALSE ); m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); } else { // dragging after the selection -- insert the new text first m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); int nStartRowNew, nStartColNew, nEndRowNew, nEndColNew; m_Selection.GetNormalizedBufferSelection( nStartColNew, nStartRowNew, nEndColNew, nEndRowNew ); if ( bMove ) { m_Selection.SetExtendedSelection( nStartCol, nStartRow, nEndCol, nEndRow ); DeleteSelection( FALSE, FALSE ); } // we want to select the dropped text, but we must first factor in the // shift caused by the text that was just deleted. if ( nStartRowNew == nEndRow ) { ASSERT( nStartColNew >= nEndCol ); if ( nStartRow == nEndRow ) nStartColNew -= nEndCol - nStartCol; else if ( nStartRowNew == nEndRow ) nStartColNew = nStartCol + nStartColNew - nEndCol; else nStartColNew -= nEndCol; } nStartRowNew -= nEndRow - nStartRow; if ( nEndRowNew == nEndRow ) { ASSERT( nEndColNew > nEndCol ); if ( nStartRow == nEndRow ) nEndColNew -= nEndCol - nStartCol; else nEndColNew -= nEndCol; } nEndRowNew -= nEndRow - nStartRow; // select the dropped text m_Selection.SetExtendedSelection( nStartColNew, nStartRowNew, nEndColNew, nEndRowNew ); } } } else { // data came from another window -- just insert it as usual -- the other window // will remove the text if a move m_Selection.SetEmptySelection( nBuffCol, nRow ); ReplaceSelection( pszText, FALSE, TRUE, TRUE ); } if ( m_pActiveView != pView ) { SetActiveView( pView ); } m_Buffer.EndEdit( m_Selection.GetEndRow(), m_Selection.GetEndCol() ); GlobalUnlock( hMem ); if ( !stgm.pUnkForRelease ) { // provider of data decided that we should release the data ReleaseStgMedium( &stgm ); } bDropped = TRUE; } m_Selection.ShowCaret(); return bDropped; }
void CEditView::DrawLine( int nLine, HDC hDC, int x, int y, int xDividerStart ) const { int nLineLen = m_pBuffer->GetLineLength( nLine ); BOOL bUseColor = ( m_pCtrl->UseColorSyntax() && ( nLineLen <= MAXCOL ) ); int nViewCol = m_nLeftIndex; int nBuffColStart = m_pBuffer->ConvertViewColToBufferCol( nLine, nViewCol, FALSE ); int xLeft = x; // highlight this line if appropriate BOOL bHighlight = m_pBuffer->IsHighlighted( nLine ); if ( bHighlight ) { // fill out the rest of the line with the highlight RECT rc = m_rcView; rc.left = x; rc.top = y; rc.bottom = y + m_cyLine; SetBkColor( hDC, m_pCtrl->GetHighlightedLineColor() ); ExtTextOut( hDC, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL ); } BOOL bMBCS = DBCS_ACTIVE; #ifdef _UNICODE int nRightIndex = m_nRightIndex; #else int nRightIndex = m_nRightIndex + bMBCS * 2; // always paint two more TCHARs so multibyte chars aren't truncated #endif if ( nBuffColStart < nLineLen ) // else nothing to draw { // wait for nLine to become available (in case of background syntax parsing) m_pBuffer->WaitForLine( nLine ); LPCTSTR pszLineStart = m_pBuffer->GetLineText( nLine ); register LPCTSTR psz = pszLineStart + nBuffColStart; LPCTSTR pszStart = psz; ////////////////////////////////////////////////////////////////////////// // Step 1: Expand tabs // BOOL bViewWhitespace = m_pCtrl->DisplayWhitespace(); TCHAR szLine[ 1000 ]; CharFill( szLine, _T(' '), ARRAY_SIZE( szLine ) ); int cbTab = m_pBuffer->GetTabSize(); LPTSTR pszBuff = szLine; TCHAR chTab, chSpace; if ( bMBCS ) { chTab = _T('^'); chSpace = _T('`'); } else { chTab = _T('»'); chSpace = _T('·'); } while ( *psz && ( nViewCol <= nRightIndex ) ) { if ( *psz == _T('\t') ) { int nSpaces = ( ( nViewCol / cbTab ) * cbTab ) + cbTab - nViewCol; if ( nSpaces ) { if ( bViewWhitespace ) { if ( psz != pszStart || m_nLeftIndex == m_pBuffer->ConvertBufferColToViewCol( nLine, nBuffColStart ) ) { *pszBuff = chTab; } } pszBuff += nSpaces; nViewCol += nSpaces; } } else { if ( bViewWhitespace && *psz == _T(' ') ) { *pszBuff++ = chSpace; } else { *pszBuff++ = *psz; } nViewCol++; } psz++; } ////////////////////////////////////////////////////////////////////////// // Step 2: Parse the line and assign colors to everything // DWORD clrLine[ 100 ]; // hiword = token, loword = token offset in szLine int nColors = 0; if ( bUseColor ) { psz = pszLineStart; int nParseLen = m_pBuffer->ConvertViewColToBufferCol( nLine, nRightIndex ) + 20; // +20 is a reasonable max token length nParseLen = min( nParseLen, nLineLen ); nViewCol = 0; int nBuffCol = 0; int nFirstColorViewCol = m_nLeftIndex; BOOL bColorIsVisible = nViewCol >= nFirstColorViewCol; CLineParser Parser( m_pBuffer, nLine, nParseLen ); // pick up where the last line left off -- in a multi-line comment block (or not) clrLine[ nColors++ ] = MAKELPARAM( 0, ( WORD ) ( Parser.m_bInComment ? CBuffer::eMultiLineCommentStart : ( Parser.m_bInString ? CBuffer::eStringDelim : ( Parser.m_bInTag ? CBuffer::eTagText : CBuffer::eText ) ) ) ); while ( Parser.MoreComing() ) { Parser.AcceptToken(); int nTokenStartCol = nViewCol; nBuffCol += Parser.m_nTokenLen; if ( Parser.m_bHasTab ) { ASSERT( Parser.m_eToken == CBuffer::eText || Parser.m_eToken == CBuffer::eTagText || Parser.m_eToken == CBuffer::eStringDelim || Parser.m_eToken == CBuffer::eSingleLineComment ); nViewCol = m_pBuffer->ConvertBufferColToViewCol( nLine, nBuffCol ); } else { nViewCol += Parser.m_nTokenLen; } if ( !bColorIsVisible ) { // Assume this token (unless in a comment) will be the first token to cross the left edge clrLine[ 0 ] = MAKELPARAM( 0, ( WORD )( Parser.m_bInComment ? CBuffer::eMultiLineCommentStart : ( Parser.m_bInString ? CBuffer::eStringDelim : Parser.m_eToken ) ) ); if ( nViewCol > nFirstColorViewCol ) { ////////////////////////// // token is now in view // bColorIsVisible = TRUE; nTokenStartCol = nFirstColorViewCol; } } // record the token position if ( nTokenStartCol > nRightIndex ) { break; } if ( bColorIsVisible && !Parser.m_bWasInComment && !Parser.m_bIsCommentEndToken && !Parser.m_bWasInString && !Parser.m_bIsStringEndToken ) { clrLine[ nColors++ ] = MAKELPARAM( nTokenStartCol - m_nLeftIndex, ( WORD ) Parser.m_eToken ); } clrLine[ nColors ] = MAKELPARAM( ( nViewCol > m_nLeftIndex ? nViewCol : nRightIndex ) - m_nLeftIndex, ( WORD ) Parser.m_eToken ); // don't blow past the local array and corrupt the stack! if ( nColors >= ARRAY_SIZE( clrLine ) - 1 ) { nColors = 0; goto no_color; } } } else { no_color: clrLine[ nColors++ ] = MAKELPARAM( 0, ( WORD ) CBuffer::eText ); // draw text only as far as is necessary. We don't want to paint extra characters that aren't // in the buffer. If underline font used on plain text, the underline will extend to the edge of the window. // we don't want that. int nViewColEnd = m_pBuffer->ConvertBufferColToViewCol( nLine, nLineLen ); nViewColEnd = min( nRightIndex, nViewColEnd ); nViewColEnd = max( m_nLeftIndex, nViewColEnd ); clrLine[ nColors ] = MAKELPARAM( nViewColEnd - m_nLeftIndex, ( WORD ) CBuffer::eText ); } ////////////////////////////////////////////////////////////////////////// // Step 3: Output the line // ASSERT( nColors ); BOOL bFirstToken = TRUE; for ( int i = 0; i < nColors; i++ ) { DWORD dwColorInfo = clrLine[ i ]; CBuffer::LangToken eToken = ( CBuffer::LangToken ) HIWORD( dwColorInfo ); SetTextColor( hDC, m_pCtrl->GetTokenColor( eToken, TRUE ) ); COLORREF crBk = bHighlight ? m_pCtrl->GetHighlightedLineColor() : m_pCtrl->GetTokenColor( eToken, FALSE ); if ( crBk != CLR_INVALID ) { SetBkColor( hDC, crBk ); SetBkMode( hDC, OPAQUE ); } else { SetBkMode( hDC, TRANSPARENT ); } long cxExtraSpacing, cyDescentShift; SelectObject( hDC, m_pCtrl->GetTokenFont( eToken, cxExtraSpacing, cyDescentShift, m_pCtrl->m_font ) ); SetTextCharacterExtra( hDC, cxExtraSpacing ); int nTokenStart = LOWORD( dwColorInfo ); int nTokenNext = LOWORD( clrLine[ i + 1 ] ); int cbToken = nTokenNext - nTokenStart; if ( cbToken ) { #ifndef _UNICODE // The first visible token on the left of the line might be cutoff right // in the middle of a multi-byte char. We need to account for this by not // rendering the character (just leave whitespace). if ( bFirstToken && _ismbstrail( ( const unsigned char * ) pszLineStart, ( const unsigned char * ) pszStart ) ) { // scan backwards to the lead byte LPCTSTR pszLead = pszStart; while ( _ismbstrail( ( const unsigned char * ) pszLineStart, ( const unsigned char * ) --pszLead ) ) ; int cbChar = pszStart - pszLead; nTokenStart += cbChar; cbToken -= cbChar; x += ( cbChar * m_cxChar ); } #endif bFirstToken = FALSE; ExtTextOut( hDC, x, y - cyDescentShift, 0, NULL, szLine + nTokenStart, cbToken, NULL ); x += ( cbToken * m_cxChar ); } // don't worry about deselecting the font -- it will be cleaned up by any // calling method (as an optimization) } } ////////////////////////////////////////////////////////////////////////// // Step 4: give the parent window a crack at painting, too. // DWORD dwStyle = m_pBuffer->GetLineStyle( nLine ); if ( HAS_FLAG( dwStyle, CML_OWNERDRAW ) ) { CM_DRAWLINEDATA dld; dld.hDC = hDC; dld.rcLine.left = xLeft; dld.rcLine.top = y; dld.rcLine.right = m_rcView.right; dld.rcLine.bottom = y + m_cyLine; dld.nLine = nLine; dld.nLeftCol = m_nLeftIndex; dld.nRightCol = m_nRightIndex; dld.lParam = m_pBuffer->GetItemData( nLine ); dld.dwStyle = dwStyle; m_pCtrl->NotifyParent( CMN_DRAWLINE, ( NMHDR * ) &dld ); } // Draw divider line underneath the line if appropriate if ( m_pBuffer->HasDivider( nLine ) ) { COLORREF crDividerLine = m_pCtrl->GetHDividerLineColor(); COLORREF crWindow = m_pCtrl->GetWindowColor( TRUE ); // if line will blend in with the background, make it visible (opposite of window color). if ( crDividerLine == CLR_INVALID || crDividerLine == crWindow ) crDividerLine = ( ~crWindow & 0x00ffffff ); HPEN hPen = CreatePen( PS_SOLID, CY_DIVIDERLINE, crDividerLine ); HPEN hPenOld = ( HPEN ) SelectObject( hDC, hPen ); int yLine = y + m_cyLine - 1; MoveToEx( hDC, xDividerStart, yLine, NULL ); LineTo( hDC, m_rcView.right, yLine ); SelectObject( hDC, hPenOld ); DeleteObject( hPen ); } }
queue_err_t queue_open(void *p, const char *name, int flags) { int id; FILE *fp; key_t key; mode_t oldmask; systemv_queue_t *q; struct msqid_ds buf; char *s, filename[MAXPATHLEN]; q = (systemv_queue_t *) p; if (HAS_FLAG(flags, QUEUE_FL_OWNER)) { if (NULL == (s = strchr(name, ':')) || '\0' == *s) { id = 'b'; if (strlcpy(filename, name, STR_SIZE(filename)) >= STR_SIZE(filename)) { errno = E2BIG; return QUEUE_ERR_GENERAL_FAILURE; } } else { id = s[1]; if (s - name >= STR_SIZE(filename)) { errno = E2BIG; return QUEUE_ERR_GENERAL_FAILURE; } strncpy(filename, name, s - name); } if (NULL == (fp = fopen(filename, "wx"))) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } if (1 != fwrite(&id, sizeof(id), 1, fp)) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } fflush(fp); } else { if (strlcpy(filename, name, STR_SIZE(filename)) >= STR_SIZE(filename)) { errno = E2BIG; return QUEUE_ERR_GENERAL_FAILURE; } if (NULL == (fp = fopen(filename, "r"))) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } if (1 != fread(&id, sizeof(id), 1, fp) < sizeof(id)) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } } fclose(fp); if (-1 == (key = ftok(filename, id))) { // NOTE: errno is not set by ftok // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } if (HAS_FLAG(flags, QUEUE_FL_OWNER)) { if (NULL == (q->filename = strdup(filename))) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } oldmask = umask(0); q->qid = msgget(key, 0660 | IPC_CREAT | IPC_EXCL); umask(oldmask); } else { q->qid = msgget(key, 0660); } if (-1 == q->qid) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } if (!HAS_FLAG(flags, QUEUE_FL_SENDER)) { #if 0 https://svnweb.freebsd.org/base/head/sys/kern/sysv_msg.c?revision=282213&view=markup #define IPCID_TO_IX(id) ((id) & 0xffff) #define IPCID_TO_SEQ(id) (((id) >> 16) & 0xffff) #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff)) #endif CAP_RIGHTS_LIMIT(q->qid, CAP_READ); #if 0 } else { CAP_RIGHTS_LIMIT(q->qid, CAP_WRITE); #endif } if (0 != msgctl(q->qid, IPC_STAT, &buf)) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } q->buffer_size = buf.msg_qbytes / 8; if (NULL == (q->buffer = malloc(sizeof(long) + sizeof(q->buffer) * q->buffer_size))) { // TODO: error debug(""); return QUEUE_ERR_GENERAL_FAILURE; } *(long *) q->buffer = 1; /* mtype is an integer greater than 0 */ return QUEUE_ERR_OK; }
BOOL is_leadbyte( TCHAR ch ) { return HAS_FLAG( CEdit::g_CharFlags[ ( BYTE ) ch ], CEdit::CHARFLAG_LEADBYTE ); }