ä¸è¶³æ°å³ã§ããã®ã§ããã¾ã«ã¯C#åãè£å ãã¦ããã¾ãã âããâ ããï¼å¹´è¿ãåã«ãªããã§ããã以åãä¸è¨ã®ã¨ã³ããªã注ç®ãæµ´ã³ã¦ãã¦ã ãããã楽ããèªã¾ãã¦ãããã¾ããã Undo,Redoã®å®è£ ã£ã¦ä½ååããã£ã¦ãæ°ããã - ãããã¨æ¥è¨ http://d.hatena.ne.jp/Youchan/20081110/1226282911 Undo,Redoã®å®è£ ã¤ã¥ã - ãããã¨æ¥è¨ http://d.hatena.ne.jp/Youchan/20081111/1226388917 ä¹ ã ã«Undo,Redoãå®è£ ããæ©ä¼ããã£ãã®ã§ããã£ãããªã®ã§ãã©è£ã«æ®ãã¦ããã¾ãã ããããGoFãã¶ã¤ã³ãã¿ã¼ã³ã§ããã¨ããã®Commandãã¿ã¼ã³ã¨Mementoãã¿ã¼ã³ã®å¿ç¨ã§ãã ããã¦ã¸ã§ããªãã¯å¯¾å¿ãããã¨ã§ãUndo,Redoã®å®è£ ãããç¨åº¦æ½è±¡åãããã¨ãã§ãã¾ãã ä»åã¯ãã®
undo,redoã®å®è£ ã£ã¦ä½ååããã£ã¦ãæ°ããããæ¯ååããã¿ã¼ã³ã ãundo,redoãç»å ´ãããããªç·¨éã½ããã¯å¤§ä½åããã¿ã¼ã³ã«è½ã¨ããããã¬ã¼ã ã¯ã¼ã¯ãä½ã£ããããã°ã«ããããå 容ãæ¸ããããé¢åããããéè¦ãããã°é¢åã§ãæ¸ããã ãã©ãªã http://twitter.com/youpychan/status/994486992 ã¨ããçºè¨ããããä½äººãåå¿ãé ããã®ã§æ¸ãã¦ã¿ããã¨ã«ããã éè¦ããããªãæ¸ãããundo,redoã ããããªãã¦ã°ã©ãã£ã«ã«ãªç·¨éã½ããå ¨è¬ã®è©±ããã¤ãã¾ã¨ãããã¨æã£ã¦ããã®ã§ãã¡ããã¨ã·ãªã¼ãºã§æ¸ãã¦ã¿ãããã¨ããã http://twitter.com/youpychan/status/994636764 æ¸ããã¨æãã ã¾ãUndo,Redoã«ã¤ãã¦ã Unod,Redoã£ã¦ã¿ãªããã©ããã風ã«å®è£ ãã¦ããã§ããããï¼ ç§ã¯ã³ãã³ããã¿
ãããæªãåå¿ã§ã¯ç¡ãã®ã§ãããåã¶ã¹ããã¨ãªãã ãã©ãæå¤ã¨å¥½è©ãªã¨ã³ããªã¼ãªã®ã§ç¶ããæ¸ãã¾ãã ã¿ã¤ãã«ã ãã¯åååæ§é£ãã£ã½ãã¿ã¤ãã«ã§ï¼¾ï¼¾ ååã®ã¨ã³ããªã¼ãæã£ãããåé¿ã大ããã¦ã³ã£ãããã¦ã¾ãããªããçä¸ãã¦ãã®ãï¼ã£ã¦æã£ã¡ããã¾ããï½ çä¸ã£ã¦ããã®ã¯ãããã«ãã¬ãã£ãã ããå 容ã¨ããé¢ãããã¦ãã®ã§ã¿ã¤ãã«å¤ãã¾ããã ãã¦ååã¯ã³ãã³ããã¿ã¼ã³ã¨ã³ãã³ãã®å®è£ ã«ã¤ãã¦æ¸ãã¾ããããä»åã¯äºåã©ããå®è¡é¨ã®å®è£ ã«ã¤ãã¦ã§ãã ã¨ãã£ã¦ããä»åã¯ã¨ã£ã¦ãåç´ãªè©±ã§ããUndoç¨ã«ã¹ã¿ãã¯ã«ã³ãã³ããç©ãã§ãUndoãããã£ã¦å¼ã°ããããã¹ã¿ãã¯ããã³ãã³ããpopãã¦ãã¦undoã®å¦çãå®è¡ããã ãã§ãã ãã ããRedoãåºæ¥ãªãã¨è¡ããªãã®ã§ãå®è¡ããã³ãã³ãã¯ä»åº¦ã¯Redoç¨ã®ã¹ã¿ãã¯ã«ç©ãã§ããã¾ãã å®è£ ã¯æ¬¡ã®ããã«ãªãã¾ãã ã¾ãååã®äºçªç®ã®ãã¿ã¼ã³ã«åã£
常ã«è¡ãããæä½ã¨ãã®æä½ãå ã«æ»ãããã®æä½ãã»ããã«ãã¦å±¥æ´ãä¿æãããã¨ã§ã è¡ã£ãæä½ãå ã«æ»ãæ©è½ãå ã«æ»ããæä½ãããç´ãæ©è½ãæä¾ããã¯ã©ã¹ã using System; using System.Collections.Generic; /// <summary> /// å®è¡ãå ã«æ»ã(undo)ãããç´ã(redo)ã®ååä½ãå®ç¾©ããã¤ã³ã¿ã¼ãã§ã¼ã¹ /// </summary> public interface ICommand { /// <summary> /// æä½ãå®è¡ããã¡ã½ãã /// </summary> void Do(); /// <summary> /// æä½ãå ã«æ»ãã¡ã½ãã /// </summary> void Undo(); /// <summary> /// æä½ãããç´ãã¡ã½ãã /// </summary> void Redo()
ä¾ãã°ç§»åãããã£ã¬ã¯ããªãè¨é²ãã¦ããã¨ãã«ãå±¥æ´ã«æ®ã£ã¦ãããã£ã¬ã¯ããªãéä¸ã§åé¤ããã¦ãã¾ã£ãå ´åã«ã¯ããã®ãã£ã¬ã¯ããªã¸ç§»åã§ããªãããã«ãããããã®ãã£ã¬ã¯ããªã表ãé ç®ãæ·¡è²è¡¨ç¤ºããããã¨ãããããªãã¨ãããã§ããã ããã§ãç»é²ããã¦ããã³ãã³ããéä¸ã§ç¡å¹ã«ãªã£ã¦ãã¾ã£ããããªå ´åã«ã¯ããã®ã³ãã³ããç¡è¦ãããã¨ãã§ããããã«ãã¦ã¿ã¾ããã Undo ã³ãã³ãã®åºåºã¯ã©ã¹ã®å®è£ #define UNDOREDO_DETACHED 0 #define UNDOREDO_ATTACHED 1 #define UNDOREDO_UNDO 2 #define UNDOREDO_REDO 3 #define UNDOREDO_UNDO_BEGIN 4 #define UNDOREDO_UNDO_END 5 #define UNDOREDO_REDO_BEGIN 6 #define
Undo/Redoã®å±¥æ´ã表示ãããã¨ããªã©ãããã¾ã ãã®ãããªã¨ãã³ãã³ãã®ã°ã«ã¼ãã«ååãä»ãã¦ããã¨ä¾¿å©ã§ã ã³ãã³ããã§ã¤ã³ã«ååãä»ããããããã«ãã¦ã¿ã¾ããã Undo ã³ãã³ã管çã¯ã©ã¹ã®å®è£ #define INVALID_COMMAND_ID (( uint32_t )-1) #define INVALID_CHAIN_ID (( uint32_t )-1) #define MAXIMUM_CHAIN_LEVEL (( uint32_t )-1) class cundoredoitem { uint32_t m_chain_id; uint32_t m_chain_level; uint32_t m_id; IRestoreObj* m_pRestoreObj; bool dispatch( uint32_t uMsg ); public: void detach();
ã³ãã³ãã®ã°ã«ã¼ãåã«å¯¾å¿ã§ããããã«ãªãã¾ããããéä¸ã§ã¨ã©ã¼ãçºçããã¨ããªã©ã«ããã£ã³ã»ã«ããã¨ãããã¨ãã§ãã¾ããã§ãã ã³ãã³ããã§ã¤ã³ãéä¸ã§ãã£ã³ã»ã«ã§ããããã«ãã¦ã¿ã¾ããã Undo ã³ãã³ã管çã¯ã©ã¹ã®å®è£ #define INVALID_COMMAND_ID (( uint32_t )-1) #define INVALID_CHAIN_ID (( uint32_t )-1) #define MAXIMUM_CHAIN_LEVEL (( uint32_t )-1) class cundoredoitem { uint32_t m_chain_id; uint32_t m_chain_level; uint32_t m_id; IRestoreObj* m_pRestoreObj; bool dispatch( uint32_t uMsg ); public: void
ä¸åº¦ã®æä½ã§è¤æ°ã®ã³ãã³ããä¸æ¬ã㦠Undo/Redo ãããã¨ããã¨ããããã¾ãããååã®ã³ã¼ãã§ã¯å¯¾å¿ãã¦ãã¾ããã§ãã ã³ãã³ãã®ã°ã«ã¼ãåãã³ãã³ããã§ã¤ã³ã«å¯¾å¿ãã¾ããã Undo ã³ãã³ã管çã¯ã©ã¹ã®å®è£ #define INVALID_COMMAND_ID (( uint32_t )-1) #define INVALID_CHAIN_ID (( uint32_t )-1) #define MAXIMUM_CHAIN_LEVEL (( uint32_t )-1) class cundoredoitem { uint32_t m_chain_id; uint32_t m_id; IRestoreObj* m_pRestoreObj; bool dispatch( uint32_t uMsg ); public: void detach(); bool attach( uint3
Undo/Redo ã®éãã³ãã³ããã§ã¤ã³ã®æåã¨æå¾ã®ã¿ã¤ãã³ã°ããããã¨ä¾¿å©ãªã¨ããããã¾ã ã³ãã³ããã§ã¤ã³ãå®è¡ããã¨ãã«ãæåã¨æå¾ã®ã¿ã¤ãã³ã°ãéç¥ããããã«ãã¦ã¿ã¾ããã Undo ã³ãã³ãã®åºåºã¯ã©ã¹ã®å®è£ æåã¨æå¾ã®ã¿ã¤ãã³ã°ãéç¥ããã¡ãã»ã¼ã¸ã追å ãã¾ã #define UNDOREDO_DETACHED 0 #define UNDOREDO_ATTACHED 1 #define UNDOREDO_UNDO 2 #define UNDOREDO_REDO 3 #define UNDOREDO_UNDO_BEGIN 4 #define UNDOREDO_UNDO_END 5 #define UNDOREDO_REDO_BEGIN 6 #define UNDOREDO_REDO_END 7 class CRestoreObj : public IRestoreObj {
ã¯ããã« ã©ã®ãããªã¢ããªã±ã¼ã·ã§ã³ã§ã Undo æ©è½ã¯ãã²ã¨ã欲ããæ©è½ã®ä¸ã¤ã ã¨æãã¾ãããæ®å¿µãªãã Undo ãå®ç¾ããããã®æ¨æºçãªãã¬ã¼ã ã¯ã¼ã¯ã¨ãããããªãã®ã¯åå¨ãã¾ãã ã§ãããã¢ããªã±ã¼ã·ã§ã³ã« Undo ã®æ©è½ã追å ãããã¨ããã°ä¸ããèªåã§æ¸ãå¿ è¦ãããã¾ã ããã§ã¯ã³ãã³ããªã¹ãå½¢å¼ã® Undo ã®å®è£ ã«ã¤ãã¦èª¬æãã¾ããã Undo ã®ä»çµã¿ Undo ã®ä»çµã¿èªä½ã¯å®ã¯ã¨ã¦ãç°¡åã§ã Undo ããã¼ã¸ã£ã¯ã³ãã³ãã®ä¸èº«ã¯é¢ç¥ããããã ã³ãã³ãã®ãªã¹ãã管çãã¦ããã ãã§ã ã³ãã³ãã®ãªã¹ãã§ç¾å¨æ³¨ç®ãã¦ããã¨ãããåã«æ»ãã®ã Undoãå ã¸é²ããã®ã Redo ã§ã 注ç®ãã¦ããä½ç½®ããåã«å¤ãã£ãã³ãã³ãã«ã¯ Redo ã®éç¥ãéããå ã«å¤ãã£ãã³ãã³ãã«ã¯ Undo ã®éç¥ãéãã¾ã ãã ããã ãã§ã ã³ãã³ãã®ãªã¹ãã¨ãã®æ³¨ç®ä½ç½®ã Undo/Re
ã¯ããã« C++20 ã®åã®åºç¤ç¥èã¨ãã¦ã以å C++ ã®åå解決 ã§ãç´¹ä»ãã ADL (Argument-dependent name lookup) ã«é¢é£ãã話é¡ãå°ãç´¹ä»ãã¦ã¿ã¾ã â è足ããã§ãååãæ¢ãããªã©ã¨è¨ã£ã¦ããã®ã¯ãã¹ã¦ã³ã³ãã¤ã«æã®è©±ã§ã ã³ã³ãã¤ã©å é¨ã®è©±ã§ã å®â¦
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}