Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpchen committed Feb 5, 2025
1 parent 8c639c2 commit 79a6711
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
5 changes: 2 additions & 3 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ const vitepressConfig = defineConfig({
markdown: {
lineNumbers: true,
theme: {
// light: await themeService.getTheme('Eva Light'),
light: await themeService.getTheme('Eva Light'),
// dark: await themeService.getTheme('Eva Dark'),
light: 'light-plus',
dark: 'dark-plus',
dark: await themeService.getTheme('JetBrains Rider Dark Theme'),
},
codeTransformers: [transformerTwoslash()],
},
Expand Down
15 changes: 12 additions & 3 deletions docs/document/Modern CSharp/docs/Understanding Bit Operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Console.WriteLine($"{nameof(after),6}: {after:B}");
- bitwise AND `&`: returns `1` for each bit as long as all of the two is `1`, else `0`
- bitwise XOR `^`: returns `1` if the two bits are different, `0` when identical


## Bitwise on Enum

Enum can be flags when the type is marked with `FlagsAttribute` and ordinary enum members are powers of 2(members represent the `All` or `None` are exceptional)
Expand Down Expand Up @@ -131,7 +130,7 @@ enum Foo
Bit mask is a common pattern that works like a filter to include or exclude or test bits.
The mask can refer to a integer represented as binary, a sequence of integers or a matrix of integers. The classical usage is a singular number.

### Is Bit Set
## Bit Checking

A common usage of mask is checking whether certain bit **is set**

Expand All @@ -152,8 +151,10 @@ int mask = 1 << position; // generate a special number 0100
bool positionIsSet = (number & mask) != 0;
```

This is the particular same case as how we tell whether a union of enum contains a enum flag.
This is the particularly similar as how we tell whether a union of enum contains a enum flag.

Since each enum member has **only one bit set**, the union in the following example has two bits set, only when the set bit from the flag being checked overlaps with any bit of the union can it evaluate to non-zero.

And in fact the operation `(union & flag)` should be equal to the flag itself.

> [!WARNING]
Expand All @@ -177,3 +178,11 @@ enum Foo
All = ~(~0 << 4)
}
```

## Set & Unset & Toggle

Similar to checking a bit, setting and unsetting require a same mask but different operation.

- set a bit: `number | (1 << position)`
- unset a bit: `number & ~(1 << position)`
- toggle a bit: `number ^ (1 << position)`
7 changes: 6 additions & 1 deletion docs/services/ThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const themeInfos = {
path: 'VSCode/themes/Eva-Dark.json',
branch: 'master',
},
'JetBrains Rider Dark Theme': {
repo: 'edsulaiman/jetbrains-rider-dark-theme',
path: 'themes/JetBrains Rider Dark Theme-color-theme.json',
branch: 'main',
},
} satisfies Record<string, RemoteThemeInfo>;

export type ThemeName = keyof typeof themeInfos;
Expand All @@ -44,7 +49,7 @@ class ThemeService implements IThemeService {
const foo = theme.tokenColors.filter(x => x.scope.startsWith('comment'))[0];
foo.settings.fontStyle = '';
}
this.innerThemeService.loadTheme(theme);
await this.innerThemeService.loadTheme(theme);
}
async getTheme(name: ThemeName): Promise<shiki.ThemeRegistration> {
if (!this.isThemeRegistered(name)) throw new Error(`Theme \`${name}\` not registered.`);
Expand Down

0 comments on commit 79a6711

Please sign in to comment.