2020-08-15 10:58:31 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
2022-02-15 13:28:01 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-08-15 10:58:31 +03:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-15 10:58:31 +03:00
|
|
|
*/
|
2020-08-17 15:22:30 +02:00
|
|
|
|
2020-08-15 10:58:31 +03:00
|
|
|
#include "CodeDocument.h"
|
|
|
|
|
2020-08-17 15:22:30 +02:00
|
|
|
namespace HackStudio {
|
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
NonnullRefPtr<CodeDocument> CodeDocument::create(ByteString const& file_path, Client* client)
|
2020-09-27 00:11:15 +03:00
|
|
|
{
|
2021-04-23 16:46:57 +02:00
|
|
|
return adopt_ref(*new CodeDocument(file_path, client));
|
2020-09-27 00:11:15 +03:00
|
|
|
}
|
|
|
|
|
2020-08-15 10:58:31 +03:00
|
|
|
NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
|
|
|
|
{
|
2021-04-23 16:46:57 +02:00
|
|
|
return adopt_ref(*new CodeDocument(client));
|
2020-08-15 10:58:31 +03:00
|
|
|
}
|
2020-08-17 15:22:30 +02:00
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
CodeDocument::CodeDocument(ByteString const& file_path, Client* client)
|
2020-09-27 00:11:15 +03:00
|
|
|
: TextDocument(client)
|
|
|
|
, m_file_path(file_path)
|
|
|
|
{
|
2022-01-17 19:42:07 -08:00
|
|
|
auto lexical_path = LexicalPath(file_path);
|
2023-03-08 20:59:05 +00:00
|
|
|
m_language = Syntax::language_from_filename(lexical_path);
|
2020-09-27 00:11:15 +03:00
|
|
|
}
|
|
|
|
|
2020-08-15 10:58:31 +03:00
|
|
|
CodeDocument::CodeDocument(Client* client)
|
|
|
|
: TextDocument(client)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-03-15 11:33:18 +00:00
|
|
|
CodeDocument::DiffType CodeDocument::line_difference(size_t line) const
|
|
|
|
{
|
|
|
|
return m_line_differences[line];
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeDocument::set_line_differences(Badge<HackStudio::Editor>, Vector<HackStudio::CodeDocument::DiffType> line_differences)
|
|
|
|
{
|
|
|
|
m_line_differences = move(line_differences);
|
|
|
|
}
|
|
|
|
|
2020-08-17 15:22:30 +02:00
|
|
|
}
|