From 3041b08ae075b8a9c7fc77b0e5f5280e2eac7370 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Wed, 7 Oct 2020 13:04:17 -0500 Subject: [PATCH] isMobileDevice shrinks gutters --- src/ide/ui.ts | 2 +- src/ide/views.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ide/ui.ts b/src/ide/ui.ts index cdab5c53..18373d5e 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -2074,7 +2074,7 @@ function revealTopBar() { export function setupSplits() { const splitName = 'workspace-split3-' + platform_id; var sizes = [0, 50, 50]; - if (!platform_id.startsWith('vcs') && !qs['embed']) + if (!(platform_id.startsWith('vcs') || qs['embed'] || Views.isMobileDevice)) sizes = [12, 44, 44]; var sizesStr = hasLocalStorage && localStorage.getItem(splitName); if (sizesStr) { diff --git a/src/ide/views.ts b/src/ide/views.ts index fef939a8..357706b3 100644 --- a/src/ide/views.ts +++ b/src/ide/views.ts @@ -1,12 +1,12 @@ //import CodeMirror = require("codemirror"); import { SourceFile, WorkerError, Segment, FileData, SourceLocation, SourceLine } from "../common/workertypes"; -import { Platform, EmuState, lookupSymbol, BaseDebugPlatform, BaseZ80MachinePlatform, BaseZ80Platform, CpuState } from "../common/baseplatform"; +import { BaseZ80MachinePlatform, BaseZ80Platform } from "../common/baseplatform"; import { hex, lpad, rpad, safeident, rgb2bgr } from "../common/util"; import { CodeAnalyzer } from "../common/analysis"; import { platform, platform_id, compparams, current_project, lastDebugState, projectWindows, runToPC } from "./ui"; import { ProbeRecorder, ProbeFlags } from "../common/recorder"; -import { getMousePos, dumpRAM, Toolbar } from "../common/emu"; +import { getMousePos, dumpRAM } from "../common/emu"; import * as pixed from "./pixeleditor"; declare var Mousetrap; @@ -29,6 +29,9 @@ export interface ProjectView { undoStep?() : void; }; +// detect mobile (https://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device) +export var isMobileDevice = window.matchMedia("only screen and (max-width: 760px)").matches; + declare var CodeMirror; declare var VirtualList; @@ -115,10 +118,10 @@ export class SourceEditor implements ProjectView { var isAsm = isAsmOverride || modedef.isAsm; var lineWrap = !!modedef.lineWrap; var theme = modedef.theme || MODEDEFS.default.theme; - var lineNums = !modedef.noLineNumbers; + var lineNums = !modedef.noLineNumbers && !isMobileDevice; var gutters = ["CodeMirror-linenumbers", "gutter-offset", "gutter-info"]; if (isAsm) gutters = ["CodeMirror-linenumbers", "gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"]; - if (modedef.noGutters) gutters = ["gutter-info"]; + if (modedef.noGutters || isMobileDevice) gutters = ["gutter-info"]; this.editor = CodeMirror(parent, { theme: theme, lineNumbers: lineNums,