Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Documentation
Record presenting a frontend's interface.
The functions layout
and refresh
are both run by the editor's main loop,
in response to user actions and so on. Their relation is a little subtle, and
is discussed here:
- to see some code, look at the function
refreshEditor
in Yi.Core. This is the only place wherelayout
andrefresh
are used. - the function
layout
is responsible for updating theEditor
with the width and height of the windows. Some frontends, such as Pango, need to modify their internal state to do this, and will consequently change their display. This is expected. - the function
refresh
should cause the UI to update its display with the information given in theEditor
. the functionalities of
layout
andrefresh
overlap to some extent, in the sense that both may cause the frontend to update its display. The Yi core provides the following guarantees which the frontend may take advantage of:- in the main editor loop (i.e. in the
refreshEditor
function),layout
will be run (possibly multiple times) and thenrefresh
will be run. This guarantee will hold even in the case of threading (the functionrefreshEditor
will always be run atomically, usingMVar
s). - between the last run of
layout
and the run ofrefresh
, some changes may be made to theEditor
. However, the text, text attributes, and (displayed) window region of all windows will remain the same. However, the cursor location may change.
This guarantee allows frontends which calculate rendering of the text during the
layout
stage to avoid recalculating the render again duringrefresh
. Pango is an example of such a frontend.- in the main editor loop (i.e. in the
The Yi core provides no guarantee about the OS thread from which the functions
layout
and refresh
are called from. In particular, subprocesses (e.g. compilation,
ghci) will run layout
and refresh
from new OS threads (see startSubprocessWatchers
in Yi.Core). The frontend must be preparaed for this: for instance, Gtk-based frontends
should wrap GUI updates in postGUIAsync
.
UI | |
|