Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fontsize dropdownlist #552

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<div class="inline-block"
style="display: flex; background-color:whitesmoke; justify-content: space-between;margin:auto;">
<span style="flex:1 1 auto;"></span>
<div class="form-group mt-2" matTooltip="Choose font size" style="max-height: 20px; box-shadow: whitesmoke;">
<select id="fontSizeSelector" class="form-control form-control-sm" [(ngModel)]="editorFontSize" (change)="updateFontSize()">
<option *ngFor="let size of fontSizes" [value]="size">{{ size }}</option>
</select>
</div>
<button class="btn btn-light btn-sm mb-1 mt-2 mr-1 " matTooltip="Increase font size" style="font-size: 16px; max-height:30px;background: transparent;"
(click)="IncreaseFont()"><i>A+</i></button>
<button class="btn btn-light btn-sm mb-1 mt-2 mr-1 " matTooltip="Decrease font size" style="font-size: 16px; max-height:30px;background: transparent;"
Expand Down
37 changes: 23 additions & 14 deletions ArduinoFrontend/src/app/code-editor/code-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class CodeEditorComponent {
/**
* Monaco code editor options
*/
size = 15;
editorFontSize = 16; // Default font size
editorOptions = {
theme: 'vs',
language: 'c',
fontSize: 15
fontSize: this.editorFontSize
};
/**
* Instance of Monaco editor
Expand Down Expand Up @@ -146,19 +146,28 @@ export class CodeEditorComponent {
}
}
}
/**
* Increase the size of the font in the editor
*/
IncreaseFont(fontSize: number) {
this.size = this.size + 1;
this.editorOptions = {...this.editorOptions, fontSize: this.size};
fontSizes = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28]; // Font size options for the dropdown
// Update font size in editor options
updateFontSize(): void {
this.editorOptions = { ...this.editorOptions, fontSize: this.editorFontSize };
// If the editor instance exists, update its options directly
if (this.editor) {
this.editor.updateOptions({ fontSize: this.editorFontSize });
}
}
/**
* Decrease the size of the font in the editor
*/
DecreaseFont(fontSize: number) {
this.size = this.size - 1;
this.editorOptions = {...this.editorOptions, fontSize: this.size};
// Increase font size and sync with editor
IncreaseFont(): void {
if (this.editorFontSize < Math.max(...this.fontSizes)) {
this.editorFontSize += 2;
this.updateFontSize();
}
}
// Decrease font size and sync with editor
DecreaseFont(): void {
if (this.editorFontSize > Math.min(...this.fontSizes)) {
this.editorFontSize -= 2;
this.updateFontSize();
}
}
/**
* Download the code from code editor
Expand Down