正在加载图片...
$21.2 FINDING THE ABSTRACTIONS 701 The basic interactive step To get started we will see how to support one-level undo.The generalization to multi-level undo-redo will come next. In any interactive system,there must be somewhere,in a module in charge of the communication with users,a passage of the form basic interactive step is --Decode and execute one user request. do "Find out what the user wants us to do next" “Doit(if possible)” end In a traditionally structured system,such as editor,these operations will be executed as part of a loop,the program's"basic loop": from start until quit has been requested and confirmed loop basic interactive step end whereas more sophisticated systems may use an event-driven scheme,in which the loop is external to the system proper (being managed by the underlying graphical environment).But in all cases there is a need for something like basic interactive step. In light of the abstractions just identified,we can reformulate the body of the procedure as "Get latest user request" "Decode request" if "Request is a normal command (not Undo)"then "Determine the corresponding command in our system" "Execute that command" elseif“Request is Undo”then if“There is a command to be undone”then Undo last command'” elseif"There is a command to be redone"then “Redo last command'" end else "Report erroneous request" end§21.2 FINDING THE ABSTRACTIONS 701 The basic interactive step To get started we will see how to support one-level undo. The generalization to multi-level undo-redo will come next. In any interactive system, there must be somewhere, in a module in charge of the communication with users, a passage of the form basic_interactive_step is -- Decode and execute one user request. do “Find out what the user wants us to do next” “Do it (if possible)” end In a traditionally structured system, such as editor, these operations will be executed as part of a loop, the program’s “basic loop”: from start until quit_has_been_requested_and_confirmed loop basic_interactive_step end whereas more sophisticated systems may use an event-driven scheme, in which the loop is external to the system proper (being managed by the underlying graphical environment). But in all cases there is a need for something like basic_interactive_step. In light of the abstractions just identified, we can reformulate the body of the procedure as “Get latest user request” “Decode request” if “Request is a normal command (not Undo)” then “Determine the corresponding command in our system” “Execute that command” elseif “Request is Undo” then if “There is a command to be undone” then “Undo last command” elseif “There is a command to be redone” then “Redo last command” end else “Report erroneous request” end
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有