Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.viewbinding.ViewBinding
import com.itsaky.androidide.databinding.FragmentEmptyStateBinding
import com.itsaky.androidide.editor.ui.EditorLongPressEvent
import com.itsaky.androidide.editor.ui.IDEEditor
import com.itsaky.androidide.idetooltips.TooltipManager
import com.itsaky.androidide.utils.viewLifecycleScope
Expand All @@ -21,9 +20,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode

abstract class EmptyStateFragment<T : ViewBinding> : FragmentWithBinding<T> {
constructor(layout: Int, bind: (View) -> T) : super(layout, bind)
Expand Down Expand Up @@ -161,22 +157,4 @@ abstract class EmptyStateFragment<T : ViewBinding> : FragmentWithBinding<T> {
)
}

override fun onResume() {
super.onResume()
// Register this fragment to receive events
EventBus.getDefault().register(this)
}

override fun onPause() {
super.onPause()
// Unregister to avoid memory leaks
EventBus.getDefault().unregister(this)
}

// This method will be called when an EditorLongPressEvent is posted
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEditorLongPressed(event: EditorLongPressEvent) {
val motionEvent = event.motionEvent
onFragmentLongPressed(motionEvent.x, motionEvent.y)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BuildOutputFragment : NonEditableEditorFragment() {
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)
editor?.includeDebugInfoOnCopy = true
editor?.tag = TooltipTag.PROJECT_BUILD_OUTPUT
emptyStateViewModel.setEmptyMessage(getString(R.string.msg_emptyview_buildoutput))
if (unsavedLines.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ abstract class LogViewFragment<V : LogViewModel> :
editor.setTextSize(12f)
editor.typefaceText = jetbrainsMono()
editor.isEnsurePosAnimEnabled = false
editor.includeDebugInfoOnCopy = true
editor.tag = tooltipTag
editor.cursorAnimator = NoOpCursorAnimator

Expand Down

This file was deleted.

17 changes: 6 additions & 11 deletions editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ import com.itsaky.androidide.utils.BasicBuildInfo
import com.itsaky.androidide.utils.DocumentUtils
import com.itsaky.androidide.utils.flashError
import io.github.rosemoe.sora.event.ContentChangeEvent
import io.github.rosemoe.sora.event.LongPressEvent
import io.github.rosemoe.sora.event.SelectionChangeEvent
import io.github.rosemoe.sora.lang.EmptyLanguage
import io.github.rosemoe.sora.lang.Language
Expand Down Expand Up @@ -526,12 +525,14 @@ constructor(
start: Int,
end: Int,
) {
var targetText = text
if (includeDebugInfoOnCopy) {
targetText = BasicBuildInfo.BASIC_INFO + System.lineSeparator() + text
// Extract selected text first, then prepend build info
val selectedText = text.subSequence(start, end)
val textWithBuildInfo = BasicBuildInfo.BASIC_INFO + System.lineSeparator() + selectedText
doCopy(textWithBuildInfo, 0, textWithBuildInfo.length)
} else {
doCopy(text, start, end)
}

doCopy(targetText, start, end)
}

@VisibleForTesting
Expand Down Expand Up @@ -825,12 +826,6 @@ constructor(
}

EventBus.getDefault().register(this)
if (isReadOnlyContext) {
subscribeEvent(LongPressEvent::class.java) { event, _ ->
EventBus.getDefault().post(EditorLongPressEvent(event.causingEvent))
event.intercept()
}
}
}

private fun handleCustomTextReplacement(event: ContentChangeEvent) {
Expand Down