mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:02:44 +00:00 
			
		
		
		
	 e2d7f585da
			
		
	
	
		e2d7f585da
		
	
	
	
	
		
			
			Hey, it actually works! You can now edit the same file in both editors and even the C++ highlighting updates correctly in both of them. :^)
		
			
				
	
	
		
			37 lines
		
	
	
	
		
			839 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
	
		
			839 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include "TextDocument.h"
 | |
| #include <AK/Noncopyable.h>
 | |
| #include <AK/NonnullRefPtrVector.h>
 | |
| #include <AK/OwnPtr.h>
 | |
| #include <LibGUI/GModel.h>
 | |
| 
 | |
| class Project {
 | |
|     AK_MAKE_NONCOPYABLE(Project)
 | |
|     AK_MAKE_NONMOVABLE(Project)
 | |
| public:
 | |
|     static OwnPtr<Project> load_from_file(const String& path);
 | |
| 
 | |
|     [[nodiscard]] bool add_file(const String& filename);
 | |
| 
 | |
|     TextDocument* get_file(const String& filename);
 | |
| 
 | |
|     GModel& model() { return *m_model; }
 | |
| 
 | |
|     template<typename Callback>
 | |
|     void for_each_text_file(Callback callback) const
 | |
|     {
 | |
|         for (auto& file : m_files) {
 | |
|             callback(file);
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
| private:
 | |
|     friend class ProjectModel;
 | |
|     explicit Project(const String& path, Vector<String>&& files);
 | |
| 
 | |
|     String m_path;
 | |
|     RefPtr<GModel> m_model;
 | |
|     NonnullRefPtrVector<TextDocument> m_files;
 | |
| };
 |