From cdd372314b08597539fc410192e0dcf43734fb17 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 12 Apr 2009 23:01:08 -0500 Subject: [PATCH] Working on error list change notification --- .../tools/error-list/error-list-docs.factor | 4 +-- basis/ui/tools/error-list/error-list.factor | 27 +++++++++---------- core/source-files/errors/errors.factor | 16 +++++++++-- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/basis/ui/tools/error-list/error-list-docs.factor b/basis/ui/tools/error-list/error-list-docs.factor index e4d15a0ea9..514812ed48 100644 --- a/basis/ui/tools/error-list/error-list-docs.factor +++ b/basis/ui/tools/error-list/error-list-docs.factor @@ -1,8 +1,8 @@ IN: ui.tools.error-list -USING: help.markup help.syntax ; +USING: help.markup help.syntax ui.tools.common ui.commands ; ARTICLE: "ui.tools.error-list" "UI error list tool" -"The error list tool displays messages generated by tools which process source files and definitions." +"The error list tool displays messages generated by tools which process source files and definitions. To display the error list, press " { $command tool "common" show-error-list } " in any UI tool window." $nl "The " { $vocab-link "source-files.errors" } " vocabulary contains backend code used by this tool." { $heading "Message icons" } diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor index 019538d31c..ceb5ff0921 100644 --- a/basis/ui/tools/error-list/error-list.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -4,14 +4,14 @@ USING: accessors arrays sequences sorting assocs colors.constants fry combinators combinators.smart combinators.short-circuit editors make memoize compiler.units fonts kernel io.pathnames prettyprint source-files.errors math.parser init math.order models models.arrow -models.arrow.smart models.search models.mapping debugger namespaces +models.arrow.smart models.search models.mapping models.delay debugger namespaces summary locals ui ui.commands ui.gadgets ui.gadgets.panes ui.gadgets.tables ui.gadgets.labeled ui.gadgets.tracks ui.gestures ui.operations ui.tools.browser ui.tools.common ui.gadgets.scrollers ui.tools.inspector ui.gadgets.status-bar ui.operations ui.gadgets.buttons ui.gadgets.borders ui.gadgets.packs ui.gadgets.labels ui.baseline-alignment ui.images -compiler.errors ; +compiler.errors calendar ; IN: ui.tools.error-list CONSTANT: source-file-icon @@ -173,26 +173,23 @@ error-list-gadget "toolbar" f { { T{ key-down f f "F1" } error-list-help } } define-command-map -SYMBOL: compiler-error-model +SYMBOL: error-list-model -compiler-error-model [ f ] initialize +error-list-model [ f ] initialize SINGLETON: updater -M: updater definitions-changed - 2drop - all-errors - compiler-error-model get-global - set-model ; +M: updater errors-changed + drop f error-list-model get-global set-model ; -[ - updater remove-definition-observer - updater add-definition-observer -] "ui.tools.error-list" add-init-hook +[ updater add-error-observer ] "ui.tools.error-list" add-init-hook + +: ( -- model ) + error-list-model get-global + 1/2 seconds [ drop all-errors ] ; : error-list-window ( -- ) - compiler-error-model get-global - "Errors" open-status-window ; + "Errors" open-status-window ; : show-error-list ( -- ) [ error-list-gadget? ] find-window diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index 385ca7a496..880472bc0a 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs kernel math.order sorting sequences definitions -namespaces arrays splitting io math.parser math ; +namespaces arrays splitting io math.parser math init ; IN: source-files.errors TUPLE: source-file-error error asset file line# ; @@ -55,4 +55,16 @@ error-types [ V{ } clone ] initialize : all-errors ( -- errors ) error-types get values [ quot>> call( -- seq ) ] map - concat ; \ No newline at end of file + concat ; + +GENERIC: errors-changed ( observer -- ) + +SYMBOL: error-observers + +[ V{ } clone error-observers set-global ] "source-files.errors" add-init-hook + +: add-error-observer ( observer -- ) error-observers get push ; + +: remove-error-observer ( observer -- ) error-observers get delq ; + +: notify-error-observers ( -- ) error-observers get [ errors-changed ] each ; \ No newline at end of file